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

✨ feature update capitalcom.py to include minimum amount by default i… #445

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

mraniki
Copy link
Owner

@mraniki mraniki commented Apr 16, 2024

…ncase amount is too low

@mraniki mraniki enabled auto-merge April 16, 2024 17:04
Copy link

@sourcery-ai sourcery-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.

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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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):
""" """
Copy link

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.

Suggested change
""" """
"""
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)
Copy link

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.

Suggested change
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)

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.46%. Comparing base (c24b3b3) to head (8007f96).

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.
📢 Have feedback on the report? Share it here.

@mraniki mraniki merged commit c47a27f into main Apr 16, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant