Closed bug-or-feature closed 10 months ago
Will look at this in January as a bit of a big one
@robcarver17 awesome. there'll be one more PR to remove the unused functions, fix tests, update docs and tidy up
Now I have this error:
File "/home/rob/pysystemtrade/sysdata/parquet/parquet_futures_per_contract_prices.py", line 89, in _write_prices_at_frequency_for_contract_object_no_checking
log = futures_contract_object.log(self.log)
AttributeError: 'futuresContract' object has no attribute 'log'
I'm guessing this is a merge issue between droparctic and develop. But what is the correct way of rewriting this in new log world:
log = futures_contract_object.log(self.log)
I haven't been following closely enough clearly, but did you drop the new_log = object.log(existing_log) pattern?
I just created a new PR for the final tidy up, I'll fix that issue in there
OK I've hotfixed it but not sure if it's the correct way of doing it.
I've pushed a fix
Thanks mate
This PR refactors away the last few usages of
log.setup()
. This one handles the more complex cases, where logger instances were passed around as function parameters. The solution in most cases is to refactor existing functions into class methods, where thelogger
instance can be accessed as a class variable instead. The changes fall into three groups:Uses of log.setup() and specific_log() in FX and price code
_delete_fx_prices_without_any_warning_be_careful()
, and_add_fx_prices_without_checking_for_existing_entry()
from classparquetFxPricesData
refactor away uses oflog.setup()
using temporary log attributesbroker_get_historical_futures_data_for_contract()
of classibPriceClient
sets log attributes before getting price updates, and clears afterwardbroker_get_daily_fx_data()
of classibFxClient
sets log attributes before getting FX updates, and clears afterwardUses of log_with_attributes() in the algo code
manage_live_trade()
of classalgoMarket
is refactored to uselog_attributes()
instead oflog_with_attributes()
file_log_report_market_order()
fromsysexecution.algos.common_functions.py
instead becomes a method of algo parent classAlgo
set_limit_price()
fromsysexecution.algos.common_functions.py
becomesset_best_limit_price()
class method of classalgoOriginalBest
, because parent classAlgo
already has a methodset_limit_price()
with a different method signature.algoOriginalBest
the following top level functions are converted to class methods:limit_trade_viable()
file_log_report()
file_log_report_limit_order()
reason_to_switch_to_aggressive()
is_market_about_to_close()
required_to_switch_to_aggressive()
adverse_size_issue()
_is_imbalance_ratio_exceeded()
_is_insufficient_size_on_our_preferred_side()
set_aggressive_limit_price()
so that they can access the parent class variabledata
, meaning they no longer need to be passed a logger instanceadverse_size_issue()
,_is_imbalance_ratio_exceeded()
, and_is_insufficient_size_on_our_preferred_side()
have a new parameterorder
so that the order attributes can be logged correctlybroker_order_with_controls_and_order_id
of methodmanage_live_trade()
is renamedorder_control
for brevitylimit_trade_viable()
,reason_to_switch_to_aggressive()
,is_market_about_to_close()
andset_aggressive_limit_price()
no longer need adata_broker
parameter; they can access the parent instance.Uses of log_with_attributes() in the order and stack handler code
log_with_attributes()
is removed from classesinstrumentOrder
,contractOrder
,brokerOrder
and parentOrder
calculate_adjusted_order_given_existing_orders()
becomes a class method ofinstrumentOrderStackData
so that it no longer needs to be passed a logger instanceapply_broker_order_fills_to_database()
of classstackHandlerForFills
refactored to use temp log attributessysexecution.stack_handler.stackHandlerCore.py
, the following top level functions are converted to class methods ofstackHandlerCore
:put_children_on_stack()
add_children_to_parent_or_rollback_children()
spawn_children_from_instrument_order()
log_successful_adding()
rollback_parents_and_children_and_handle_exceptions()
so that they can access the parent class variablelog
rollback_parents_and_children_and_handle_exceptions()
is passed the parent order object instead of the parent order ID, so that the parent log attributes can be accessed (as well as the parent ID)sysexecution.stack_handler.spawn_children_from_instrument_orders.py
the following top level functions are converted to class methods of classstackHandlerForSpawning
:spawn_children_from_instrument_order()
function_to_process_instrument()
single_instrument_child_orders()
adjust_limit_orders_with_correct_prices()
get_required_contract_trade_for_instrument()
child_order_in_priced_contract_only()
so that they can access the parent class variablesdata
andlog
put_children_on_stack()
no longer needs to be passed parameterparent_log
, the log attributes can be accessed from the parent order object, which is also passedadd_children_to_parent_or_rollback_children()
andlog_successful_adding()
function_to_process_instrument()
would need to be refactored in future if spread orders were implemented; this has not been done for now to ease merge comparisonadd_instrument_and_list_of_contract_orders_to_stack()
from classstackHandlerForRolls
is refactored to use temporary log attributes, and to use the new methodsput_children_on_stack()
,log_successful_adding()
, androllback_parents_and_children_and_handle_exceptions()