Skip to content

Commit

Permalink
fix net position error in roll code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Carver committed Nov 17, 2023
1 parent a68ee4c commit 317d163
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sysexecution/stack_handler/roll_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,17 @@ def get_strategy_name_with_largest_position_for_instrument(
diag_positions.get_all_current_strategy_instrument_positions()
)

return (
all_instrument_positions.strategy_name_with_largest_abs_position_for_instrument(
instrument_code
)
)
try:
strategy_name = all_instrument_positions.strategy_name_with_largest_abs_position_for_instrument(
instrument_code
)
except:
## corner case where nets out to 0
strategies = diag_positions.get_list_of_strategies_with_positions()
strategy_name = strategies[0]
data.log.debug("No strategies have net positions in %s, using arbitrary strategy %s" % (instrument_code, strategy_name))

return strategy_name


def create_contract_roll_orders(
Expand Down

0 comments on commit 317d163

Please sign in to comment.