mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
fix: initialize IF_TRADE to True (trades expected by default)
Root cause: IF_TRADE was initialized to False and never updated when trades executed, causing 'No trading' message to always display. Design documents (2025-02-11-complete-schema-migration) specify IF_TRADE should start as True, with trades setting it to False only after completion. Fixes sporadic issue where all trading sessions reported 'No trading' despite successful buy/sell actions.
This commit is contained in:
@@ -80,7 +80,7 @@ class RuntimeConfigManager:
|
|||||||
initial_config = {
|
initial_config = {
|
||||||
"TODAY_DATE": date,
|
"TODAY_DATE": date,
|
||||||
"SIGNATURE": model_sig,
|
"SIGNATURE": model_sig,
|
||||||
"IF_TRADE": False,
|
"IF_TRADE": True, # FIX: Trades are expected by default
|
||||||
"JOB_ID": job_id,
|
"JOB_ID": job_id,
|
||||||
"TRADING_DAY_ID": trading_day_id
|
"TRADING_DAY_ID": trading_day_id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class TestRuntimeConfigCreation:
|
|||||||
|
|
||||||
assert config["TODAY_DATE"] == "2025-01-16"
|
assert config["TODAY_DATE"] == "2025-01-16"
|
||||||
assert config["SIGNATURE"] == "gpt-5"
|
assert config["SIGNATURE"] == "gpt-5"
|
||||||
assert config["IF_TRADE"] is False
|
assert config["IF_TRADE"] is True
|
||||||
assert config["JOB_ID"] == "test-job-123"
|
assert config["JOB_ID"] == "test-job-123"
|
||||||
|
|
||||||
def test_create_runtime_config_unique_paths(self):
|
def test_create_runtime_config_unique_paths(self):
|
||||||
@@ -108,6 +108,32 @@ class TestRuntimeConfigCreation:
|
|||||||
# Config file should exist
|
# Config file should exist
|
||||||
assert os.path.exists(config_path)
|
assert os.path.exists(config_path)
|
||||||
|
|
||||||
|
def test_create_runtime_config_if_trade_defaults_true(self):
|
||||||
|
"""Test that IF_TRADE initializes to True (trades expected by default)"""
|
||||||
|
from api.runtime_manager import RuntimeConfigManager
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
manager = RuntimeConfigManager(data_dir=temp_dir)
|
||||||
|
|
||||||
|
config_path = manager.create_runtime_config(
|
||||||
|
job_id="test-job-123",
|
||||||
|
model_sig="test-model",
|
||||||
|
date="2025-01-16",
|
||||||
|
trading_day_id=1
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Read the config file
|
||||||
|
with open(config_path, 'r') as f:
|
||||||
|
config = json.load(f)
|
||||||
|
|
||||||
|
# Verify IF_TRADE is True by default
|
||||||
|
assert config["IF_TRADE"] is True, "IF_TRADE should initialize to True"
|
||||||
|
finally:
|
||||||
|
# Cleanup
|
||||||
|
if os.path.exists(config_path):
|
||||||
|
os.remove(config_path)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
class TestRuntimeConfigCleanup:
|
class TestRuntimeConfigCleanup:
|
||||||
|
|||||||
Reference in New Issue
Block a user