Skip to content

Binance Futures in hedging mode position ID error for execution algo #2504

@Oxygen923

Description

@Oxygen923

Bug Report

Expected Behavior

Nautilus Version : 1.215.0

          ```

position_id = PositionId(f"{self.instrument.id}-SHORT")
order = self.order_factory.market(
instrument_id=self.instrument.id,
order_side=OrderSide.SELL,
quantity=self.instrument.make_qty(qty),
time_in_force=TimeInForce.GTC,
exec_algorithm_id=self.exec_algorithm_id,
exec_algorithm_params=self.exec_algorithm_params
)
self.submit_order(order, position_id=position_id)


For Live Mode Error.      For backtest Normal.
if not add exec_algorithm_id and  exec_algorithm_params, then this can succssfully submit order.
But if add TWAP execution  exec_algorithm_id and  exec_algorithm_params then   Error on '_submit_order': TypeError("'position_id' argument was `None`").  
And Check Order, Order cannot be asssigned for position_id.
                
### Actual Behavior
2025-04-11T14:10:06.380884832Z [ERROR] TESTER-001.ExecClient-BINANCE: Error on '_submit_order': TypeError("'position_id' argument was `None`")
Traceback (most recent call last):
  File "/home/leo/miniconda3/envs/HFT/lib/python3.12/site-packages/nautilus_trader/adapters/binance/execution.py", line 673, in _submit_order
    position_side = self._get_position_side_from_position_id(command.position_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/leo/miniconda3/envs/HFT/lib/python3.12/site-packages/nautilus_trader/adapters/binance/execution.py", line 659, in _get_position_side_from_position_id
    PyCondition.not_none(position_id, "position_id")
  File "nautilus_trader/core/correctness.pyx", line 887, in nautilus_trader.core.correctness.PyCondition.not_none
  File "nautilus_trader/core/correctness.pyx", line 144, in nautilus_trader.core.correctness.Condition.not_none
TypeError: 'position_id' argument was `None`
### Steps to Reproduce the Problem

1.
2.
3.

### Specifications

- OS platform:
- Python version:
- `nautilus_trader` version:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions