Skip to content

Commit

Permalink
Merge pull request #272 from mraniki/dev
Browse files Browse the repository at this point in the history
💬 🔈 added better debug log
  • Loading branch information
mraniki committed Aug 11, 2023
2 parents 5391c34 + bdcdf29 commit 4da79de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
dynaconf==3.2.0 ; python_version >= "3.10" and python_version < "4.0"
dynaconf==3.2.1 ; python_version >= "3.10" and python_version < "4.0"
emoji==2.7.0 ; python_version >= "3.10" and python_version < "4.0"
loguru==0.7.0 ; python_version >= "3.10" and python_version < "4.0"
pyparsing==3.1.1 ; python_version >= "3.10" and python_version < "4.0"
Expand Down
16 changes: 10 additions & 6 deletions findmyorder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def search(
"""Search an order."""
if my_string:
string_check = my_string.split()[0].lower()
self.logger.debug(string_check)
self.logger.debug("Searching order identifier in {}", string_check)
if string_check in settings.action_identifier.lower():
return True
return False
Expand Down Expand Up @@ -94,28 +94,31 @@ async def identify_order(
)

order = order_grammar.parse_string(instring=my_string, parse_all=False)
self.logger.debug(order)
self.logger.debug("Order parsed {}", order)
return order.asDict()

except Exception as e:
return e
except Exception as error:
self.logger.error(error)
return error

async def get_order(
self,
msg: str,
):
"""get an order."""
if not await self.search(msg):
self.logger.debug("No order identified")
return None
order = await self.identify_order(msg)
if isinstance(order, dict):
order["timestamp"] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
if settings.instrument_mapping:
self.logger.debug("mapping")
await self.replace_instrument(order)
if order["instrument"] in settings.ignore_instrument:
"""ignoring instrument"""
self.logger.debug("Ignoring instrument {}", order["instrument"])
return
self.logger.debug(order)
self.logger.debug("Order identified {}", order)
return order

async def replace_instrument(self, order):
Expand All @@ -125,4 +128,5 @@ async def replace_instrument(self, order):
if item["id"] == instrument:
order["instrument"] = item["alt"]
break
self.logger.debug("Instrument symbol changed", order)
return order

0 comments on commit 4da79de

Please sign in to comment.