Add explicit trade sizing
This commit is contained in:
@@ -80,6 +80,33 @@ async def test_open_trade_uses_all_available_buying_power_and_allows_repeated_en
|
||||
await database.close()
|
||||
|
||||
|
||||
async def test_open_trade_accepts_explicit_quote_notional(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")
|
||||
try:
|
||||
result = await tools.open_trade(
|
||||
"linear",
|
||||
"BTCUSDT",
|
||||
"Buy",
|
||||
"Market",
|
||||
90,
|
||||
"sized entry",
|
||||
take_profit=120,
|
||||
leverage=3,
|
||||
quote_notional=5000,
|
||||
context={"run_id": run_id},
|
||||
)
|
||||
|
||||
assert result["quantity"] == "50"
|
||||
assert result["notional"] == "5000"
|
||||
assert bybit.orders[0]["qty"] == "50"
|
||||
finally:
|
||||
await database.close()
|
||||
|
||||
|
||||
async def test_pause_blocks_entry_from_running_session(tmp_path):
|
||||
database = Database(tmp_path / "state.db")
|
||||
await database.open()
|
||||
|
||||
Reference in New Issue
Block a user