удалить лимиты
This commit is contained in:
@@ -5,14 +5,13 @@ from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
|
||||
from llm_trade_bot.agent import AgentTools, _has_existing_idea
|
||||
from llm_trade_bot.agent import AgentTools
|
||||
from llm_trade_bot.config import (
|
||||
AppConfig,
|
||||
BraveConfig,
|
||||
BybitConfig,
|
||||
ZaiConfig,
|
||||
PromptsConfig,
|
||||
RiskConfig,
|
||||
ScannerConfig,
|
||||
ScheduleConfig,
|
||||
StorageConfig,
|
||||
@@ -55,28 +54,27 @@ def make_config(database_path: Path) -> AppConfig:
|
||||
PromptsConfig(database_path.parent / "prompts.md"),
|
||||
ScheduleConfig(ZoneInfo("Europe/Warsaw"), (time(9), time(21))),
|
||||
ScannerConfig(),
|
||||
RiskConfig(),
|
||||
StorageConfig(database_path),
|
||||
)
|
||||
|
||||
|
||||
async def test_open_trade_is_risk_sized_and_deduplicated_within_run(tmp_path):
|
||||
async def test_open_trade_uses_all_available_buying_power_and_allows_repeated_entries(tmp_path):
|
||||
database = Database(tmp_path / "state.db")
|
||||
await database.open()
|
||||
bybit = FakeBybit()
|
||||
tools = AgentTools(make_config(database.path), database, bybit) # type: ignore[arg-type]
|
||||
run_id = await database.start_run("test")
|
||||
context = {"run_id": run_id, "candidate_keys": {"linear:BTCUSDT"}}
|
||||
context = {"run_id": run_id}
|
||||
try:
|
||||
first = await tools.open_trade(
|
||||
"linear", "BTCUSDT", "Buy", "Market", 90, 2, "test", take_profit=120, leverage=3, context=context
|
||||
"linear", "BTCUSDT", "Buy", "Market", 90, "test", take_profit=120, leverage=3, context=context
|
||||
)
|
||||
second = await tools.open_trade(
|
||||
"linear", "BTCUSDT", "Buy", "Market", 90, 2, "test", take_profit=120, leverage=3, context=context
|
||||
"linear", "BTCUSDT", "Buy", "Market", 90, "test", take_profit=120, leverage=3, context=context
|
||||
)
|
||||
assert first["quantity"] == "20"
|
||||
assert second["deduplicated"] is True
|
||||
assert len(bybit.orders) == 1
|
||||
assert first["quantity"] == "300"
|
||||
assert second["quantity"] == "300"
|
||||
assert len(bybit.orders) == 2
|
||||
assert bybit.orders[0]["stopLoss"] == "90"
|
||||
finally:
|
||||
await database.close()
|
||||
@@ -95,29 +93,9 @@ async def test_pause_blocks_entry_from_running_session(tmp_path):
|
||||
"Buy",
|
||||
"Market",
|
||||
90,
|
||||
2,
|
||||
"test",
|
||||
take_profit=120,
|
||||
context={"run_id": 1, "candidate_keys": {"linear:BTCUSDT"}},
|
||||
context={"run_id": 1},
|
||||
)
|
||||
finally:
|
||||
await database.close()
|
||||
|
||||
|
||||
def test_seeded_spot_balance_does_not_block_new_agent_entry():
|
||||
state = {
|
||||
"wallets": {"spot": {"balances": [{"asset": "SOL", "free": "4", "locked": "0"}]}},
|
||||
"positions": [],
|
||||
"open_orders": [],
|
||||
}
|
||||
assert _has_existing_idea(state, "spot", "SOLUSDT") is False
|
||||
|
||||
state["open_orders"] = [
|
||||
{
|
||||
"category": "spot",
|
||||
"symbol": "SOLUSDT",
|
||||
"protective": True,
|
||||
"client_id": "ltb-12-abcd-tp",
|
||||
}
|
||||
]
|
||||
assert _has_existing_idea(state, "spot", "SOLUSDT") is True
|
||||
|
||||
Reference in New Issue
Block a user