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

Added logs for trade processing #490

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Conversation

grzesir
Copy link
Contributor

@grzesir grzesir commented Jul 10, 2024

No description provided.

Copy link
Contributor

korbit-ai bot commented Jul 10, 2024

My review is in progress 📖 - I will have feedback for you in a few minutes!

Copy link
Contributor

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I have reviewed your code and found 4 potential issues. To discuss my individual comments that I have added, tag me in replies using @korbit-ai.


Please react with a 👍 to my comments that you find helpful and a 👎 to those you find unhelpful - this will help me learn and improve as we collaborate.

@@ -625,6 +625,9 @@ def on_trade_event_poll():

@broker.stream.add_action(broker.NEW_ORDER)
def on_trade_event_new(order):
# Log that the order was submitted
logging.info(f"Processing action for new order {order}")
Copy link
Contributor

Choose a reason for hiding this comment

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

category Logging Severity Major

The log message for a new order currently includes the entire order object, which may expose sensitive information. Please update the log message to only include relevant non-sensitive details such as the order ID and action type.

Comment on lines +1056 to +1058
self.logger.info(
f"Processing held trade event. Trade event received for stored_order: {stored_order}, type_event: {type_event}, price: {price}, filled_quantity: {filled_quantity}, multiplier: {multiplier}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

category Logging Severity Major

The log message in _process_trade_event includes detailed order information which could be sensitive. Consider removing or sanitizing these details to enhance security.

@@ -199,18 +202,33 @@ def add_event(self, event_name, payload):
self.queue.put((event_name, payload))

def process_event(self, event, payload):
# Log that we are processing an event.
self.strategy.logger.info(f"Processing event: {event}, payload: {payload}")
Copy link
Contributor

Choose a reason for hiding this comment

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

category Logging Severity Major

It looks like the log messages for processing events include the payload directly, which may contain sensitive information. Please ensure that any sensitive data is sanitized before being included in log messages.

Comment on lines +31 to +36
def __init__(self, strategy, asset, quantity, orders=None, hold=0, available=0, avg_fill_price=None):
self.strategy = strategy
self.asset = asset
self.symbol = self.asset.symbol
self.orders = None
self.avg_fill_price = avg_fill_price
Copy link
Contributor

Choose a reason for hiding this comment

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

category Objects and Data Structures

I noticed that you've added an 'avg_fill_price' attribute to the Position class, but it doesn't seem to be used anywhere in the class methods. If this attribute is not needed, I would recommend removing it to avoid confusion. If it is needed, please consider adding methods that use or manipulate this attribute, and add comments explaining its purpose and usage.

@grzesir grzesir merged commit faa74a5 into dev Jul 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant