File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 1
1
from copy import copy
2
2
from dataclasses import dataclass
3
3
4
- from syscore .exceptions import missingContract
4
+ from syscore .exceptions import missingContract , missingData
5
5
from syscore .constants import missing_data , arg_not_supplied
6
6
from sysexecution .orders .named_order_objects import missing_order
7
7
@@ -165,21 +165,21 @@ def get_market_data_for_order_modifies_ticker_object(
165
165
log = contract_order .log_with_attributes (self .data .log )
166
166
167
167
# Get the first 'reference' tick
168
- reference_tick = (
169
- ticker_object .wait_for_valid_bid_and_ask_and_return_current_tick (
170
- wait_time_seconds = 10
168
+ try :
169
+ reference_tick = (
170
+ ticker_object .wait_for_valid_bid_and_ask_and_return_current_tick (
171
+ wait_time_seconds = 10
172
+ )
171
173
)
172
- )
173
-
174
- tick_analysis = ticker_object .analyse_for_tick (reference_tick )
175
-
176
- if tick_analysis is missing_data :
174
+ except missingData :
177
175
log .warn (
178
176
"Can't get market data for %s so not trading with limit order %s"
179
177
% (contract_order .instrument_code , str (contract_order ))
180
178
)
181
179
return missing_data
182
180
181
+ tick_analysis = ticker_object .analyse_for_tick (reference_tick )
182
+
183
183
ticker_object .clear_and_add_reference_as_first_tick (reference_tick )
184
184
185
185
# These prices will be used for limit price purposes
Original file line number Diff line number Diff line change @@ -250,7 +250,7 @@ def analyse_for_tick(
250
250
if tick is arg_not_supplied :
251
251
tick = self .current_tick ()
252
252
253
- if tick is missing_data or qty is arg_not_supplied :
253
+ if qty is arg_not_supplied :
254
254
return missing_data
255
255
256
256
results = analyse_tick (tick , qty , replace_qty_nans = replace_qty_nans )
@@ -261,9 +261,13 @@ def wait_for_valid_bid_and_ask_and_analyse_current_tick(
261
261
self , qty : int = arg_not_supplied , wait_time_seconds : int = 10
262
262
) -> oneTick :
263
263
264
- current_tick = self .wait_for_valid_bid_and_ask_and_return_current_tick (
265
- wait_time_seconds = wait_time_seconds
266
- )
264
+ try :
265
+ current_tick = self .wait_for_valid_bid_and_ask_and_return_current_tick (
266
+ wait_time_seconds = wait_time_seconds
267
+ )
268
+ except missingData :
269
+ return missing_data
270
+
267
271
analysis = self .analyse_for_tick (current_tick , qty = qty )
268
272
269
273
return analysis
@@ -275,7 +279,7 @@ def wait_for_valid_bid_and_ask_and_return_current_tick(
275
279
timer = quickTimer (wait_time_seconds )
276
280
while waiting :
277
281
if timer .finished :
278
- return missing_data
282
+ raise missingData
279
283
self .refresh ()
280
284
last_bid = self .bid ()
281
285
last_ask = self .ask ()
You can’t perform that action at this time.
0 commit comments