Fix forced-paper execution semantics and add minimum forced notional control
This commit is contained in:
@@ -14,6 +14,7 @@ TRADE_INTERVAL_HOURS=2
|
|||||||
CURATE_INTERVAL_MINUTES=30
|
CURATE_INTERVAL_MINUTES=30
|
||||||
TIMEZONE=America/Los_Angeles
|
TIMEZONE=America/Los_Angeles
|
||||||
FORCE_PAPER_TRADES=true
|
FORCE_PAPER_TRADES=true
|
||||||
|
FORCE_PAPER_MIN_USD=10
|
||||||
|
|
||||||
OLLAMA_URL=http://10.30.20.110:11434
|
OLLAMA_URL=http://10.30.20.110:11434
|
||||||
OLLAMA_CURATOR_MODEL=gemma3:latest
|
OLLAMA_CURATOR_MODEL=gemma3:latest
|
||||||
|
|||||||
12
bot.py
12
bot.py
@@ -69,6 +69,12 @@ def run_cycle():
|
|||||||
memory_hits = qdrant_similar(symbol, json.dumps(news)[:2000], limit=5)
|
memory_hits = qdrant_similar(symbol, json.dumps(news)[:2000], limit=5)
|
||||||
decision = llm_final_decision(symbol, news, strat, memory_hits)
|
decision = llm_final_decision(symbol, news, strat, memory_hits)
|
||||||
|
|
||||||
|
if settings.paper_mode and settings.force_paper_trades and decision["action"] == "hold":
|
||||||
|
decision["action"] = "buy"
|
||||||
|
decision["confidence"] = max(decision.get("confidence", 0.0), settings.min_confidence)
|
||||||
|
decision["order_usd"] = max(decision.get("order_usd", 0.0), settings.force_paper_min_usd)
|
||||||
|
decision["reason"] = f"{decision.get('reason','')} | force_paper_trades"
|
||||||
|
|
||||||
drow = BotDecision(
|
drow = BotDecision(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
action=decision["action"],
|
action=decision["action"],
|
||||||
@@ -82,11 +88,6 @@ def run_cycle():
|
|||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(drow)
|
db.refresh(drow)
|
||||||
|
|
||||||
if settings.paper_mode and settings.force_paper_trades and decision["action"] == "hold":
|
|
||||||
decision["action"] = "buy"
|
|
||||||
decision["confidence"] = max(decision.get("confidence", 0.0), settings.min_confidence)
|
|
||||||
decision["reason"] = f"{decision.get('reason','')} | force_paper_trades"
|
|
||||||
|
|
||||||
should_trade = decision["action"] in {"buy", "sell"} and decision["confidence"] >= settings.min_confidence
|
should_trade = decision["action"] in {"buy", "sell"} and decision["confidence"] >= settings.min_confidence
|
||||||
|
|
||||||
if should_trade:
|
if should_trade:
|
||||||
@@ -103,6 +104,7 @@ def run_cycle():
|
|||||||
drow.status = "executed" if ok else "failed"
|
drow.status = "executed" if ok else "failed"
|
||||||
db.add(drow)
|
db.add(drow)
|
||||||
|
|
||||||
|
if ok:
|
||||||
trade = TradeExecution(
|
trade = TradeExecution(
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
side=decision["action"],
|
side=decision["action"],
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class Settings:
|
|||||||
curate_interval_minutes = int(os.getenv("CURATE_INTERVAL_MINUTES", "30"))
|
curate_interval_minutes = int(os.getenv("CURATE_INTERVAL_MINUTES", "30"))
|
||||||
timezone = os.getenv("TIMEZONE", "America/Los_Angeles")
|
timezone = os.getenv("TIMEZONE", "America/Los_Angeles")
|
||||||
force_paper_trades = os.getenv("FORCE_PAPER_TRADES", "true").lower() == "true"
|
force_paper_trades = os.getenv("FORCE_PAPER_TRADES", "true").lower() == "true"
|
||||||
|
force_paper_min_usd = float(os.getenv("FORCE_PAPER_MIN_USD", "10"))
|
||||||
|
|
||||||
ollama_url = os.getenv("OLLAMA_URL", "http://10.30.20.110:11434")
|
ollama_url = os.getenv("OLLAMA_URL", "http://10.30.20.110:11434")
|
||||||
ollama_curator_model = os.getenv("OLLAMA_CURATOR_MODEL", "gemma3:latest")
|
ollama_curator_model = os.getenv("OLLAMA_CURATOR_MODEL", "gemma3:latest")
|
||||||
|
|||||||
Reference in New Issue
Block a user