Update app.py
Browse files
app.py
CHANGED
|
@@ -419,10 +419,13 @@ def get_symbol_volume_limits(ssl_sock, account_id, symbol_id):
|
|
| 419 |
# Helper: Convert lots to cTrader protocol volume using broker's lotSize
|
| 420 |
def lots_to_protocol_volume(lots, lot_size):
|
| 421 |
"""Convert a lot value to cTrader protocol units.
|
| 422 |
-
Protocol volume = lots × lotSize
|
| 423 |
-
e.g. EURUSD: 0.01 lots × 100000 lotSize
|
| 424 |
-
e.g.
|
| 425 |
-
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
# Helper: Get the configured lot size for a given ticker
|
| 428 |
def get_volume_for_symbol(ticker):
|
|
@@ -449,7 +452,7 @@ def place_market_order_smart(ssl_sock, account_id, symbol_id, trade_side, volume
|
|
| 449 |
if try_volume < min_volume:
|
| 450 |
break
|
| 451 |
|
| 452 |
-
logger.info(f"Order attempt {attempt}: volume={try_volume} protocol units
|
| 453 |
res = place_market_order(ssl_sock, account_id, symbol_id, trade_side, int(try_volume))
|
| 454 |
|
| 455 |
if res.get('status') == 'success':
|
|
@@ -466,7 +469,7 @@ def place_market_order_smart(ssl_sock, account_id, symbol_id, trade_side, volume
|
|
| 466 |
# Different error, don't retry
|
| 467 |
return res
|
| 468 |
|
| 469 |
-
return {"status": "error", "message": f"Not enough funds even at minimum volume ({min_volume} protocol units
|
| 470 |
|
| 471 |
|
| 472 |
# Helper: Fetch Account Balance/Details
|
|
|
|
| 419 |
# Helper: Convert lots to cTrader protocol volume using broker's lotSize
|
| 420 |
def lots_to_protocol_volume(lots, lot_size):
|
| 421 |
"""Convert a lot value to cTrader protocol units.
|
| 422 |
+
Protocol volume = lots × lotSize
|
| 423 |
+
e.g. EURUSD: 0.01 lots × 100000 lotSize = 1,000
|
| 424 |
+
e.g. BTCUSD: 0.01 lots × 100 lotSize = 1
|
| 425 |
+
e.g. NAS100: 0.05 lots × 100 lotSize = 5"""
|
| 426 |
+
result = int(lots * lot_size)
|
| 427 |
+
logger.info(f"lots_to_protocol_volume: {lots} lots × {lot_size} lotSize = {result} protocol units")
|
| 428 |
+
return result
|
| 429 |
|
| 430 |
# Helper: Get the configured lot size for a given ticker
|
| 431 |
def get_volume_for_symbol(ticker):
|
|
|
|
| 452 |
if try_volume < min_volume:
|
| 453 |
break
|
| 454 |
|
| 455 |
+
logger.info(f"Order attempt {attempt}: volume={try_volume} protocol units")
|
| 456 |
res = place_market_order(ssl_sock, account_id, symbol_id, trade_side, int(try_volume))
|
| 457 |
|
| 458 |
if res.get('status') == 'success':
|
|
|
|
| 469 |
# Different error, don't retry
|
| 470 |
return res
|
| 471 |
|
| 472 |
+
return {"status": "error", "message": f"Not enough funds even at minimum volume ({min_volume} protocol units)"}
|
| 473 |
|
| 474 |
|
| 475 |
# Helper: Fetch Account Balance/Details
|