Skip to content

Commit

Permalink
Fixed passing of position_id
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jan 18, 2025
1 parent 075a7e1 commit 126c2b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tradeexecutor/cli/close_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,14 @@ def close_single_or_all_positions(
quantity = p.get_quantity()

if trading_quantity != quantity:
logger.info("Position quantity: %f, available for trade quantity: %f", quantity, trading_quantity)
logger.info(
"Position #%d quantity: %f, available for trade quantity: %f",
p.position_id,
quantity,
trading_quantity,
)
for t in p.trades.values():
logger.info("Trade %s, quantity", t, quantity)
logger.info("Trade %s, quantity: %s", t, quantity)

assert trading_quantity == quantity, (f"Position quantity vs. available trading quantity mismatch.\n"
f"Probably unexecuted trades? {quantity} vs. {trading_quantity}\n"
Expand Down
3 changes: 3 additions & 0 deletions tradeexecutor/cli/commands/close_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def break_sync(x):
if mod.parameters:
slippage_tolerance = mod.parameters.get("slippage_tolerance", 0.01)

assert position_id

close_single_or_all_positions(
web3config.get_default(),
execution_model=execution_model,
Expand All @@ -189,6 +191,7 @@ def break_sync(x):
unit_testing=unit_testing,
valuation_model=valuation_model,
execution_context=execution_context,
position_id=position_id,
)

# Store the test trade data in the strategy history
Expand Down

0 comments on commit 126c2b1

Please sign in to comment.