-
Notifications
You must be signed in to change notification settings - Fork 143
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
Change type to asset_type in pandas_data.get_asset_by_symbol #388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My review is in progress 📖 - I will have feedback for you in a few minutes!
There was a problem hiding this 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-mentor.
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.
@@ -171,7 +171,7 @@ def get_last_price(self): | |||
float | |||
|
|||
""" | |||
return self.df["close"][-1] | |||
return self.df["close"].iloc[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -185,7 +185,7 @@ def get_last_dividend(self): | |||
float | |||
""" | |||
if "dividend" in self.df.columns: | |||
return self.df["dividend"][-1] | |||
return self.df["dividend"].iloc[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -233,7 +233,7 @@ def get_momentum(self, start=None, end=None): | |||
if n_rows == 0: | |||
return 0 | |||
|
|||
momentum = df_copy["close"].pct_change(n_rows - 1)[-1] | |||
momentum = df_copy["close"].pct_change(n_rows - 1).iloc[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if asset_type is None: | ||
return [asset for asset in store_assets if asset.symbol == symbol] | ||
else: | ||
return [asset for asset in store_assets if (asset.symbol == symbol and asset.asset_type == asset_type)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change from 'type' to 'asset_type' is a good one, as it makes the code more readable and less prone to confusion. However, it's important to ensure that this change doesn't affect other parts of the codebase. Even though you mentioned that there are no references to this method in the library, it's always a good practice to double-check. Also, it would be beneficial to add a test case for this method to ensure its correct functionality after the change.
Whoops. I meant to have this change be only the one line in get_asset_by_symbol. Lemme know if you want me to redo this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimwhite Great work! You are now officially a lumibot contributor, part of the best algo builders in the world. Can't wait to see what you build next.
By the way, let me know if you want some free lumiweralth products, I'd love to support you.
pandas_data.get_asset_by_symbol used type where it meant asset_type.
There don't appear to be any references to this method in the library so I'm skipping adding/updating a test.