Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ symbol_volumes = {
|
|
| 43 |
"ETHUSD": 0.01,
|
| 44 |
"EURUSD": 0.01,
|
| 45 |
"_DEFAULT_FOREX": 0.01, # catch-all for any forex pair not explicitly listed
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
# Per-symbol BUY/SELL/STOP-TRADE/ANCHOR toggle (controlled from dashboard, NOT TradingView)
|
|
@@ -58,6 +59,7 @@ symbol_status = {
|
|
| 58 |
"ETHUSD": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 59 |
"EURUSD": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 60 |
"_DEFAULT_FOREX": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
CONFIG_FILE = "bot_config.json"
|
|
@@ -479,10 +481,14 @@ def lots_to_protocol_volume(lots, lot_size):
|
|
| 479 |
|
| 480 |
# Helper: Get the configured lot size for a given ticker
|
| 481 |
def get_volume_for_symbol(ticker):
|
| 482 |
-
"""Look up the per-symbol volume (in lots). Falls back to _DEFAULT_FOREX, then DEFAULT_VOLUME_LOTS."""
|
| 483 |
ticker_upper = ticker.upper()
|
| 484 |
if ticker_upper in symbol_volumes:
|
| 485 |
return symbol_volumes[ticker_upper]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
# Fallback: if it looks like a forex pair (6 chars, all letters), use default forex
|
| 487 |
if len(ticker_upper) == 6 and ticker_upper.isalpha():
|
| 488 |
return symbol_volumes.get('_DEFAULT_FOREX', DEFAULT_VOLUME_LOTS)
|
|
@@ -826,7 +832,7 @@ async def dashboard(request: Request):
|
|
| 826 |
positions_html = '<p style="color: #64748b; margin: 10px 0 0 0;">No active positions found.</p>'
|
| 827 |
|
| 828 |
# 1b. Construct per-symbol volume rows HTML
|
| 829 |
-
display_order = ["NAS100", "NAS100m", "USTEC", "US500", "US500m", "US30", "US30m", "BTCUSD", "ETHUSD", "EURUSD", "_DEFAULT_FOREX"]
|
| 830 |
volume_rows_html = ""
|
| 831 |
for sym in display_order:
|
| 832 |
if sym not in symbol_volumes:
|
|
@@ -837,7 +843,7 @@ async def dashboard(request: Request):
|
|
| 837 |
sell_on = status.get("sell", True)
|
| 838 |
stop_on = status.get("stop-trade", True)
|
| 839 |
anchor_on = status.get("anchor", True)
|
| 840 |
-
display_name = "Default Forex" if sym == "_DEFAULT_FOREX" else sym
|
| 841 |
row_bg = "#0f172a" if display_order.index(sym) % 2 == 0 else "#111827"
|
| 842 |
# Build toggle buttons for all 4 actions
|
| 843 |
def _btn(label, key, is_on, on_color):
|
|
@@ -1283,7 +1289,7 @@ async def webhook(request: Request):
|
|
| 1283 |
# ββ Dashboard action toggle filter ββ
|
| 1284 |
# If the user disabled this action for this symbol on the dashboard, ignore it instantly
|
| 1285 |
if action in ["BUY", "SELL", "STOP-TRADE", "ANCHOR"]:
|
| 1286 |
-
status = symbol_status.get(ticker, symbol_status.get("_DEFAULT_FOREX", {"buy": True, "sell": True, "stop-trade": True, "anchor": True}))
|
| 1287 |
is_allowed = status.get(action.lower(), True)
|
| 1288 |
if not is_allowed:
|
| 1289 |
ignore_msg = f"{action} for {ticker} IGNORED β disabled on dashboard"
|
|
|
|
| 43 |
"ETHUSD": 0.01,
|
| 44 |
"EURUSD": 0.01,
|
| 45 |
"_DEFAULT_FOREX": 0.01, # catch-all for any forex pair not explicitly listed
|
| 46 |
+
"_DEFAULT_CRYPTO": 0.01, # catch-all for any crypto pair not explicitly listed
|
| 47 |
}
|
| 48 |
|
| 49 |
# Per-symbol BUY/SELL/STOP-TRADE/ANCHOR toggle (controlled from dashboard, NOT TradingView)
|
|
|
|
| 59 |
"ETHUSD": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 60 |
"EURUSD": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 61 |
"_DEFAULT_FOREX": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 62 |
+
"_DEFAULT_CRYPTO": {"buy": True, "sell": True, "stop-trade": True, "anchor": True},
|
| 63 |
}
|
| 64 |
|
| 65 |
CONFIG_FILE = "bot_config.json"
|
|
|
|
| 481 |
|
| 482 |
# Helper: Get the configured lot size for a given ticker
|
| 483 |
def get_volume_for_symbol(ticker):
|
| 484 |
+
"""Look up the per-symbol volume (in lots). Falls back to _DEFAULT_CRYPTO or _DEFAULT_FOREX, then DEFAULT_VOLUME_LOTS."""
|
| 485 |
ticker_upper = ticker.upper()
|
| 486 |
if ticker_upper in symbol_volumes:
|
| 487 |
return symbol_volumes[ticker_upper]
|
| 488 |
+
# Known crypto suffixes
|
| 489 |
+
CRYPTO_BASES = ["BTC", "ETH", "XLM", "BCH", "SOL", "DOGE", "BNB", "LTC", "ADA", "AVAX", "LNK", "MATIC", "EOS", "DOT", "XRP", "SHIB", "UNI", "LINK"]
|
| 490 |
+
if any(ticker_upper.startswith(base) for base in CRYPTO_BASES) and ticker_upper.endswith("USD"):
|
| 491 |
+
return symbol_volumes.get('_DEFAULT_CRYPTO', DEFAULT_VOLUME_LOTS)
|
| 492 |
# Fallback: if it looks like a forex pair (6 chars, all letters), use default forex
|
| 493 |
if len(ticker_upper) == 6 and ticker_upper.isalpha():
|
| 494 |
return symbol_volumes.get('_DEFAULT_FOREX', DEFAULT_VOLUME_LOTS)
|
|
|
|
| 832 |
positions_html = '<p style="color: #64748b; margin: 10px 0 0 0;">No active positions found.</p>'
|
| 833 |
|
| 834 |
# 1b. Construct per-symbol volume rows HTML
|
| 835 |
+
display_order = ["NAS100", "NAS100m", "USTEC", "US500", "US500m", "US30", "US30m", "BTCUSD", "ETHUSD", "EURUSD", "_DEFAULT_FOREX", "_DEFAULT_CRYPTO"]
|
| 836 |
volume_rows_html = ""
|
| 837 |
for sym in display_order:
|
| 838 |
if sym not in symbol_volumes:
|
|
|
|
| 843 |
sell_on = status.get("sell", True)
|
| 844 |
stop_on = status.get("stop-trade", True)
|
| 845 |
anchor_on = status.get("anchor", True)
|
| 846 |
+
display_name = "Default Forex" if sym == "_DEFAULT_FOREX" else "Default Crypto" if sym == "_DEFAULT_CRYPTO" else sym
|
| 847 |
row_bg = "#0f172a" if display_order.index(sym) % 2 == 0 else "#111827"
|
| 848 |
# Build toggle buttons for all 4 actions
|
| 849 |
def _btn(label, key, is_on, on_color):
|
|
|
|
| 1289 |
# ββ Dashboard action toggle filter ββ
|
| 1290 |
# If the user disabled this action for this symbol on the dashboard, ignore it instantly
|
| 1291 |
if action in ["BUY", "SELL", "STOP-TRADE", "ANCHOR"]:
|
| 1292 |
+
status = symbol_status.get(ticker, symbol_status.get("_DEFAULT_CRYPTO" if any(ticker.startswith(b) for b in ["BTC","ETH","XLM","BCH","SOL","DOGE","BNB","LTC","ADA","AVAX","LNK","MATIC","EOS","DOT"]) else "_DEFAULT_FOREX", {"buy": True, "sell": True, "stop-trade": True, "anchor": True}))
|
| 1293 |
is_allowed = status.get(action.lower(), True)
|
| 1294 |
if not is_allowed:
|
| 1295 |
ignore_msg = f"{action} for {ticker} IGNORED β disabled on dashboard"
|