-
Notifications
You must be signed in to change notification settings - Fork 2
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
✨ feature update capitalcom.py to include minimum amount by default i… #445
Conversation
…ncase amount is too low
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.
Hey @mraniki - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Docstrings: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@@ -245,6 +245,13 @@ async def get_instrument_decimals(self, instrument): | |||
logger.debug("Decimals {}", decimals) | |||
return int(decimals) | |||
|
|||
async def get_instrument_min_amount(self, instrument): | |||
""" """ |
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.
suggestion (code_clarification): Docstring is empty for the method get_instrument_min_amount
.
Consider adding a brief description of what the method does, its parameters, and its return type for better code documentation and readability.
""" """ | |
""" | |
Asynchronously retrieves the minimum trade amount for a specified instrument. | |
Args: | |
instrument (str): The identifier for the instrument. | |
Returns: | |
float: The minimum amount that can be traded for the given instrument. | |
""" |
async def get_instrument_min_amount(self, instrument): | ||
""" """ | ||
instrument_info = self.client.single_market(instrument) | ||
minimum_amount = instrument_info.get("minDealSize", {}).get("value", 0) |
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.
suggestion (edge_case_not_handled): Consider handling potential None
values more explicitly.
If instrument_info
or minDealSize
is None
, this line could raise an exception. It might be safer to ensure that instrument_info
is a dictionary and minDealSize
contains a 'value' key before attempting to access it.
minimum_amount = instrument_info.get("minDealSize", {}).get("value", 0) | |
instrument_info = self.client.single_market(instrument) | |
if isinstance(instrument_info, dict) and "minDealSize" in instrument_info: | |
minimum_amount = instrument_info["minDealSize"].get("value", 0) | |
else: | |
minimum_amount = 0 | |
logger.debug("Minimum {}", minimum_amount) | |
return int(minimum_amount) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #445 +/- ##
==========================================
+ Coverage 70.99% 71.46% +0.46%
==========================================
Files 7 7
Lines 431 438 +7
==========================================
+ Hits 306 313 +7
Misses 125 125 ☔ View full report in Codecov by Sentry. |
…ncase amount is too low