@@ -156,9 +156,12 @@ def view_trade_limits(data):
156156def change_limit_for_instrument (data ):
157157 trade_limits = dataTradeLimits (data )
158158 instrument_code = get_valid_instrument_code_from_user (data )
159- period_days = get_input_from_user_and_convert_to_type ("Period of days?" , type_expected = int , allow_default = True ,
160- default_value = 1 )
161- new_limit = get_input_from_user_and_convert_to_type ("Limit (in contracts?)" , type_expected = int , allow_default = False )
159+ period_days = get_input_from_user_and_convert_to_type (
160+ "Period of days?" , type_expected = int , allow_default = True , default_value = 1
161+ )
162+ new_limit = get_input_from_user_and_convert_to_type (
163+ "Limit (in contracts?)" , type_expected = int , allow_default = False
164+ )
162165 ans = input (
163166 "Update will change number of trades allowed in periods, but won't reset 'clock'. Are you sure? (y/other)"
164167 )
@@ -171,8 +174,9 @@ def change_limit_for_instrument(data):
171174def reset_limit_for_instrument (data ):
172175 trade_limits = dataTradeLimits (data )
173176 instrument_code = get_valid_instrument_code_from_user (data )
174- period_days = get_input_from_user_and_convert_to_type ("Period of days?" , type_expected = int , allow_default = True ,
175- default_value = 1 )
177+ period_days = get_input_from_user_and_convert_to_type (
178+ "Period of days?" , type_expected = int , allow_default = True , default_value = 1
179+ )
176180 ans = input ("Reset means trade 'clock' will restart. Are you sure? (y/other)" )
177181 if ans == "y" :
178182 trade_limits .reset_instrument_limit (instrument_code , period_days )
@@ -189,9 +193,12 @@ def change_limit_for_instrument_strategy(data):
189193 trade_limits = dataTradeLimits (data )
190194 instrument_code = get_valid_instrument_code_from_user (data )
191195 strategy_name = get_valid_strategy_name_from_user (data )
192- period_days = get_input_from_user_and_convert_to_type ("Period of days?" , type_expected = int , allow_default = True ,
193- default_value = 1 )
194- new_limit = get_input_from_user_and_convert_to_type ("Limit (in contracts?)" , type_expected = int , allow_default = False )
196+ period_days = get_input_from_user_and_convert_to_type (
197+ "Period of days?" , type_expected = int , allow_default = True , default_value = 1
198+ )
199+ new_limit = get_input_from_user_and_convert_to_type (
200+ "Limit (in contracts?)" , type_expected = int , allow_default = False
201+ )
195202
196203 ans = input (
197204 "Update will change number of trades allowed in periods, but won't reset 'clock'. Are you sure? (y/other)"
@@ -210,8 +217,9 @@ def change_limit_for_instrument_strategy(data):
210217def reset_limit_for_instrument_strategy (data ):
211218 trade_limits = dataTradeLimits (data )
212219 instrument_code = get_valid_instrument_code_from_user (data )
213- period_days = get_input_from_user_and_convert_to_type ("Period of days?" , type_expected = int , allow_default = True ,
214- default_value = 1 )
220+ period_days = get_input_from_user_and_convert_to_type (
221+ "Period of days?" , type_expected = int , allow_default = True , default_value = 1
222+ )
215223 strategy_name = get_valid_strategy_name_from_user (data = data , source = "positions" )
216224
217225 ans = input ("Reset means trade 'clock' will restart. Are you sure? (y/other)" )
@@ -232,10 +240,13 @@ def auto_populate_limits(data: dataBlob):
232240 auto_parameters = get_auto_population_parameters ()
233241
234242 trade_multiplier = get_input_from_user_and_convert_to_type (
235- "Higgest proportion of standard position expected to trade daily?" , type_expected = float ,
236- default_value = MAX_POSITION_TRADED_DAILY )
237- period_days = get_input_from_user_and_convert_to_type ("What period in days to set limit for?" , type_expected = int ,
238- default_value = 1 )
243+ "Higgest proportion of standard position expected to trade daily?" ,
244+ type_expected = float ,
245+ default_value = MAX_POSITION_TRADED_DAILY ,
246+ )
247+ period_days = get_input_from_user_and_convert_to_type (
248+ "What period in days to set limit for?" , type_expected = int , default_value = 1
249+ )
239250 _ = [
240251 set_trade_limit_for_instrument (
241252 data ,
@@ -306,25 +317,36 @@ def calc_trade_limit_for_instrument(
306317
307318def get_auto_population_parameters () -> parametersForAutoPopulation :
308319 print ("Enter parameters to estimate typical position sizes" )
309- notional_risk_target = get_input_from_user_and_convert_to_type ("Notional risk target (% per year, 0.25 = 25%%)" ,
310- type_expected = float ,
311- default_value = RISK_TARGET_ASSUMED / 100.0 )
312- approx_IDM = get_input_from_user_and_convert_to_type ("Approximate IDM" , type_expected = float ,
313- default_value = IDM_ASSUMED )
320+ notional_risk_target = get_input_from_user_and_convert_to_type (
321+ "Notional risk target (% per year, 0.25 = 25%%)" ,
322+ type_expected = float ,
323+ default_value = RISK_TARGET_ASSUMED / 100.0 ,
324+ )
325+ approx_IDM = get_input_from_user_and_convert_to_type (
326+ "Approximate IDM" , type_expected = float , default_value = IDM_ASSUMED
327+ )
314328 notional_instrument_weight = get_input_from_user_and_convert_to_type (
315- "Notional instrument weight (go large for safety!)" , type_expected = float ,
316- default_value = INSTRUMENT_WEIGHT_ASSUMED )
329+ "Notional instrument weight (go large for safety!)" ,
330+ type_expected = float ,
331+ default_value = INSTRUMENT_WEIGHT_ASSUMED ,
332+ )
317333 raw_max_leverage = get_input_from_user_and_convert_to_type (
318- "Maximum Leverage per instrument (notional exposure*# contracts / capital)" , type_expected = float ,
319- default_value = RAW_MAX_LEVERAGE )
334+ "Maximum Leverage per instrument (notional exposure*# contracts / capital)" ,
335+ type_expected = float ,
336+ default_value = RAW_MAX_LEVERAGE ,
337+ )
320338
321339 max_proportion_risk_one_contract = get_input_from_user_and_convert_to_type (
322- "Maximum proportion of risk in a single instrument (0.1 = 10%%)" , type_expected = float ,
323- default_value = MAX_RISK_EXPOSURE_ONE_INSTRUMENT )
340+ "Maximum proportion of risk in a single instrument (0.1 = 10%%)" ,
341+ type_expected = float ,
342+ default_value = MAX_RISK_EXPOSURE_ONE_INSTRUMENT ,
343+ )
324344
325345 max_proportion_of_volume = get_input_from_user_and_convert_to_type (
326- "Maximum proportion of volume for expiry with largest volume (0.1 = 10%)" , type_expected = float ,
327- default_value = MAX_PROPORTION_OF_VOLUME )
346+ "Maximum proportion of volume for expiry with largest volume (0.1 = 10%)" ,
347+ type_expected = float ,
348+ default_value = MAX_PROPORTION_OF_VOLUME ,
349+ )
328350
329351 auto_parameters = parametersForAutoPopulation (
330352 raw_max_leverage = raw_max_leverage ,
@@ -537,9 +559,13 @@ def change_position_limit_for_instrument(data):
537559 view_position_limit (data )
538560 data_position_limits = dataPositionLimits (data )
539561 instrument_code = get_valid_instrument_code_from_user (data , allow_all = False )
540- new_position_limit = get_input_from_user_and_convert_to_type ("New position limit?" , type_expected = int ,
541- allow_default = True , default_value = - 1 ,
542- default_str = "No limit" )
562+ new_position_limit = get_input_from_user_and_convert_to_type (
563+ "New position limit?" ,
564+ type_expected = int ,
565+ allow_default = True ,
566+ default_value = - 1 ,
567+ default_str = "No limit" ,
568+ )
543569 if new_position_limit == - 1 :
544570 data_position_limits .delete_position_limit_for_instrument (instrument_code )
545571 else :
@@ -556,9 +582,13 @@ def change_position_limit_for_instrument_strategy(data):
556582 data , allow_all = False , source = "positions"
557583 )
558584 instrument_code = get_valid_instrument_code_from_user (data , allow_all = False )
559- new_position_limit = get_input_from_user_and_convert_to_type ("New position limit?" , type_expected = int ,
560- allow_default = True , default_value = - 1 ,
561- default_str = "No limit" )
585+ new_position_limit = get_input_from_user_and_convert_to_type (
586+ "New position limit?" ,
587+ type_expected = int ,
588+ allow_default = True ,
589+ default_value = - 1 ,
590+ default_str = "No limit" ,
591+ )
562592
563593 instrument_strategy = instrumentStrategy (
564594 instrument_code = instrument_code , strategy_name = strategy_name
@@ -862,8 +892,11 @@ def get_list_of_changes_to_make_to_slippage(
862892
863893 estimate_to_use_with_mult = get_input_from_user_and_convert_to_type (
864894 "New configured slippage value (current %f, default is estimate %f)"
865- % (configured_estimate_multiplied , suggested_estimate_multiplied ), type_expected = float , allow_default = True ,
866- default_value = suggested_estimate_multiplied )
895+ % (configured_estimate_multiplied , suggested_estimate_multiplied ),
896+ type_expected = float ,
897+ allow_default = True ,
898+ default_value = suggested_estimate_multiplied ,
899+ )
867900
868901 if estimate_to_use_with_mult == configured_estimate_multiplied :
869902 print ("Same as configured, do nothing..." )
@@ -888,8 +921,11 @@ def get_list_of_changes_to_make_to_slippage(
888921
889922def get_filter_size_for_slippage () -> float :
890923 filter = get_input_from_user_and_convert_to_type (
891- "% difference to filter on? (eg 30 means we ignore differences<30%" , type_expected = float , allow_default = True ,
892- default_value = 30.0 )
924+ "% difference to filter on? (eg 30 means we ignore differences<30%" ,
925+ type_expected = float ,
926+ allow_default = True ,
927+ default_value = 30.0 ,
928+ )
893929
894930 return filter
895931
0 commit comments