Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 update default_settings.toml and main.py #384

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion findmyorder/default_settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ findmyorder_enabled = true
parser_library = "standard"
enabled = true
# Keyword to be use to identify an order
action_identifier = "BUY SELL LONG SHORT"
action_identifier = "BUY SELL LONG SHORT DEFAULT"
# Keyword identifier for stoploss
stop_loss_identifier = "sl="
# Keyword identifier for take-profit
Expand Down
7 changes: 3 additions & 4 deletions findmyorder/handler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def __init__(self, **kwargs):
self.name = kwargs.get("name", None)
self.client = None
self.enabled = kwargs.get("enabled", None)
self.library = kwargs.get("library", None) or kwargs.get(
"parser_library", "standard"
Comment on lines +28 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider simplifying the library assignment logic.

The current logic for assigning self.library can be simplified to self.library = kwargs.get("library") or kwargs.get("parser_library", "standard"). This makes the code more readable.

Suggested change
self.library = kwargs.get("library", None) or kwargs.get(
"parser_library", "standard"
self.library = kwargs.get("library") or kwargs.get("parser_library", "standard")

)
self.action_identifier = kwargs.get("action_identifier", "BUY SELL")
self.action_identifier = self.action_identifier.lower()
self.stop_loss_identifier = kwargs.get("stop_loss_identifier", None)
Expand Down Expand Up @@ -64,11 +67,7 @@ async def search(self, message: str) -> bool:
"""
if message:
order_identifier = message.split()[0].lower()
# logger.debug("Order identifier: {}", order_identifier)
# logger.debug("Action identifiers: {}", self.action_identifiers)
if order_identifier in self.action_identifier:

# logger.debug("Order identifier found in {}", order_identifier)
Comment on lines -67 to -71
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider removing commented-out debug statements.

The commented-out debug statements can be removed to keep the code clean and maintainable. If these logs are no longer needed, it's better to remove them entirely.

return True

return False
Expand Down
4 changes: 3 additions & 1 deletion findmyorder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def __init__(
"""

self.enabled = settings.findmyorder_enabled
self.settings = settings.findmyorder
logger.debug("Settings: {}", self.settings)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Consider the security implications of logging settings.

Logging the entire settings object might expose sensitive information. Ensure that no sensitive data is included in the settings or consider logging only non-sensitive parts.

if not self.enabled:
logger.info("Module is disabled. No Client will be created.")
return
self.client_classes = self.get_all_client_classes()
self.clients = []
# Create a client for each client in settings.findmyorder
for name, client_config in settings.findmyorder.items():
for name, client_config in self.settings.items():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Check for potential NoneType in settings.

Ensure that self.settings is not None before iterating over its items. This can prevent potential runtime errors.

if (
# Skip empty client configs
client_config is None
Expand Down