Skip to content

Commit

Permalink
change behaviour when connection lost before execution
Browse files Browse the repository at this point in the history
  • Loading branch information
rob committed Dec 7, 2022
1 parent 5374659 commit 4c81ce0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sysexecution/algos/algo_original_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def prepare_and_submit_trade(self) -> orderWithControls:
order=cut_down_contract_order,
log=log)

## REFACTOR WITH EXCEPTIONS
if okay_to_do_limit_trade is missing_data:
## Safer not to trade at all
return missing_order

if okay_to_do_limit_trade:

# create and issue limit order
Expand Down Expand Up @@ -217,7 +222,12 @@ def limit_trade_viable(data: dataBlob,

# no point doing limit order if we've got imbalanced size issues, as we'd
# switch to aggressive immediately
if adverse_size_issue(ticker_object, wait_for_valid_tick=True, log=log):
raise_adverse_size_issue = adverse_size_issue(ticker_object, wait_for_valid_tick=True, log=log)
## REFACTOR WITH EXCEPTIONS
if raise_adverse_size_issue is missing_data:
return missing_data

if raise_adverse_size_issue:
log.msg("Limit trade not viable")
return False

Expand Down Expand Up @@ -279,7 +289,12 @@ def reason_to_switch_to_aggressive(data: dataBlob,
broker_order_with_controls.seconds_since_submission() > PASSIVE_TIME_OUT
)
adverse_price = ticker_object.adverse_price_movement_vs_reference()

adverse_size = adverse_size_issue(ticker_object, wait_for_valid_tick=False, log=log)
# REFACTOR FOR EXCEPTIONS
if adverse_size is missing_data:
adverse_size = True


market_about_to_close = is_market_about_to_close(data = data,
order=broker_order_with_controls,
Expand Down Expand Up @@ -341,7 +356,7 @@ def adverse_size_issue(
if current_tick_analysis is missing_data:
## serious problem with data, return True so switch to market order
## most likely case is order will be cancelled which is fine
return True
return missing_data

latest_imbalance_ratio_exceeded = _is_imbalance_ratio_exceeded(
current_tick_analysis, log=log
Expand Down

0 comments on commit 4c81ce0

Please sign in to comment.