Skip to content

Commit

Permalink
Merge pull request #436 from mraniki/dev
Browse files Browse the repository at this point in the history
🐛 update capitalcom.py
  • Loading branch information
mraniki authored Apr 8, 2024
2 parents 754d0b5 + bd5a6e8 commit 8e4ac94
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions cefi/handler/capitalcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,28 +280,18 @@ async def execute_order(self, order_params):
return f"Error executing {self.name}"

decimals = await self.get_instrument_decimals(instrument)
offer = await self.get_offer(instrument)
bid = await self.get_bid(instrument)

profit_price = (
(
await self.get_offer(instrument)
+ (int(order_params.get("take_profit", 0)) / (10**decimals))
)
(offer + (int(order_params.get("take_profit", 0)) / (10**decimals)))
if action_str == "BUY"
else (
await self.get_bid(instrument)
- (int(order_params.get("take_profit", 0)) / (10**decimals))
)
else (bid - (int(order_params.get("take_profit", 0)) / (10**decimals)))
)
stop_price = (
(
await self.get_bid(instrument)
- (int(order_params.get("stop_loss", 0)) / (10**decimals))
)
(bid - (int(order_params.get("stop_loss", 0)) / (10**decimals)))
if action_str == "BUY"
else (
self.get_offer(instrument)
+ (int(order_params.get("stop_loss", 0)) / (10**decimals))
)
else (offer + (int(order_params.get("stop_loss", 0)) / (10**decimals)))
)
logger.debug("stop price {}", stop_price)
logger.debug("profit price {}", profit_price)
Expand Down

0 comments on commit 8e4ac94

Please sign in to comment.