feat: add algo order compatibility and orphan order cleanup

- exchange.py: cancel_all_orders() now cancels both standard and algo orders
- exchange.py: get_open_orders() merges standard + algo orders
- exchange.py: cancel_order() falls back to algo cancel on failure
- bot.py: store SL/TP prices for price-based close_reason re-determination
- bot.py: add _cancel_remaining_orders() for orphan SL/TP cleanup
- bot.py: re-classify MANUAL close_reason as SL/TP via price comparison
- bot.py: cancel orphan orders on startup when no position exists
- tests: fix env setup for testnet config and ML filter mocking
- docs: add backtest market context and algo order fix design specs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
21in7
2026-03-23 20:46:59 +09:00
parent ff2566dfef
commit 17742da6af
8 changed files with 549 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ def config():
"NOTION_TOKEN": "secret_test",
"NOTION_DATABASE_ID": "db_test",
"DISCORD_WEBHOOK_URL": "",
"BINANCE_TESTNET": "false",
})
return Config()
@@ -34,6 +35,7 @@ def sample_df():
"low": close * 0.995,
"close": close,
"volume": np.random.randint(100000, 1000000, n).astype(float),
"atr": np.full(n, 0.005),
})

View File

@@ -29,6 +29,7 @@ def test_no_model_should_enter_returns_true(tmp_path):
assert f.should_enter(features) is True
@patch.dict("os.environ", {"NO_ML_FILTER": "false"})
def test_should_enter_above_threshold():
"""확률 >= 0.60 이면 True"""
f = MLFilter(threshold=0.60)
@@ -40,6 +41,7 @@ def test_should_enter_above_threshold():
assert f.should_enter(features) is True
@patch.dict("os.environ", {"NO_ML_FILTER": "false"})
def test_should_enter_below_threshold():
"""확률 < 0.60 이면 False"""
f = MLFilter(threshold=0.60)