Skip to content

Commit

Permalink
🐛 update capitalcom.py and example.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Apr 19, 2024
1 parent fc34d0a commit cb662c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions cefi/handler/capitalcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def get_quote(self, instrument):
# logger.debug("Instrument verification: {}", search_markets)

market = self.client.single_market(instrument)
# logger.debug("Raw Quote: {}", market)
# logger.debug("market: {}", market)

quote = market["snapshot"]["offer"]
logger.debug("Quote: {}", quote)
Expand Down Expand Up @@ -254,8 +254,8 @@ async def get_instrument_min_amount(self, instrument):
.get("minDealSize", {})
.get("value", 0)
)
logger.debug("Minimum {}", minimum_amount)
return int(minimum_amount)
logger.debug("Minimum Amount Needed {}", minimum_amount)
return float(minimum_amount)

async def execute_order(self, order_params):
"""
Expand Down Expand Up @@ -283,9 +283,8 @@ async def execute_order(self, order_params):
is_percentage=self.trading_risk_percentage,
)
min_amount = await self.get_instrument_min_amount(instrument)
logger.debug("min_amount {}", min_amount)
amount = max(amount, min_amount)
logger.debug("amount {}", amount)
logger.debug("Amount to execute {}", amount)
await asyncio.sleep(1) # Wait for 1 second

if not (await self.pre_order_checks(order_params)):
Expand Down
2 changes: 1 addition & 1 deletion examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def main():
# # EURUSD: -3.22
order = {
"action": "BUY",
"instrument": "EURUSD",
"instrument": "US500",
"quantity": 10,
"take_profit": 100,
"stop_loss": 1000,
Expand Down

0 comments on commit cb662c8

Please sign in to comment.