close_position_with_empty_trade#

API documentation for tradeexecutor.state.repair.close_position_with_empty_trade Python function.

close_position_with_empty_trade(portfolio, p)[source]#

Make a trade that closes the position.

  • Closes an open position that has lost it tokens, in accounting correction

  • This trade has size of 0 and pricing data from the opening trade

  • TradeExecution.repaired_trade_id is set for this trade to be the opening trade

  • We assume closed positions must have at least 2 trades, so this function will generate the final trade and now the position has at least opening trade + this trade (TODO: This assumption should be changed)

Parameters:
Return type:

TradeExecution