From 02c4cbcc50a7752fd18bff66bb5fb5822fe1293f Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Fri, 9 Jun 2023 12:24:52 +0100 Subject: [PATCH 1/5] log.msg() -> log.debug() --- sysbrokers/IB/client/ib_client.py | 2 +- sysbrokers/IB/client/ib_price_client.py | 2 +- sysbrokers/IB/ib_Fx_prices_data.py | 2 +- sysbrokers/IB/ib_connection.py | 2 +- sysbrokers/IB/ib_futures_contracts_data.py | 12 ++--- sysbrokers/IB/ib_orders.py | 6 +-- syscontrol/report_process_status.py | 4 +- syscontrol/run_process.py | 10 ++-- syscontrol/timer_functions.py | 6 +-- sysdata/arctic/arctic_adjusted_prices.py | 4 +- .../arctic_futures_per_contract_prices.py | 4 +- sysdata/arctic/arctic_multiple_prices.py | 4 +- sysdata/arctic/arctic_spotfx_prices.py | 4 +- sysdata/arctic/arctic_spreads.py | 4 +- sysdata/config/configdata.py | 2 +- sysdata/csv/csv_multiple_prices.py | 2 +- sysdata/csv/csv_roll_calendars.py | 2 +- sysdata/csv/csv_spot_fx.py | 2 +- .../futures/futures_per_contract_prices.py | 10 ++-- sysdata/futures/instruments.py | 2 +- sysdata/futures/roll_calendars.py | 2 +- sysdata/fx/spotfx.py | 6 +-- sysdata/mongodb/mongo_IB_client_id.py | 4 +- sysdata/tools/cleaner.py | 6 +-- sysexecution/algos/algo.py | 4 +- sysexecution/algos/algo_limit_orders.py | 2 +- sysexecution/algos/algo_market.py | 10 ++-- sysexecution/algos/algo_original_best.py | 22 ++++---- sysexecution/algos/allocate_algo_to_order.py | 6 +-- sysexecution/algos/common_functions.py | 8 +-- .../order_stacks/instrument_order_stack.py | 6 +-- sysexecution/order_stacks/order_stack.py | 2 +- sysexecution/stack_handler/balance_trades.py | 14 ++--- .../stack_handler/cancel_and_modify.py | 6 +-- sysexecution/stack_handler/checks.py | 4 +- ...eate_broker_orders_from_contract_orders.py | 8 +-- sysexecution/stack_handler/roll_orders.py | 2 +- .../spawn_children_from_instrument_orders.py | 18 +++---- .../stack_handler/stackHandlerCore.py | 2 +- sysexecution/stack_handler/stack_handler.py | 8 +-- .../strategies/classic_buffered_positions.py | 2 +- .../strategies/dynamic_optimised_positions.py | 18 +++---- .../strategies/strategy_order_handling.py | 8 +-- sysinit/futures/seed_price_data_from_IB.py | 6 +-- syslogging/adapter.py | 8 --- syslogging/tests/logging_tests.py | 7 --- sysproduction/backup_arctic_to_csv.py | 52 +++++++++---------- sysproduction/backup_mongo_data_as_dump.py | 10 ++-- sysproduction/backup_state_files.py | 4 +- .../clean_truncate_backtest_states.py | 2 +- sysproduction/clean_truncate_echo_files.py | 4 +- sysproduction/clean_truncate_log_files.py | 2 +- sysproduction/data/backtest.py | 4 +- sysproduction/data/contracts.py | 2 +- sysproduction/data/controls.py | 4 +- sysproduction/data/instruments.py | 2 +- sysproduction/data/positions.py | 6 +-- .../interactive_update_roll_status.py | 4 +- .../reporting/reporting_functions.py | 4 +- .../run_dynamic_optimised_system.py | 2 +- .../strategy_code/run_system_classic.py | 4 +- sysproduction/update_fx_prices.py | 2 +- sysproduction/update_historical_prices.py | 12 ++--- sysproduction/update_sampled_contracts.py | 12 ++--- sysproduction/update_strategy_capital.py | 4 +- sysproduction/update_total_capital.py | 8 +-- sysquant/optimisation/pre_processing.py | 12 ++--- .../accounts/account_buffering_subsystem.py | 2 +- systems/accounts/account_buffering_system.py | 2 +- systems/accounts/account_forecast.py | 2 +- systems/accounts/account_instruments.py | 4 +- systems/accounts/account_subsystem.py | 2 +- systems/accounts/account_with_multiplier.py | 2 +- systems/basesystem.py | 14 ++--- systems/buffering.py | 8 +-- systems/forecast_combine.py | 18 +++---- systems/forecast_scale_cap.py | 4 +- systems/forecasting.py | 2 +- systems/portfolio.py | 14 ++--- systems/positionsizing.py | 10 ++-- .../accounts_stage.py | 2 +- .../optimisation.py | 8 +-- .../optimised_positions_stage.py | 4 +- .../provided/rob_system/forecastScaleCap.py | 2 +- systems/rawdata.py | 10 ++-- 85 files changed, 263 insertions(+), 278 deletions(-) diff --git a/sysbrokers/IB/client/ib_client.py b/sysbrokers/IB/client/ib_client.py index e065020489..b7d8ee3ad3 100644 --- a/sysbrokers/IB/client/ib_client.py +++ b/sysbrokers/IB/client/ib_client.py @@ -136,7 +136,7 @@ def broker_error(self, msg, log, myerror_type): log.warn(msg) def broker_message(self, log, msg): - log.msg(msg) + log.debug(msg) def refresh(self): self.ib.sleep(0.00001) diff --git a/sysbrokers/IB/client/ib_price_client.py b/sysbrokers/IB/client/ib_price_client.py index 82e35006b2..7123061015 100644 --- a/sysbrokers/IB/client/ib_price_client.py +++ b/sysbrokers/IB/client/ib_price_client.py @@ -329,7 +329,7 @@ def _avoid_pacing_violation( printed_warning_already = False while _pause_for_pacing(last_call_datetime): if not printed_warning_already: - log.msg( + log.debug( "Pausing %f seconds to avoid pacing violation" % ( last_call_datetime diff --git a/sysbrokers/IB/ib_Fx_prices_data.py b/sysbrokers/IB/ib_Fx_prices_data.py index 2b8860f8c9..36dcf1e21b 100644 --- a/sysbrokers/IB/ib_Fx_prices_data.py +++ b/sysbrokers/IB/ib_Fx_prices_data.py @@ -78,7 +78,7 @@ def _get_fx_prices_with_ib_config( # turn into a fxPrices fx_prices = fxPrices(raw_fx_prices) - log.msg("Downloaded %d prices" % len(fx_prices)) + log.debug("Downloaded %d prices" % len(fx_prices)) return fx_prices diff --git a/sysbrokers/IB/ib_connection.py b/sysbrokers/IB/ib_connection.py index c2e5cb0bae..b9f9a35eff 100644 --- a/sysbrokers/IB/ib_connection.py +++ b/sysbrokers/IB/ib_connection.py @@ -106,7 +106,7 @@ def account(self): return self._account def close_connection(self): - self.log.msg("Terminating %s" % str(self._ib_connection_config)) + self.log.debug("Terminating %s" % str(self._ib_connection_config)) try: # Try and disconnect IB client self.ib.disconnect() diff --git a/sysbrokers/IB/ib_futures_contracts_data.py b/sysbrokers/IB/ib_futures_contracts_data.py index 7f4e64b925..f3c264f2d8 100644 --- a/sysbrokers/IB/ib_futures_contracts_data.py +++ b/sysbrokers/IB/ib_futures_contracts_data.py @@ -164,7 +164,7 @@ def get_min_tick_size_for_contract(self, contract_object: futuresContract) -> fl contract_object ) except missingContract: - new_log.msg("Can't resolve contract so can't find tick size") + new_log.debug("Can't resolve contract so can't find tick size") raise try: @@ -172,7 +172,7 @@ def get_min_tick_size_for_contract(self, contract_object: futuresContract) -> fl contract_object_with_ib_data ) except missingContract: - new_log.msg("No tick size found") + new_log.debug("No tick size found") raise return min_tick_size @@ -186,7 +186,7 @@ def get_price_magnifier_for_contract( contract_object ) except missingContract: - new_log.msg("Can't resolve contract so can't find tick size") + new_log.debug("Can't resolve contract so can't find tick size") raise try: @@ -194,7 +194,7 @@ def get_price_magnifier_for_contract( contract_object_with_ib_data ) except missingContract: - new_log.msg("No contract found") + new_log.debug("No contract found") raise return price_magnifier @@ -214,7 +214,7 @@ def get_trading_hours_for_contract( futures_contract ) except missingContract: - new_log.msg("Can't resolve contract") + new_log.debug("Can't resolve contract") raise missingContract try: @@ -222,7 +222,7 @@ def get_trading_hours_for_contract( contract_object_with_ib_data ) except missingData: - new_log.msg("No trading hours found") + new_log.debug("No trading hours found") trading_hours = listOfTradingHours([]) return trading_hours diff --git a/sysbrokers/IB/ib_orders.py b/sysbrokers/IB/ib_orders.py index 884c8fdce2..626d2ba7bb 100644 --- a/sysbrokers/IB/ib_orders.py +++ b/sysbrokers/IB/ib_orders.py @@ -297,7 +297,7 @@ def _send_broker_order_to_IB(self, broker_order: brokerOrder) -> tradeWithContra """ log = broker_order.log_with_attributes(self.log) - log.msg("Going to submit order %s to IB" % str(broker_order)) + log.debug("Going to submit order %s to IB" % str(broker_order)) trade_list = broker_order.trade order_type = broker_order.order_type @@ -320,7 +320,7 @@ def _send_broker_order_to_IB(self, broker_order: brokerOrder) -> tradeWithContra log.warn("Couldn't submit order") return missing_order - log.msg("Order submitted to IB") + log.debug("Order submitted to IB") return placed_broker_trade_object @@ -385,7 +385,7 @@ def cancel_order_on_stack(self, broker_order: brokerOrder): return None self.cancel_order_given_control_object(matched_control_order) - log.msg("Sent cancellation for %s" % str(broker_order)) + log.debug("Sent cancellation for %s" % str(broker_order)) def cancel_order_given_control_object( self, broker_orders_with_controls: ibOrderWithControls diff --git a/syscontrol/report_process_status.py b/syscontrol/report_process_status.py index f71c523458..f89afde6d8 100644 --- a/syscontrol/report_process_status.py +++ b/syscontrol/report_process_status.py @@ -68,7 +68,7 @@ def _minutes_elapsed_since_log(self, log_time: datetime.datetime) -> float: return elapsed_minutes def _log_and_mark_timing(self, status: str): - self.log.msg(status) + self.log.debug(status) self._mark_timing_of_log(status) def _mark_timing_of_log(self, status): @@ -91,7 +91,7 @@ def _get_all_keys_in_store(self) -> list: return all_keys def _log_clear_and_mark(self, status: str): - self.log.msg("No longer- %s" % status) + self.log.debug("No longer- %s" % status) self._mark_log_of_clear(status) def _mark_log_of_clear(self, status): diff --git a/syscontrol/run_process.py b/syscontrol/run_process.py index e72512e12a..8dfe5fd105 100644 --- a/syscontrol/run_process.py +++ b/syscontrol/run_process.py @@ -153,7 +153,7 @@ def _finish_control_process(self): % self.process_name ) elif result_of_finish is success: - self.log.msg("Process control %s marked close" % self.process_name) + self.log.debug("Process control %s marked close" % self.process_name) ### STARTUP CODE @@ -334,7 +334,7 @@ def wait_for_next_method_run_time(process_to_run: processToRun): "Sleeping for %d seconds as %d seconds until next method ready to run (will react to STOP or PAUSE at that point)" % (sleep_time, seconds_to_next_run) ) - process_to_run.log.msg(msg) + process_to_run.log.debug(msg) sys.stdout.flush() time.sleep(seconds_to_next_run) @@ -377,13 +377,13 @@ def _check_for_stop(process_to_run: processToRun) -> bool: log = process_to_run.log if process_requires_stop: - log.msg("Process control marked as STOP") + log.debug("Process control marked as STOP") if all_methods_finished: - log.msg("Finished doing all executions of provided methods") + log.debug("Finished doing all executions of provided methods") if time_to_stop: - log.msg("Passed finish time of process") + log.debug("Passed finish time of process") if process_requires_stop or all_methods_finished or time_to_stop: return True diff --git a/syscontrol/timer_functions.py b/syscontrol/timer_functions.py index 2b57bc5a37..da7c68f5a7 100644 --- a/syscontrol/timer_functions.py +++ b/syscontrol/timer_functions.py @@ -39,7 +39,7 @@ def _log_on_startup(self): log = self.log method_name = self.method_name if self.run_on_completion_only: - log.msg("%s will run once only on process completion" % method_name) + log.debug("%s will run once only on process completion" % method_name) return None max_executions = self.max_executions @@ -49,7 +49,7 @@ def _log_on_startup(self): else: exec_string = "at most %d times" % max_executions - log.msg( + log.debug( "%s will run every %d minutes %s with heartbeats every %d minutes" % ( method_name, @@ -108,7 +108,7 @@ def report_status(self) -> reportStatus: return self._report_status def log_msg(self, msg: str): - self.log.msg(msg, type=self.process_name) + self.log.debug(msg, type=self.process_name) def check_and_run(self, last_run: bool = False, **kwargs): """ diff --git a/sysdata/arctic/arctic_adjusted_prices.py b/sysdata/arctic/arctic_adjusted_prices.py index 2ce44cffe3..0ee3272377 100644 --- a/sysdata/arctic/arctic_adjusted_prices.py +++ b/sysdata/arctic/arctic_adjusted_prices.py @@ -43,7 +43,7 @@ def _delete_adjusted_prices_without_any_warning_be_careful( self, instrument_code: str ): self.arctic.delete(instrument_code) - self.log.msg( + self.log.debug( "Deleted adjusted prices for %s from %s" % (instrument_code, str(self)), instrument_code=instrument_code, ) @@ -55,7 +55,7 @@ def _add_adjusted_prices_without_checking_for_existing_entry( adjusted_price_data_aspd.columns = ["price"] adjusted_price_data_aspd = adjusted_price_data_aspd.astype(float) self.arctic.write(instrument_code, adjusted_price_data_aspd) - self.log.msg( + self.log.debug( "Wrote %s lines of prices for %s to %s" % (len(adjusted_price_data), instrument_code, str(self)), instrument_code=instrument_code, diff --git a/sysdata/arctic/arctic_futures_per_contract_prices.py b/sysdata/arctic/arctic_futures_per_contract_prices.py index fcfb353618..741c9c0ec0 100644 --- a/sysdata/arctic/arctic_futures_per_contract_prices.py +++ b/sysdata/arctic/arctic_futures_per_contract_prices.py @@ -104,7 +104,7 @@ def _write_prices_at_frequency_for_contract_object_no_checking( self.arctic_connection.write(ident, futures_price_data_as_pd) - log.msg( + log.debug( "Wrote %s lines of prices for %s at %s to %s" % ( len(futures_price_data), @@ -198,7 +198,7 @@ def _delete_prices_at_frequency_for_contract_object_with_no_checks_be_careful( contract=futures_contract_object, frequency=frequency ) self.arctic_connection.delete(ident) - log.msg( + log.debug( "Deleted all prices for %s from %s" % (futures_contract_object.key, str(self)) ) diff --git a/sysdata/arctic/arctic_multiple_prices.py b/sysdata/arctic/arctic_multiple_prices.py index 9a62dd2be2..5c113ce8bc 100644 --- a/sysdata/arctic/arctic_multiple_prices.py +++ b/sysdata/arctic/arctic_multiple_prices.py @@ -52,7 +52,7 @@ def _delete_multiple_prices_without_any_warning_be_careful( ): self.arctic.delete(instrument_code) - self.log.msg( + self.log.debug( "Deleted multiple prices for %s from %s" % (instrument_code, str(self)) ) @@ -64,7 +64,7 @@ def _add_multiple_prices_without_checking_for_existing_entry( multiple_price_data_aspd = _change_contracts_to_str(multiple_price_data_aspd) self.arctic.write(instrument_code, multiple_price_data_aspd) - self.log.msg( + self.log.debug( "Wrote %s lines of prices for %s to %s" % (len(multiple_price_data_aspd), instrument_code, str(self)), instrument_code=instrument_code, diff --git a/sysdata/arctic/arctic_spotfx_prices.py b/sysdata/arctic/arctic_spotfx_prices.py index a556738d1b..76e3b57ce2 100644 --- a/sysdata/arctic/arctic_spotfx_prices.py +++ b/sysdata/arctic/arctic_spotfx_prices.py @@ -38,7 +38,7 @@ def _get_fx_prices_without_checking(self, currency_code: str) -> fxPrices: def _delete_fx_prices_without_any_warning_be_careful(self, currency_code: str): log = self.log.setup(**{CURRENCY_CODE_LOG_LABEL: currency_code}) self.arctic.delete(currency_code) - log.msg("Deleted fX prices for %s from %s" % (currency_code, str(self))) + log.debug("Deleted fX prices for %s from %s" % (currency_code, str(self))) def _add_fx_prices_without_checking_for_existing_entry( self, currency_code: str, fx_price_data: fxPrices @@ -50,7 +50,7 @@ def _add_fx_prices_without_checking_for_existing_entry( fx_price_data_aspd = fx_price_data_aspd.astype(float) self.arctic.write(currency_code, fx_price_data_aspd) - log.msg( + log.debug( "Wrote %s lines of prices for %s to %s" % (len(fx_price_data), currency_code, str(self)) ) diff --git a/sysdata/arctic/arctic_spreads.py b/sysdata/arctic/arctic_spreads.py index fef207da17..11d083e9aa 100644 --- a/sysdata/arctic/arctic_spreads.py +++ b/sysdata/arctic/arctic_spreads.py @@ -36,7 +36,7 @@ def _get_spreads_without_checking( def _delete_spreads_without_any_warning_be_careful(self, instrument_code: str): self.arctic.delete(instrument_code) - self.log.msg( + self.log.debug( "Deleted spreads for %s from %s" % (instrument_code, str(self)), instrument_code=instrument_code, ) @@ -48,7 +48,7 @@ def _add_spreads_without_checking_for_existing_entry( spreads_as_pd.columns = [SPREAD_COLUMN_NAME] spreads_as_pd = spreads_as_pd.astype(float) self.arctic.write(instrument_code, spreads_as_pd) - self.log.msg( + self.log.debug( "Wrote %s lines of spreads for %s to %s" % (len(spreads_as_pd), instrument_code, str(self)), instrument_code=instrument_code, diff --git a/sysdata/config/configdata.py b/sysdata/config/configdata.py index 412166428c..cd4f2ff0c8 100644 --- a/sysdata/config/configdata.py +++ b/sysdata/config/configdata.py @@ -229,7 +229,7 @@ def fill_with_defaults(self): """ Fills with defaults - private stuff first, then defaults """ - self.log.msg("Adding config defaults") + self.log.debug("Adding config defaults") self_as_dict = self.as_dict() defaults_dict = self.default_config_dict diff --git a/sysdata/csv/csv_multiple_prices.py b/sysdata/csv/csv_multiple_prices.py index cc75ac1807..3eb14443da 100644 --- a/sysdata/csv/csv_multiple_prices.py +++ b/sysdata/csv/csv_multiple_prices.py @@ -73,7 +73,7 @@ def _add_multiple_prices_without_checking_for_existing_entry( filename = self._filename_given_instrument_code(instrument_code) multiple_price_data.to_csv(filename, index_label=DATE_INDEX_NAME) - self.log.msg( + self.log.debug( "Written multiple prices for %s to %s" % (instrument_code, filename), instrument_code=instrument_code, ) diff --git a/sysdata/csv/csv_roll_calendars.py b/sysdata/csv/csv_roll_calendars.py index 1c75249ff1..7dc07708e9 100644 --- a/sysdata/csv/csv_roll_calendars.py +++ b/sysdata/csv/csv_roll_calendars.py @@ -67,7 +67,7 @@ def _add_roll_calendar_without_checking_for_existing_entry( ): filename = self._filename_given_instrument_code(instrument_code) roll_calendar.to_csv(filename, index_label=DATE_INDEX_NAME) - self.log.msg("Wrote calendar for %s to %s" % (instrument_code, str(filename))) + self.log.debug("Wrote calendar for %s to %s" % (instrument_code, str(filename))) def _filename_given_instrument_code(self, instrument_code: str): return resolve_path_and_filename_for_package( diff --git a/sysdata/csv/csv_spot_fx.py b/sysdata/csv/csv_spot_fx.py index 0ed58a2a3b..57ec69195b 100644 --- a/sysdata/csv/csv_spot_fx.py +++ b/sysdata/csv/csv_spot_fx.py @@ -115,7 +115,7 @@ def _add_fx_prices_without_checking_for_existing_entry( filename, index_label=date_column, date_format=date_format, header=True ) - self.log.msg( + self.log.debug( "Wrote currency prices to %s for %s" % (filename, code), **{CURRENCY_CODE_LOG_LABEL: code}, ) diff --git a/sysdata/futures/futures_per_contract_prices.py b/sysdata/futures/futures_per_contract_prices.py index cf0c19deee..2d35b1e2c2 100644 --- a/sysdata/futures/futures_per_contract_prices.py +++ b/sysdata/futures/futures_per_contract_prices.py @@ -356,7 +356,7 @@ def update_prices_at_frequency_for_contract( new_log = contract_object.log(self.log) if len(new_futures_per_contract_prices) == 0: - new_log.msg("No new data") + new_log.debug("No new data") return 0 if frequency is MIXED_FREQ: @@ -373,7 +373,7 @@ def update_prices_at_frequency_for_contract( ) if merged_prices is SPIKE_IN_DATA: - new_log.msg( + new_log.debug( "Price has moved too much - will need to manually check - no price update done" ) return SPIKE_IN_DATA @@ -387,10 +387,10 @@ def update_prices_at_frequency_for_contract( elif rows_added == 0: if len(old_prices) == 0: - new_log.msg("No existing or additional data") + new_log.debug("No existing or additional data") return 0 else: - new_log.msg("No additional data since %s " % str(old_prices.index[-1])) + new_log.debug("No additional data since %s " % str(old_prices.index[-1])) return 0 # We have guaranteed no duplication @@ -406,7 +406,7 @@ def update_prices_at_frequency_for_contract( ignore_duplication=True, ) - new_log.msg("Added %d additional rows of data" % rows_added) + new_log.debug("Added %d additional rows of data" % rows_added) return rows_added diff --git a/sysdata/futures/instruments.py b/sysdata/futures/instruments.py index e4f0b1687d..d69fd04934 100644 --- a/sysdata/futures/instruments.py +++ b/sysdata/futures/instruments.py @@ -50,7 +50,7 @@ def update_meta_data(self, instrument_code: str, meta_name: str, new_value): ) setattr(existing_meta_data, meta_name, new_value) self.add_instrument_data(instrument_object, ignore_duplication=True) - self.log.msg( + self.log.debug( "Updated %s for %s from %s to %s" % (meta_name, instrument_code, existing_meta_data_value, new_value) ) diff --git a/sysdata/futures/roll_calendars.py b/sysdata/futures/roll_calendars.py index f92e7c95f4..f6f3c090f3 100644 --- a/sysdata/futures/roll_calendars.py +++ b/sysdata/futures/roll_calendars.py @@ -75,7 +75,7 @@ def add_roll_calendar( instrument_code, roll_calendar ) - self.log.msg("Added roll calendar for instrument %s" % instrument_code) + self.log.debug("Added roll calendar for instrument %s" % instrument_code) def is_code_in_data(self, instrument_code: str) -> bool: if instrument_code in self.get_list_of_instruments(): diff --git a/sysdata/fx/spotfx.py b/sysdata/fx/spotfx.py index cf5c263740..2d5e44e650 100644 --- a/sysdata/fx/spotfx.py +++ b/sysdata/fx/spotfx.py @@ -199,10 +199,10 @@ def update_fx_prices( if rows_added == 0: if len(old_fx_prices) == 0: - log.msg("No new or old prices for %s" % code) + log.debug("No new or old prices for %s" % code) else: - log.msg( + log.debug( "No additional data since %s for %s" % (str(old_fx_prices.index[-1]), code) ) @@ -210,7 +210,7 @@ def update_fx_prices( self.add_fx_prices(code, merged_fx_prices, ignore_duplication=True) - log.msg("Added %d additional rows for %s" % (rows_added, code)) + log.debug("Added %d additional rows for %s" % (rows_added, code)) return rows_added diff --git a/sysdata/mongodb/mongo_IB_client_id.py b/sysdata/mongodb/mongo_IB_client_id.py index 6402fe6649..55313d4c4b 100644 --- a/sysdata/mongodb/mongo_IB_client_id.py +++ b/sysdata/mongodb/mongo_IB_client_id.py @@ -36,7 +36,7 @@ def _get_list_of_clientids(self) -> list: def _lock_clientid(self, next_id: int): self.mongo_data.add_data(next_id, {}) - self.log.msg("Locked IB client ID %d" % next_id) + self.log.debug("Locked IB client ID %d" % next_id) def release_clientid(self, clientid: int): """ @@ -45,4 +45,4 @@ def release_clientid(self, clientid: int): :return: None """ self.mongo_data.delete_data_without_any_warning(clientid) - self.log.msg("Released IB client ID %d" % clientid) + self.log.debug("Released IB client ID %d" % clientid) diff --git a/sysdata/tools/cleaner.py b/sysdata/tools/cleaner.py index e5efc4c292..917377811b 100644 --- a/sysdata/tools/cleaner.py +++ b/sysdata/tools/cleaner.py @@ -46,7 +46,7 @@ def apply_price_cleaning( broker_prices = broker_prices.remove_future_data() new_price_length = len(broker_prices) if new_price_length < price_length: - log.msg( + log.debug( "Ignoring %d prices with future timestamps" % (price_length - new_price_length) ) @@ -65,7 +65,7 @@ def apply_price_cleaning( broker_prices = broker_prices.remove_zero_volumes() new_price_length = len(broker_prices) if new_price_length < price_length: - log.msg( + log.debug( "Ignoring %d prices with zero volumes" % (price_length - new_price_length) ) @@ -75,7 +75,7 @@ def apply_price_cleaning( broker_prices = broker_prices.remove_zero_prices() new_price_length = len(broker_prices) if new_price_length < price_length: - log.msg( + log.debug( "Ignoring %d prices with zero prices" % (price_length - new_price_length) ) diff --git a/sysexecution/algos/algo.py b/sysexecution/algos/algo.py index d4298db1b9..c1374db4d0 100644 --- a/sysexecution/algos/algo.py +++ b/sysexecution/algos/algo.py @@ -134,7 +134,7 @@ def get_and_submit_broker_order_for_contract_order( limit_price=limit_price, ) - log.msg( + log.debug( "Created a broker order %s (not yet submitted or written to local DB)" % str(broker_order) ) @@ -148,7 +148,7 @@ def get_and_submit_broker_order_for_contract_order( return missing_order log = placed_broker_order_with_controls.order.log_with_attributes(log) - log.msg( + log.debug( "Submitted order to IB %s" % str(placed_broker_order_with_controls.order) ) diff --git a/sysexecution/algos/algo_limit_orders.py b/sysexecution/algos/algo_limit_orders.py index be1c587fc0..7650d0a331 100644 --- a/sysexecution/algos/algo_limit_orders.py +++ b/sysexecution/algos/algo_limit_orders.py @@ -29,7 +29,7 @@ def blocking_algo_requires_management(self) -> bool: def submit_trade(self) -> orderWithControls: contract_order = self.contract_order - self.data.log.msg( + self.data.log.debug( "Submitting limit order for %s, limit price %f" % (str(contract_order), contract_order.limit_price) ) diff --git a/sysexecution/algos/algo_market.py b/sysexecution/algos/algo_market.py index 5cc3edb5df..ab7ef33225 100644 --- a/sysexecution/algos/algo_market.py +++ b/sysexecution/algos/algo_market.py @@ -51,7 +51,7 @@ def prepare_and_submit_trade(self): log = contract_order.log_with_attributes(self.data.log) if contract_order.panic_order: - log.msg("PANIC ORDER! DON'T RESIZE AND DO ENTIRE TRADE") + log.debug("PANIC ORDER! DON'T RESIZE AND DO ENTIRE TRADE") cut_down_contract_order = copy(contract_order) else: cut_down_contract_order = contract_order.reduce_trade_size_proportionally_so_smallest_leg_is_max_size( @@ -59,7 +59,7 @@ def prepare_and_submit_trade(self): ) if cut_down_contract_order.trade != contract_order.trade: - log.msg( + log.debug( "Cut down order to size %s from %s because of algo size limit" % (str(contract_order.trade), str(cut_down_contract_order.trade)) ) @@ -79,7 +79,7 @@ def manage_live_trade( data_broker = self.data_broker trade_open = True - log.msg( + log.debug( "Managing trade %s with market order" % str(broker_order_with_controls.order) ) @@ -100,11 +100,11 @@ def manage_live_trade( ) ) if is_order_completed: - log.msg("Trade completed") + log.debug("Trade completed") break if is_order_timeout: - log.msg("Run out of time to execute: cancelling") + log.debug("Run out of time to execute: cancelling") broker_order_with_controls = cancel_order( self.data, broker_order_with_controls ) diff --git a/sysexecution/algos/algo_original_best.py b/sysexecution/algos/algo_original_best.py index 4b4d1e1184..ab78f3f347 100644 --- a/sysexecution/algos/algo_original_best.py +++ b/sysexecution/algos/algo_original_best.py @@ -101,7 +101,7 @@ def prepare_and_submit_trade(self) -> orderWithControls: ) ) if cut_down_contract_order.trade != contract_order.trade: - log.msg( + log.debug( "Cut down order to size %s from %s because of algo size limit" % (str(contract_order.trade), str(cut_down_contract_order.trade)) ) @@ -133,7 +133,7 @@ def prepare_and_submit_trade(self) -> orderWithControls: ) else: # do a market order - log.msg("Conditions are wrong so doing market trade instead of limit trade") + log.debug("Conditions are wrong so doing market trade instead of limit trade") broker_order_with_controls = ( self.get_and_submit_broker_order_for_contract_order( cut_down_contract_order, order_type=market_order_type @@ -154,7 +154,7 @@ def manage_live_trade( trade_open = True is_aggressive = False - log.msg( + log.debug( "Managing trade %s with algo 'original-best'" % str(broker_order_with_controls_and_order_id.order) ) @@ -187,7 +187,7 @@ def manage_live_trade( need_to_switch = required_to_switch_to_aggressive(reason_to_switch) if need_to_switch: - log.msg("Switch to aggressive because %s" % reason_to_switch) + log.debug("Switch to aggressive because %s" % reason_to_switch) is_aggressive = True else: # market trade nothing to do @@ -195,7 +195,7 @@ def manage_live_trade( order_completed = broker_order_with_controls_and_order_id.completed() if order_completed: - log.msg("Trade completed") + log.debug("Trade completed") break order_timeout = ( @@ -203,7 +203,7 @@ def manage_live_trade( > TOTAL_TIME_OUT ) if order_timeout: - log.msg("Run out of time: cancelling") + log.debug("Run out of time: cancelling") broker_order_with_controls_and_order_id = cancel_order( data, broker_order_with_controls_and_order_id ) @@ -230,13 +230,13 @@ def limit_trade_viable( ) if raise_adverse_size_issue: - log.msg("Limit trade not viable") + log.debug("Limit trade not viable") return False # or if not enough time left if is_market_about_to_close(data, order=order, log=log): - log.msg( + log.debug( "Market about to close or stack handler nearly close - doing market order" ) return False @@ -279,7 +279,7 @@ def file_log_report_limit_order( current_tick, ) - log.msg(log_report) + log.debug(log_report) def reason_to_switch_to_aggressive( @@ -380,7 +380,7 @@ def _is_imbalance_ratio_exceeded( latest_imbalance_ratio_exceeded = latest_imbalance_ratio > IMBALANCE_THRESHOLD if latest_imbalance_ratio_exceeded: - log.msg( + log.debug( "Imbalance ratio for ticker %s %f exceeds threshold %f" % (str(current_tick_analysis), latest_imbalance_ratio, IMBALANCE_THRESHOLD) ) @@ -400,7 +400,7 @@ def _is_insufficient_size_on_our_preferred_side( ) if insufficient_size_on_our_preferred_side: - log.msg( + log.debug( "On ticker %s we require size of %f (our trade %f * adjustment %f) for a limit order but only %f available" % ( str(current_tick_analysis), diff --git a/sysexecution/algos/allocate_algo_to_order.py b/sysexecution/algos/allocate_algo_to_order.py index 9ebb3d82d2..95a4c01e70 100644 --- a/sysexecution/algos/allocate_algo_to_order.py +++ b/sysexecution/algos/allocate_algo_to_order.py @@ -75,7 +75,7 @@ def check_and_if_required_allocate_algo_to_single_contract_order( is_roll_order = instrument_order.roll_order if instrument_order_type == market_order_type: - log.msg("Market order type, so allocating to algo_market") + log.debug("Market order type, so allocating to algo_market") contract_order.algo_to_use = MARKET_ALGO elif ( @@ -108,7 +108,7 @@ def allocate_for_best_execution_no_limit( # in the future could be randomized... log = contract_order.log_with_attributes(data.log) - log.msg("'Best' order so allocating to original_best") + log.debug("'Best' order so allocating to original_best") contract_order.algo_to_use = ORIGINAL_BEST return contract_order @@ -119,7 +119,7 @@ def allocate_for_limit_order( ) -> contractOrder: # in the future could be randomized... log = contract_order.log_with_attributes(data.log) - log.msg("Allocating to limit order") + log.debug("Allocating to limit order") contract_order.algo_to_use = LIMIT_ALGO return contract_order diff --git a/sysexecution/algos/common_functions.py b/sysexecution/algos/common_functions.py index 97b16eaf20..031c2ed10e 100644 --- a/sysexecution/algos/common_functions.py +++ b/sysexecution/algos/common_functions.py @@ -47,7 +47,7 @@ def cancel_order( broker_order_with_controls ) if is_cancelled: - log.msg("Cancelled order") + log.debug("Cancelled order") break if timer.finished: log.warn("Ran out of time to cancel order - may cause weird behaviour!") @@ -71,9 +71,9 @@ def set_limit_price( broker_order_with_controls, new_limit_price ) ) - log.msg("Tried to change limit price to %f" % new_limit_price) + log.debug("Tried to change limit price to %f" % new_limit_price) except orderCannotBeModified as error: - log.msg("Can't modify limit price for order, error %s" % str(error)) + log.debug("Can't modify limit price for order, error %s" % str(error)) return broker_order_with_controls @@ -112,4 +112,4 @@ def file_log_report_market_order(log, broker_order_with_controls: orderWithContr log_report = "Market order execution current tick %s" % current_tick - log.msg(log_report) + log.debug(log_report) diff --git a/sysexecution/order_stacks/instrument_order_stack.py b/sysexecution/order_stacks/instrument_order_stack.py index 9888e18c8f..2094da853c 100644 --- a/sysexecution/order_stacks/instrument_order_stack.py +++ b/sysexecution/order_stacks/instrument_order_stack.py @@ -88,10 +88,10 @@ def _put_new_order_on_stack_when_no_existing_order( if new_order.is_zero_trade() and not allow_zero_orders: log_msg = "Zero orders not allowed" - log.msg(log_msg) + log.debug(log_msg) raise zeroOrderException(log_msg) - log.msg("New order %s putting on %s" % (str(new_order), str(self))) + log.debug("New order %s putting on %s" % (str(new_order), str(self))) order_id = self._put_order_on_stack_and_get_order_id(new_order) @@ -154,7 +154,7 @@ def calculate_adjusted_order_given_existing_orders( ) ) - log.msg( + log.debug( "Already have orders %s wanted %s so putting on order for %s (%s)" % ( str(existing_trades), diff --git a/sysexecution/order_stacks/order_stack.py b/sysexecution/order_stacks/order_stack.py index 368ac4c273..36de6165ad 100644 --- a/sysexecution/order_stacks/order_stack.py +++ b/sysexecution/order_stacks/order_stack.py @@ -340,7 +340,7 @@ def change_fill_quantity_for_order( self._change_order_on_stack(order_id, new_order) - log.msg( + log.debug( "Changed fill qty from %s to %s for order %s" % (str(existing_order.fill), str(fill_qty), str(existing_order)) ) diff --git a/sysexecution/stack_handler/balance_trades.py b/sysexecution/stack_handler/balance_trades.py index 426f7665ca..ca65dfae69 100644 --- a/sysexecution/stack_handler/balance_trades.py +++ b/sysexecution/stack_handler/balance_trades.py @@ -21,7 +21,7 @@ def create_balance_trade(self, broker_order: brokerOrder): contract_order ) - log.msg("Putting balancing trades on stacks") + log.debug("Putting balancing trades on stacks") ( result, @@ -42,7 +42,7 @@ def create_balance_trade(self, broker_order: brokerOrder): contract_order.order_id = contract_order_id instrument_order.order_id = instrument_order_id - log.msg("Updating positions") + log.debug("Updating positions") self.apply_position_change_to_stored_contract_positions( contract_order, contract_order.fill, apply_entire_trade=True ) @@ -50,7 +50,7 @@ def create_balance_trade(self, broker_order: brokerOrder): instrument_order, instrument_order.fill, apply_entire_trade=True ) - log.msg("Marking balancing trades as completed and historic order data") + log.debug("Marking balancing trades as completed and historic order data") self.handle_completed_instrument_order( instrument_order_id, treat_inactive_as_complete=True ) @@ -64,7 +64,7 @@ def put_balance_trades_on_stack( broker_order: brokerOrder, ): log = instrument_order.log_with_attributes(self.log) - log.msg("Putting balancing trades on stacks") + log.debug("Putting balancing trades on stacks") try: instrument_order_id = ( @@ -111,7 +111,7 @@ def put_balance_trades_on_stack( log.error("Couldn't add children to contract order exception %s" % str(e)) return failure, instrument_order_id, contract_order_id, broker_order_id - log.msg("All balancing trades added to stacks") + log.debug("All balancing trades added to stacks") return success, instrument_order_id, contract_order_id, broker_order_id @@ -128,7 +128,7 @@ def rollback_balance_trades( def create_balance_instrument_trade(self, instrument_order: instrumentOrder): log = instrument_order.log_with_attributes(self.log) - log.msg("Putting balancing order on instrument stack") + log.debug("Putting balancing order on instrument stack") instrument_order_id = ( self.instrument_stack.put_manual_order_on_stack_and_return_order_id( instrument_order @@ -137,7 +137,7 @@ def create_balance_instrument_trade(self, instrument_order: instrumentOrder): instrument_order.order_id = instrument_order_id - log.msg( + log.debug( "Marking balancing trades as completed and updating positions and historic order data" ) self.apply_position_change_to_instrument( diff --git a/sysexecution/stack_handler/cancel_and_modify.py b/sysexecution/stack_handler/cancel_and_modify.py index eeec8c43f1..08180ccfcf 100644 --- a/sysexecution/stack_handler/cancel_and_modify.py +++ b/sysexecution/stack_handler/cancel_and_modify.py @@ -34,7 +34,7 @@ def cancel_and_confirm_all_broker_orders( if log_critical_on_timeout: self.critical_cancel_log(list_of_uncancelled_broker_orders) else: - self.log.msg("All orders cancelled okay") + self.log.debug("All orders cancelled okay") def try_and_cancel_all_broker_orders_and_return_list_of_orders( self, @@ -65,7 +65,7 @@ def cancel_broker_order_with_id_and_return_order( return missing_order log = broker_order.log_with_attributes(self.log) - log.msg("Cancelling order on stack with broker %s" % str(broker_order)) + log.debug("Cancelling order on stack with broker %s" % str(broker_order)) data_broker = self.data_broker data_broker.cancel_order_on_stack(broker_order) @@ -96,7 +96,7 @@ def list_of_orders_not_yet_cancelled( if order_is_cancelled: log = broker_order.log_with_attributes(self.log) new_list_of_orders.remove(broker_order) - log.msg("Order %s succesfully cancelled" % broker_order) + log.debug("Order %s succesfully cancelled" % broker_order) new_list_of_orders = listOfOrders(new_list_of_orders) diff --git a/sysexecution/stack_handler/checks.py b/sysexecution/stack_handler/checks.py index 3681b4cfaa..f97836250d 100644 --- a/sysexecution/stack_handler/checks.py +++ b/sysexecution/stack_handler/checks.py @@ -63,7 +63,7 @@ def clear_position_locks_where_breaks_fixed(self, breaks: list): instrument not in instruments_with_breaks ) if instrument_is_locked_but_no_longer_has_a_break: - self.log.msg("Clearing lock for %s" % instrument) + self.log.debug("Clearing lock for %s" % instrument) data_locks.remove_lock_for_instrument(instrument) else: # instrument has a break and needs a break @@ -76,5 +76,5 @@ def clear_position_locks_no_checks(self, instrument_code: str = arg_not_supplied else: locked_instruments = [instrument_code] for instrument in locked_instruments: - self.log.msg("Clearing lock for %s" % instrument) + self.log.debug("Clearing lock for %s" % instrument) data_locks.remove_lock_for_instrument(instrument) diff --git a/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py b/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py index f7d60b686f..c45fa4e3bc 100644 --- a/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py +++ b/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py @@ -179,7 +179,7 @@ def apply_trade_limits_to_contract_order( ) if contract_order_after_trade_limits.trade != proposed_order.trade: - log.msg( + log.debug( "%s trade change from %s to %s because of trade limits" % ( proposed_order.key, @@ -206,7 +206,7 @@ def liquidity_size_contract_order( ) if liquid_qty != contract_order_after_trade_limits.trade: - log.msg( + log.debug( "Cut down order to size %s from %s because of liquidity" % (str(liquid_qty), str(contract_order_after_trade_limits.trade)) ) @@ -235,7 +235,7 @@ def send_to_algo( ) ) - log.msg( + log.debug( "Sending order %s to algo %s" % ( str(contract_order_to_trade_with_algo_set), @@ -343,7 +343,7 @@ def post_trade_processing( # release contract order from algo contract_order_id = broker_order.parent self.contract_stack.release_order_from_algo_control(contract_order_id) - self.log.msg("Released contract order %s from algo control" % contract_order_id) + self.log.debug("Released contract order %s from algo control" % contract_order_id) def add_trade_to_trade_limits(self, executed_order: brokerOrder): diff --git a/sysexecution/stack_handler/roll_orders.py b/sysexecution/stack_handler/roll_orders.py index b074e800b8..05330e162f 100644 --- a/sysexecution/stack_handler/roll_orders.py +++ b/sysexecution/stack_handler/roll_orders.py @@ -207,7 +207,7 @@ def add_instrument_and_list_of_contract_orders_to_stack( ) # phew got there - parent_log.msg( + parent_log.debug( "Added parent order with ID %d %s to stack" % (parent_order_id, str(instrument_order)) ) diff --git a/sysexecution/stack_handler/spawn_children_from_instrument_orders.py b/sysexecution/stack_handler/spawn_children_from_instrument_orders.py index ab92e15b8c..5190a3fd5f 100644 --- a/sysexecution/stack_handler/spawn_children_from_instrument_orders.py +++ b/sysexecution/stack_handler/spawn_children_from_instrument_orders.py @@ -52,7 +52,7 @@ def spawn_children_from_instrument_order_id(self, instrument_order_id: int): instrument_order.instrument_code ) if instrument_locked: - # log.msg("Instrument is locked, not spawning order") + # log.debug("Instrument is locked, not spawning order") return None list_of_contract_orders = spawn_children_from_instrument_order( @@ -60,7 +60,7 @@ def spawn_children_from_instrument_order_id(self, instrument_order_id: int): ) log = instrument_order.log_with_attributes(self.log) - log.msg("List of contract orders spawned %s" % str(list_of_contract_orders)) + log.debug("List of contract orders spawned %s" % str(list_of_contract_orders)) self.add_children_to_stack_and_child_id_to_parent( self.instrument_stack, @@ -216,7 +216,7 @@ def get_required_contract_trade_for_instrument( diag_contracts = dataContracts(data) current_contract = diag_contracts.get_priced_contract_id(instrument_code) - log.msg( + log.debug( "No roll, allocating entire order %s to current contract %s" % (str(instrument_order), current_contract) ) @@ -226,7 +226,7 @@ def get_required_contract_trade_for_instrument( diag_contracts = dataContracts(data) current_contract = diag_contracts.get_priced_contract_id(instrument_code) - log.msg( + log.debug( "Closing roll state, allocating entire order %s to current contract %s" % (str(instrument_order), current_contract) ) @@ -241,7 +241,7 @@ def get_required_contract_trade_for_instrument( return list_of_child_contract_dates_and_trades elif diag_positions.is_type_of_active_rolling_roll_state(instrument_code): - log.msg( + log.debug( "Roll state is active rolling, not going to generate trade for order %s" % (str(instrument_order)) ) @@ -280,7 +280,7 @@ def passive_roll_child_order( if position_current_contract == 0: # Passive roll and no position in the current contract, start trading # the next contract - log.msg( + log.debug( "Passive roll handling order %s, no position in current contract, entire trade in next contract %s" % (str(instrument_order), next_contract) ) @@ -291,7 +291,7 @@ def passive_roll_child_order( if increasing_trade: # Passive roll and increasing trade # Do it all in next contract - log.msg( + log.debug( "Passive roll handling order %s, increasing trade, entire trade in next contract %s" % (str(instrument_order), next_contract) ) @@ -304,7 +304,7 @@ def passive_roll_child_order( ) if new_position == 0 or sign_of_position_is_unchanged: # A reducing trade that we can do entirely in the current contract - log.msg( + log.debug( "Passive roll handling order %s, reducing trade, entire trade in next contract %s" % (str(instrument_order), next_contract) ) @@ -318,7 +318,7 @@ def passive_roll_child_order( next_contract=next_contract, position_current_contract=position_current_contract, ) - log.msg( + log.debug( "Passive roll handling order %s, reducing trade, split trade between contract %s and %s" % (str(instrument_order), current_contract, next_contract) ) diff --git a/sysexecution/stack_handler/stackHandlerCore.py b/sysexecution/stack_handler/stackHandlerCore.py index 7a5e3a27ba..1eaf7e8284 100644 --- a/sysexecution/stack_handler/stackHandlerCore.py +++ b/sysexecution/stack_handler/stackHandlerCore.py @@ -160,7 +160,7 @@ def log_successful_adding( for child_order, child_id in zip(list_of_child_orders, list_of_child_ids): child_log = child_order.log_with_attributes(parent_log) - child_log.msg( + child_log.debug( "Put child order %s on stack with ID %d from parent order %s" % (str(child_order), child_id, str(parent_order)) ) diff --git a/sysexecution/stack_handler/stack_handler.py b/sysexecution/stack_handler/stack_handler.py index ce62d622f7..2d6c93ea48 100644 --- a/sysexecution/stack_handler/stack_handler.py +++ b/sysexecution/stack_handler/stack_handler.py @@ -25,19 +25,19 @@ def safe_stack_removal(self): # We do this at the end of every day as we don't like state hanging # around - self.log.msg("Running safe stack removal") + self.log.debug("Running safe stack removal") # First, cancel any partially or unfilled broker orders - self.log.msg("Trying to cancel all broker orders") + self.log.debug("Trying to cancel all broker orders") self.cancel_and_confirm_all_broker_orders(log_critical_on_timeout=True) # Next, process fills - self.log.msg("Processing fills") + self.log.debug("Processing fills") self.process_fills_stack() # and then completions # need special flag for completions, since we also need to 'complete' partially filled orders # and allow empty broker orders to be marked as completed - self.log.msg("Processing completions") + self.log.debug("Processing completions") self.handle_completed_orders( allow_partial_completions=True, allow_zero_completions=True ) diff --git a/sysexecution/strategies/classic_buffered_positions.py b/sysexecution/strategies/classic_buffered_positions.py index 28493068cb..9bd0ff6613 100644 --- a/sysexecution/strategies/classic_buffered_positions.py +++ b/sysexecution/strategies/classic_buffered_positions.py @@ -180,7 +180,7 @@ def trade_given_optimal_and_actual_positions( ) log = order_required.log_with_attributes(data.log) - log.msg( + log.debug( "Upper %.2f Lower %.2f Current %d Required position %d Required trade %d Reference price %f for contract %s" % ( upper_for_instrument, diff --git a/sysexecution/strategies/dynamic_optimised_positions.py b/sysexecution/strategies/dynamic_optimised_positions.py index f493ce0b81..1844c57511 100644 --- a/sysexecution/strategies/dynamic_optimised_positions.py +++ b/sysexecution/strategies/dynamic_optimised_positions.py @@ -207,7 +207,7 @@ def get_data_for_objective_instance( ) -> dataForObjectiveInstance: list_of_instruments = list(raw_optimal_position_data.keys()) - data.log.msg("Getting data for optimisation") + data.log.debug("Getting data for optimisation") previous_positions_as_weights_object = portfolioWeights(previous_positions) previous_positions_as_weights_object = ( @@ -244,19 +244,19 @@ def get_data_for_objective_instance( ] ) - data.log.msg("Getting maximum positions") + data.log.debug("Getting maximum positions") maximum_position_contracts = get_maximum_position_contracts( data, strategy_name=strategy_name, list_of_instruments=list_of_instruments ) - data.log.msg("Getting covariance matrix") + data.log.debug("Getting covariance matrix") - data.log.msg("Getting per contract values") + data.log.debug("Getting per contract values") per_contract_value = get_per_contract_values( data, strategy_name=strategy_name, list_of_instruments=list_of_instruments ) - data.log.msg("Getting costs") + data.log.debug("Getting costs") costs = calculate_costs_per_portfolio_weight( data, per_contract_value=per_contract_value, @@ -517,11 +517,11 @@ def get_speed_control(data): "config.small_system doesn't include buffer or shadow cost or cost_multiplier: you've probably messed up your private_config" ) - data.log.msg( + data.log.debug( "Shadow cost %f multiply by cost multiplier %f) = %f" % (trade_shadow_cost, cost_multiplier, trade_shadow_cost * cost_multiplier) ) - data.log.msg("Tracking error buffer %f" % tracking_error_buffer) + data.log.debug("Tracking error buffer %f" % tracking_error_buffer) speed_control = speedControlForDynamicOpt( trade_shadow_cost=trade_shadow_cost * cost_multiplier, @@ -682,7 +682,7 @@ def write_optimised_positions_data_for_code( instrument_code=instrument_code, strategy_name=strategy_name ) - data.log.msg( + data.log.debug( "Adding optimal position for %s: %s" % (str(instrument_strategy), optimised_position_entry.verbose_repr()) ) @@ -743,7 +743,7 @@ def trade_given_optimal_and_actual_positions( ) log = order_required.log_with_attributes(data.log) - log.msg( + log.debug( "Current %d Required position %d Required trade %d Reference price %f for contract %s" % ( current_position, diff --git a/sysexecution/strategies/strategy_order_handling.py b/sysexecution/strategies/strategy_order_handling.py index b9feda217b..46e2702bda 100644 --- a/sysexecution/strategies/strategy_order_handling.py +++ b/sysexecution/strategies/strategy_order_handling.py @@ -133,7 +133,7 @@ def apply_overrides_for_instrument_and_strategy( if revised_order.trade != proposed_order.trade: log = proposed_order.log_with_attributes(self.log) - log.msg( + log.debug( "%s trade change from %s to %s because of override %s" % ( instrument_strategy.key, @@ -174,11 +174,11 @@ def submit_order_list(self, order_list: listOfOrders): # try: # we allow existing orders to be modified log = order.log_with_attributes(self.log) - log.msg("Required order %s" % str(order)) + log.debug("Required order %s" % str(order)) instrument_locked = data_lock.is_instrument_locked(order.instrument_code) if instrument_locked: - log.msg("Instrument locked, not submitting") + log.debug("Instrument locked, not submitting") continue self.submit_order(order) @@ -195,7 +195,7 @@ def submit_order(self, order: instrumentOrder): ) else: - log.msg( + log.debug( "Added order %s to instrument order stack with order id %d" % (str(order), order_id), instrument_order_id=order_id, diff --git a/sysinit/futures/seed_price_data_from_IB.py b/sysinit/futures/seed_price_data_from_IB.py index 53fc70f54e..0069b2f2f4 100644 --- a/sysinit/futures/seed_price_data_from_IB.py +++ b/sysinit/futures/seed_price_data_from_IB.py @@ -36,12 +36,12 @@ def seed_price_data_for_contract(data: dataBlob, contract_object: futuresContrac list_of_frequencies = [HOURLY_FREQ, DAILY_PRICE_FREQ] for frequency in list_of_frequencies: - log.msg("Getting data at frequency %s" % str(frequency)) + log.debug("Getting data at frequency %s" % str(frequency)) seed_price_data_for_contract_at_frequency( data=data, contract_object=contract_object, frequency=frequency ) - log.msg("Writing merged data for %s" % str(contract_object)) + log.debug("Writing merged data for %s" % str(contract_object)) write_merged_prices_for_contract( data, contract_object=contract_object, list_of_frequencies=list_of_frequencies ) @@ -65,7 +65,7 @@ def seed_price_data_for_contract_at_frequency( log.warn("Error getting data for %s" % str(contract_object)) return None - log.msg("Got %d lines of prices for %s" % (len(prices), str(contract_object))) + log.debug("Got %d lines of prices for %s" % (len(prices), str(contract_object))) if len(prices) == 0: log.warn("No price data for %s" % str(contract_object)) diff --git a/syslogging/adapter.py b/syslogging/adapter.py index d157f3a3a9..1c71f65a95 100644 --- a/syslogging/adapter.py +++ b/syslogging/adapter.py @@ -62,14 +62,6 @@ def _merge_attributes(self, method, attributes): return merged - def msg(self, msg, *args, **kwargs): - warnings.warn( - "The 'msg' function is deprecated, " "use 'debug' instead", - DeprecationWarning, - 2, - ) - self.log(logging.DEBUG, msg, *args, **kwargs) - def terse(self, msg, *args, **kwargs): warnings.warn( "The 'terse' function is deprecated, " "use 'info' instead", diff --git a/syslogging/tests/logging_tests.py b/syslogging/tests/logging_tests.py index 5430f04bc4..4f231483e1 100644 --- a/syslogging/tests/logging_tests.py +++ b/syslogging/tests/logging_tests.py @@ -94,13 +94,6 @@ def test_label_bad(self): with pytest.raises(Exception): logger.label(stage="left", foo="bar") - def test_msg(self, caplog): - logger = get_logger("Msg") - logger.msg("msg() is an alias for DEBUG") - assert caplog.record_tuples == [ - ("Msg", logging.DEBUG, "msg() is an alias for DEBUG") - ] - def test_terse(self, caplog): logger = get_logger("Terse") logger.terse("terse() is an alias for INFO") diff --git a/sysproduction/backup_arctic_to_csv.py b/sysproduction/backup_arctic_to_csv.py index 6a0040b118..f807522f84 100644 --- a/sysproduction/backup_arctic_to_csv.py +++ b/sysproduction/backup_arctic_to_csv.py @@ -75,7 +75,7 @@ def backup_arctic_to_csv(self): backup_data = get_data_and_create_csv_directories(self.data.log_name) log = self.data.log - log.msg("Dumping from arctic, mongo to .csv files") + log.debug("Dumping from arctic, mongo to .csv files") backup_futures_contract_prices_to_csv(backup_data) backup_spreads_to_csv(backup_data) backup_fx_to_csv(backup_data) @@ -89,7 +89,7 @@ def backup_arctic_to_csv(self): backup_spread_cost_data(backup_data) backup_optimal_positions(backup_data) backup_roll_state_data(backup_data) - log.msg("Copying to backup directory") + log.debug("Copying to backup directory") backup_csv_dump(self.data) @@ -206,7 +206,7 @@ def backup_futures_contract_prices_for_contract_to_csv( if ignore_long_expired: if futures_contract.days_since_expiry() > CALENDAR_DAYS_IN_YEAR: ## Almost certainly expired, skip - data.log.msg("Skipping expired contract %s" % str(futures_contract)) + data.log.debug("Skipping expired contract %s" % str(futures_contract)) return None @@ -222,7 +222,7 @@ def backup_futures_contract_prices_for_contract_to_csv( if check_df_equals(arctic_data, csv_data): # No update needed, move on - data.log.msg("No prices backup needed for %s" % str(futures_contract)) + data.log.debug("No prices backup needed for %s" % str(futures_contract)) else: # Write backup try: @@ -231,7 +231,7 @@ def backup_futures_contract_prices_for_contract_to_csv( arctic_data, ignore_duplication=True, ) - data.log.msg("Written backup .csv of prices for %s" % str(futures_contract)) + data.log.debug("Written backup .csv of prices for %s" % str(futures_contract)) except BaseException: data.log.warn( "Problem writing .csv of prices for %s" % str(futures_contract) @@ -245,14 +245,14 @@ def backup_fx_to_csv(data): arctic_data = data.arctic_fx_prices.get_fx_prices(fx_code) csv_data = data.csv_fx_prices.get_fx_prices(fx_code) if check_ts_equals(arctic_data, csv_data): - data.log.msg("No fx backup needed for %s" % fx_code) + data.log.debug("No fx backup needed for %s" % fx_code) else: # Write backup try: data.csv_fx_prices.add_fx_prices( fx_code, arctic_data, ignore_duplication=True ) - data.log.msg("Written .csv backup for %s" % fx_code) + data.log.debug("Written .csv backup for %s" % fx_code) except BaseException: data.log.warn("Problem writing .csv backup for %s" % fx_code) @@ -270,14 +270,14 @@ def backup_multiple_to_csv_for_instrument(data, instrument_code: str): csv_data = data.csv_futures_multiple_prices.get_multiple_prices(instrument_code) if check_df_equals(arctic_data, csv_data): - data.log.msg("No multiple prices backup needed for %s" % instrument_code) + data.log.debug("No multiple prices backup needed for %s" % instrument_code) pass else: try: data.csv_futures_multiple_prices.add_multiple_prices( instrument_code, arctic_data, ignore_duplication=True ) - data.log.msg("Written .csv backup multiple prices for %s" % instrument_code) + data.log.debug("Written .csv backup multiple prices for %s" % instrument_code) except BaseException: data.log.warn( "Problem writing .csv backup multiple prices for %s" % instrument_code @@ -297,14 +297,14 @@ def backup_adj_to_csv_for_instrument(data: dataBlob, instrument_code: str): csv_data = data.csv_futures_adjusted_prices.get_adjusted_prices(instrument_code) if check_ts_equals(arctic_data, csv_data): - data.log.msg("No adjusted prices backup needed for %s" % instrument_code) + data.log.debug("No adjusted prices backup needed for %s" % instrument_code) pass else: try: data.csv_futures_adjusted_prices.add_adjusted_prices( instrument_code, arctic_data, ignore_duplication=True ) - data.log.msg("Written .csv backup for adjusted prices %s" % instrument_code) + data.log.debug("Written .csv backup for adjusted prices %s" % instrument_code) except BaseException: data.log.warn( "Problem writing .csv backup for adjusted prices %s" % instrument_code @@ -322,14 +322,14 @@ def backup_spreads_to_csv_for_instrument(data: dataBlob, instrument_code: str): csv_data = data.csv_spreads_for_instrument.get_spreads(instrument_code) if check_ts_equals(arctic_data, csv_data): - data.log.msg("No spreads backup needed for %s" % instrument_code) + data.log.debug("No spreads backup needed for %s" % instrument_code) pass else: try: data.csv_spreads_for_instrument.add_spreads( instrument_code, arctic_data, ignore_duplication=True ) - data.log.msg("Written .csv backup for spreads %s" % instrument_code) + data.log.debug("Written .csv backup for spreads %s" % instrument_code) except BaseException: data.log.warn( "Problem writing .csv backup for spreads %s" % instrument_code @@ -357,7 +357,7 @@ def backup_contract_position_data(data): data.csv_contract_position.overwrite_position_series_for_contract_object_without_checking( contract, arctic_data ) - data.log.msg( + data.log.debug( "Backed up %s %s contract position data" % (instrument_code, contract) ) @@ -381,36 +381,36 @@ def backup_strategy_position_data(data): data.csv_strategy_position.overwrite_position_series_for_instrument_strategy_without_checking( instrument_strategy, arctic_data ) - data.log.msg( + data.log.debug( "Backed up %s %s strategy position data" % (instrument_code, strategy_name) ) def backup_historical_orders(data): - data.log.msg("Backing up strategy orders...") + data.log.debug("Backing up strategy orders...") list_of_orders = [ data.mongo_strategy_historic_orders.get_order_with_orderid(id) for id in data.mongo_strategy_historic_orders.get_list_of_order_ids() ] data.csv_strategy_historic_orders.write_orders(list_of_orders) - data.log.msg("Done") + data.log.debug("Done") - data.log.msg("Backing up contract orders...") + data.log.debug("Backing up contract orders...") list_of_orders = [ data.mongo_contract_historic_orders.get_order_with_orderid(order_id) for order_id in data.mongo_contract_historic_orders.get_list_of_order_ids() ] data.csv_contract_historic_orders.write_orders(list_of_orders) - data.log.msg("Done") + data.log.debug("Done") - data.log.msg("Backing up broker orders...") + data.log.debug("Backing up broker orders...") list_of_orders = [ data.mongo_broker_historic_orders.get_order_with_orderid(order_id) for order_id in data.mongo_broker_historic_orders.get_list_of_order_ids() ] data.csv_broker_historic_orders.write_orders(list_of_orders) - data.log.msg("Done") + data.log.debug("Done") def backup_capital(data): @@ -463,13 +463,13 @@ def backup_optimal_positions(data): data.csv_optimal_position.write_optimal_position_as_df_for_instrument_strategy_without_checking( instrument_strategy, arctic_data ) - data.log.msg("Backed up %s optimal position data" % str(instrument_strategy)) + data.log.debug("Backed up %s optimal position data" % str(instrument_strategy)) def backup_spread_cost_data(data): spread_cost_as_series = data.mongo_spread_cost.get_spread_costs_as_series() data.csv_spread_cost.write_all_instrument_spreads(spread_cost_as_series) - data.log.msg("Backed up spread cost data") + data.log.debug("Backed up spread cost data") def backup_roll_state_data(data): @@ -482,7 +482,7 @@ def backup_roll_state_data(data): roll_state_df = pd.DataFrame(roll_state_list, index=instrument_list) roll_state_df.columns = ["state"] data.csv_roll_state.write_all_instrument_data(roll_state_df) - data.log.msg("Backed up roll state") + data.log.debug("Backed up roll state") def backup_contract_data(data): @@ -498,13 +498,13 @@ def backup_contract_data(data): data.csv_futures_contract.write_contract_list_as_df( instrument_code, contract_list ) - data.log.msg("Backed up contract data for %s" % instrument_code) + data.log.debug("Backed up contract data for %s" % instrument_code) def backup_csv_dump(data): source_path = get_csv_dump_dir() destination_path = get_csv_backup_directory() - data.log.msg("Copy from %s to %s" % (source_path, destination_path)) + data.log.debug("Copy from %s to %s" % (source_path, destination_path)) os.system("rsync -av %s %s" % (source_path, destination_path)) diff --git a/sysproduction/backup_mongo_data_as_dump.py b/sysproduction/backup_mongo_data_as_dump.py index f42dd229b1..6dd0fa6649 100644 --- a/sysproduction/backup_mongo_data_as_dump.py +++ b/sysproduction/backup_mongo_data_as_dump.py @@ -24,9 +24,9 @@ def __init__(self, data): def backup_mongo_data_as_dump(self): data = self.data log = data.log - log.msg("Exporting mongo data") + log.debug("Exporting mongo data") dump_mongo_data(data) - log.msg("Copying data to backup destination") + log.debug("Copying data to backup destination") backup_mongo_dump(data) @@ -34,18 +34,18 @@ def dump_mongo_data(data: dataBlob): config = data.config host = config.get_element_or_arg_not_supplied("mongo_host") path = get_mongo_dump_directory() - data.log.msg("Dumping mongo data to %s NOT TESTED IN WINDOWS" % path) + data.log.debug("Dumping mongo data to %s NOT TESTED IN WINDOWS" % path) if host.startswith("mongodb://"): os.system("mongodump --uri='%s' -o=%s" % (host, path)) else: os.system("mongodump --host='%s' -o=%s" % (host, path)) - data.log.msg("Dumped") + data.log.debug("Dumped") def backup_mongo_dump(data): source_path = get_mongo_dump_directory() destination_path = get_mongo_backup_directory() - data.log.msg("Copy from %s to %s" % (source_path, destination_path)) + data.log.debug("Copy from %s to %s" % (source_path, destination_path)) os.system("rsync -av %s %s" % (source_path, destination_path)) diff --git a/sysproduction/backup_state_files.py b/sysproduction/backup_state_files.py index 0e864453ce..bd431d8739 100644 --- a/sysproduction/backup_state_files.py +++ b/sysproduction/backup_state_files.py @@ -21,14 +21,14 @@ def __init__(self, data): def backup_files(self): data = self.data - self.data.log.msg("Backing up state files") + self.data.log.debug("Backing up state files") backup_state_files_with_data_object(data) def backup_state_files_with_data_object(data): source_path = get_statefile_directory() destination_path = get_statefile_backup_directory() - data.log.msg("Copy from %s to %s" % (source_path, destination_path)) + data.log.debug("Copy from %s to %s" % (source_path, destination_path)) os.system("rsync -av %s %s" % (source_path, destination_path)) diff --git a/sysproduction/clean_truncate_backtest_states.py b/sysproduction/clean_truncate_backtest_states.py index 2dfa2fee1f..a88c1d1309 100644 --- a/sysproduction/clean_truncate_backtest_states.py +++ b/sysproduction/clean_truncate_backtest_states.py @@ -17,7 +17,7 @@ def __init__(self, data: dataBlob): def clean_backtest_states(self): directory_to_use = get_directory_store_backtests() - self.data.log.msg( + self.data.log.debug( "Deleting old .pck and .yaml backtest state files in directory %s" % directory_to_use ) diff --git a/sysproduction/clean_truncate_echo_files.py b/sysproduction/clean_truncate_echo_files.py index d140f4f699..4bd701dc25 100644 --- a/sysproduction/clean_truncate_echo_files.py +++ b/sysproduction/clean_truncate_echo_files.py @@ -21,11 +21,11 @@ def __init__(self, data: dataBlob): def clean_echo_files(self): pathname = get_echo_file_directory() echo_extension = get_echo_extension() - self.data.log.msg("Archiving echo files") + self.data.log.debug("Archiving echo files") rename_files_with_extension_in_pathname_as_archive_files( pathname, extension=echo_extension, archive_extension=".arch" ) - self.data.log.msg("Deleting old echo files") + self.data.log.debug("Deleting old echo files") delete_old_files_with_extension_in_pathname( pathname, extension=".arch", days_old=30 ) diff --git a/sysproduction/clean_truncate_log_files.py b/sysproduction/clean_truncate_log_files.py index 662bedf14a..0dc618fcd9 100644 --- a/sysproduction/clean_truncate_log_files.py +++ b/sysproduction/clean_truncate_log_files.py @@ -16,7 +16,7 @@ def __init__(self, data: dataBlob): ## FIXME - CHANGE TO FILE ROTATION def clean_log_files(self): mlog = diagLogs(self.data) - self.data.log.msg("Deleting log items more than 30 days old") + self.data.log.debug("Deleting log items more than 30 days old") mlog.delete_log_items_from_before_n_days(days=30) diff --git a/sysproduction/data/backtest.py b/sysproduction/data/backtest.py index f953c3cd13..9257bef241 100644 --- a/sysproduction/data/backtest.py +++ b/sysproduction/data/backtest.py @@ -276,7 +276,7 @@ def pickle_state(data, system, backtest_filename): try: system.cache.pickle(backtest_filename) - data.log.msg("Pickled backtest state to %s" % backtest_filename) + data.log.debug("Pickled backtest state to %s" % backtest_filename) return success except Exception as e: data.log.warn( @@ -288,7 +288,7 @@ def pickle_state(data, system, backtest_filename): def copy_config_file(data, resolved_backtest_config_filename, config_save_filename): try: copyfile(resolved_backtest_config_filename, config_save_filename) - data.log.msg( + data.log.debug( "Copied config file from %s to %s" % (resolved_backtest_config_filename, config_save_filename) ) diff --git a/sysproduction/data/contracts.py b/sysproduction/data/contracts.py index a163eb6c46..c0d9791eec 100644 --- a/sysproduction/data/contracts.py +++ b/sysproduction/data/contracts.py @@ -180,7 +180,7 @@ def update_roll_parameters( ignore_duplication=True, ) else: - self.log.msg("Have to be sure to modify roll parameters") + self.log.debug("Have to be sure to modify roll parameters") def get_roll_parameters(self, instrument_code: str) -> rollParameters: roll_parameters = self.db_roll_parameters.get_roll_parameters(instrument_code) diff --git a/sysproduction/data/controls.py b/sysproduction/data/controls.py index 97566b52ae..5acdcba47f 100644 --- a/sysproduction/data/controls.py +++ b/sysproduction/data/controls.py @@ -671,7 +671,7 @@ def temporarily_set_position_limit_to_zero_and_store_original_limit( self.db_temporary_close_data.add_stored_position_limit(original_limit) self.set_abs_position_limit_for_instrument(instrument_code, 0) - self.log.msg( + self.log.debug( "Temporarily setting position limit, was %s, now zero" % (str(original_limit)) ) @@ -694,7 +694,7 @@ def reset_position_limit_for_instrument_to_original_value(self, instrument_code) self.db_temporary_close_data.clear_stored_position_limit_for_instrument( instrument_code ) - self.log.msg( + self.log.debug( "Reset position limit from temporary zero limit, now %s" % str(original_limit) ) diff --git a/sysproduction/data/instruments.py b/sysproduction/data/instruments.py index 7d7a9f396e..b8bddc2055 100644 --- a/sysproduction/data/instruments.py +++ b/sysproduction/data/instruments.py @@ -18,7 +18,7 @@ def _add_required_classes_to_data(self, data) -> dataBlob: def update_spread_costs(self, instrument_code: str, spread_cost: float): original_cost = self.db_spread_cost_data.get_spread_cost(instrument_code) - self.log.msg( + self.log.debug( "Updating spread for %s from %f to %f" % (instrument_code, original_cost, spread_cost) ) diff --git a/sysproduction/data/positions.py b/sysproduction/data/positions.py index 1c0c7edff5..4ab082f5ff 100644 --- a/sysproduction/data/positions.py +++ b/sysproduction/data/positions.py @@ -414,7 +414,7 @@ def update_strategy_position_table_with_instrument_order( ) log = original_instrument_order.log_with_attributes(self.log) - log.msg( + log.debug( "Updated position of %s from %d to %d because of trade %s %d fill %s" % ( str(instrument_strategy), @@ -450,7 +450,7 @@ def update_contract_position_table_with_contract_order( self._update_positions_for_individual_contract_leg( contract=contract, trade_done=trade_done, time_date=time_date ) - log.msg( + log.debug( "Updated position of %s because of trade %s ID:%d with fills %d" % ( str(contract), @@ -475,7 +475,7 @@ def _update_positions_for_individual_contract_leg( new_position_db = self.diag_positions.get_position_for_contract(contract) log = contract.specific_log(self.log) - log.msg( + log.debug( "Updated position of %s from %d to %d; new position in db is %d" % ( str(contract), diff --git a/sysproduction/interactive_update_roll_status.py b/sysproduction/interactive_update_roll_status.py index 9dc8a277a9..781da6aca9 100644 --- a/sysproduction/interactive_update_roll_status.py +++ b/sysproduction/interactive_update_roll_status.py @@ -541,14 +541,14 @@ def state_change_to_roll_adjusted_prices( if roll_result is success: # Return the state back to default (no roll) state - data.log.msg( + data.log.debug( "Successful roll! Returning roll state of %s to %s" % (instrument_code, default_state) ) update_positions.set_roll_state(instrument_code, default_state) else: - data.log.msg( + data.log.debug( "Something has gone wrong with rolling adjusted of %s! Returning roll state to previous state of %s" % (instrument_code, original_roll_state) ) diff --git a/sysproduction/reporting/reporting_functions.py b/sysproduction/reporting/reporting_functions.py index 8d73d01453..b08516da20 100644 --- a/sysproduction/reporting/reporting_functions.py +++ b/sysproduction/reporting/reporting_functions.py @@ -71,7 +71,7 @@ def run_report_with_data_blob(report_config: reportConfig, data: dataBlob): :return: """ - data.log.msg("Running report %s" % str(report_config)) + data.log.debug("Running report %s" % str(report_config)) report_results = run_report_from_config(report_config=report_config, data=data) parsed_report = parse_report_results(data=data, report_results=report_results) @@ -275,7 +275,7 @@ def output_file_report( report_text=parsed_report.text, full_filename=full_filename ) - data.log.msg("Written report to %s" % full_filename) + data.log.debug("Written report to %s" % full_filename) def resolve_report_filename(report_config, data: dataBlob): diff --git a/sysproduction/strategy_code/run_dynamic_optimised_system.py b/sysproduction/strategy_code/run_dynamic_optimised_system.py index 462f45b919..4dd36eddbc 100644 --- a/sysproduction/strategy_code/run_dynamic_optimised_system.py +++ b/sysproduction/strategy_code/run_dynamic_optimised_system.py @@ -137,7 +137,7 @@ def updated_optimal_positions_for_dynamic_system( position_entry=position_entry, ) - log.msg("New Optimal position %s %s" % (str(position_entry), instrument_code)) + log.debug("New Optimal position %s %s" % (str(position_entry), instrument_code)) def construct_optimal_position_entry( diff --git a/sysproduction/strategy_code/run_system_classic.py b/sysproduction/strategy_code/run_system_classic.py index 4b10e94b58..7f019235a8 100644 --- a/sysproduction/strategy_code/run_system_classic.py +++ b/sysproduction/strategy_code/run_system_classic.py @@ -94,7 +94,7 @@ def _get_currency_and_capital(self): currency_data = dataCurrency(data) base_currency = currency_data.get_base_currency() - self.data.log.msg( + self.data.log.debug( "Using capital of %s %.2f" % (base_currency, notional_trading_capital) ) @@ -172,7 +172,7 @@ def updated_buffered_positions(data: dataBlob, strategy_name: str, system: Syste data_optimal_positions.update_optimal_position_for_instrument_strategy( instrument_strategy=instrument_strategy, position_entry=position_entry ) - log.msg( + log.debug( "New buffered positions %.3f %.3f" % (position_entry.lower_position, position_entry.upper_position), instrument_code=instrument_code, diff --git a/sysproduction/update_fx_prices.py b/sysproduction/update_fx_prices.py index fce6f5832d..f41b868611 100644 --- a/sysproduction/update_fx_prices.py +++ b/sysproduction/update_fx_prices.py @@ -41,7 +41,7 @@ def update_fx_prices_with_data(data: dataBlob): list_of_codes_all = ( broker_fx_source.get_list_of_fxcodes() ) # codes must be in .csv file /sysbrokers/IB/ibConfigSpotFx.csv - data.log.msg("FX Codes: %s" % str(list_of_codes_all)) + data.log.debug("FX Codes: %s" % str(list_of_codes_all)) for fx_code in list_of_codes_all: data.log.label(**{CURRENCY_CODE_LOG_LABEL: fx_code}) diff --git a/sysproduction/update_historical_prices.py b/sysproduction/update_historical_prices.py index 9df149075c..4852039e5f 100644 --- a/sysproduction/update_historical_prices.py +++ b/sysproduction/update_historical_prices.py @@ -64,7 +64,7 @@ def update_historical_prices_with_data( def download_all_instrument_prices_now(data: dataBlob): - data.log.msg("Downloading everything") + data.log.debug("Downloading everything") price_data = diagPrices(data) @@ -80,7 +80,7 @@ def manage_download_over_multiple_time_zones(data: dataBlob, download_by_zone: d Example download_by_zone = {'ASIA': '07:00', 'EMEA': '18:00', 'US': '20:00'} """ - data.log.msg( + data.log.debug( "Passed multiple time zones: %s, if started before first time will download at specified times" % str(download_by_zone) ) @@ -160,7 +160,7 @@ def manage_download_given_dict_of_instrument_codes( if download_time_manager.finished_downloading_everything(): ## NOTE this means we could go beyond the STOP time in the report, since this i ## happening outside of the python process manager - data.log.msg("All instruments downloaded today, finished") + data.log.debug("All instruments downloaded today, finished") break ## Something to download - this will return the first if more than one @@ -170,7 +170,7 @@ def manage_download_given_dict_of_instrument_codes( region, ) = download_time_manager.list_of_instruments_and_region_to_download_now() - data.log.msg( + data.log.debug( "Now it's time to download region %s: %s" % (region, str(list_of_instruments_to_download_now)) ) @@ -178,7 +178,7 @@ def manage_download_given_dict_of_instrument_codes( data, list_of_instrument_codes=list_of_instruments_to_download_now ) download_time_manager.mark_region_as_download_completed(region) - data.log.msg("Finished downloading region %s" % region) + data.log.debug("Finished downloading region %s" % region) class downloadTimeManager: @@ -414,7 +414,7 @@ def get_and_add_prices_for_frequency( if error_or_rows_added is failure: return failure - data.log.msg( + data.log.debug( "Added %d rows at frequency %s for %s" % (error_or_rows_added, frequency, str(contract_object)) ) diff --git a/sysproduction/update_sampled_contracts.py b/sysproduction/update_sampled_contracts.py index ecf04e4d9e..a61c255f6d 100644 --- a/sysproduction/update_sampled_contracts.py +++ b/sysproduction/update_sampled_contracts.py @@ -275,7 +275,7 @@ def mark_existing_contract_as_sampling( data_contracts.mark_contract_as_sampling(contract_to_add) log = contract_to_add.specific_log(data.log) - log.msg("Contract %s now sampling" % str(contract_to_add)) + log.debug("Contract %s now sampling" % str(contract_to_add)) def add_new_contract_with_sampling_on(contract_to_add: futuresContract, data: dataBlob): @@ -290,7 +290,7 @@ def add_new_contract_with_sampling_on(contract_to_add: futuresContract, data: da log = contract_to_add.specific_log(data.log) - log.msg("Contract %s now added to database and sampling" % str(contract_to_add)) + log.debug("Contract %s now added to database and sampling" % str(contract_to_add)) def update_expiries_and_sampling_status_for_contracts( @@ -341,7 +341,7 @@ def update_expiry_and_sampling_status_for_contract( try: broker_expiry_date = get_contract_expiry_from_broker(contract_object, data=data) except missingContract: - log.msg( + log.debug( "Can't find expiry for %s, could be a connection problem but could be because contract has already expired" % (str(contract_object)) ) @@ -350,7 +350,7 @@ def update_expiry_and_sampling_status_for_contract( unsample_reason = "Contract not available from IB" else: if broker_expiry_date == db_expiry_date: - log.msg( + log.debug( "No change to contract expiry %s to %s" % (str(contract_object), str(broker_expiry_date)) ) @@ -374,7 +374,7 @@ def update_expiry_and_sampling_status_for_contract( if turn_off_sampling: # Mark it as stop sampling in the database data_contracts.mark_contract_as_not_sampling(contract_object) - log.msg( + log.debug( "Contract %s %s so now stopped sampling" % (str(contract_object), unsample_reason), contract_date=contract_object.date_str, @@ -402,7 +402,7 @@ def update_contract_object_with_new_expiry_date( log = contract_object.specific_log(data.log) - log.msg( + log.debug( "Updated expiry of contract %s to %s" % (str(contract_object), str(broker_expiry_date)) ) diff --git a/sysproduction/update_strategy_capital.py b/sysproduction/update_strategy_capital.py index 64edb65567..c6ef7a2068 100644 --- a/sysproduction/update_strategy_capital.py +++ b/sysproduction/update_strategy_capital.py @@ -120,7 +120,7 @@ def write_allocated_strategy_capital(data: dataBlob, strategy_capital_dict: dict capital_data.update_capital_value_for_strategy( strategy_name, strategy_capital, date=date ) - data.log.msg( + data.log.debug( "Updated capital for %s to %f" % (strategy_name, strategy_capital), strategy_name=strategy_name, ) @@ -133,7 +133,7 @@ def write_allocated_strategy_margin(data: dataBlob, strategy_margin_dict: dict): strategy_name=strategy_name, margin_entry=strategy_margin ) - data.log.msg( + data.log.debug( "Updated margin for %s to %f" % (strategy_name, strategy_margin), strategy_name=strategy_name, ) diff --git a/sysproduction/update_total_capital.py b/sysproduction/update_total_capital.py index 50554c26b3..709d5a8e08 100644 --- a/sysproduction/update_total_capital.py +++ b/sysproduction/update_total_capital.py @@ -44,13 +44,13 @@ def update_margin(self): log = data.log margin_in_base_currency = broker_data.get_margin_used_in_base_currency() - log.msg("Broker margin value is %f" % margin_in_base_currency) + log.debug("Broker margin value is %f" % margin_in_base_currency) # Update total capital margin_data.add_total_margin_entry(margin_in_base_currency) margin_series = margin_data.get_series_of_total_margin() - log.msg("Recent margin\n %s" % str(margin_series.tail(10))) + log.debug("Recent margin\n %s" % str(margin_series.tail(10))) def update_capital(self): data = self.data @@ -61,7 +61,7 @@ def update_capital(self): total_account_value_in_base_currency = ( broker_data.get_total_capital_value_in_base_currency() ) - data.log.msg( + data.log.debug( "Broker account value is %f" % total_account_value_in_base_currency ) @@ -111,7 +111,7 @@ def _update_capital_with_broker_account_value_if_capital_data_exists( log.critical("Error %s whilst updating total capital" % e) return failure - log.msg("New capital is %f" % new_capital) + log.debug("New capital is %f" % new_capital) if __name__ == "__main__": diff --git a/sysquant/optimisation/pre_processing.py b/sysquant/optimisation/pre_processing.py index d1a572330c..0f08e58b15 100644 --- a/sysquant/optimisation/pre_processing.py +++ b/sysquant/optimisation/pre_processing.py @@ -136,7 +136,7 @@ def get_gross_returns_for_asset_name_before_equalisation( return self.get_unpooled_gross_returns_dict_for_asset_name(asset_name) def get_pooled_gross_returns_dict(self) -> dictOfReturnsForOptimisation: - self.log.msg("Using pooled gross returns") + self.log.debug("Using pooled gross returns") dict_of_returns = self.dict_of_returns gross_returns_dict = dict_of_returns.get_returns_for_all_assets() @@ -146,7 +146,7 @@ def get_pooled_gross_returns_dict(self) -> dictOfReturnsForOptimisation: def get_unpooled_gross_returns_dict_for_asset_name( self, asset_name: str ) -> dictOfReturnsForOptimisation: - self.log.msg("Using only returns of %s for gross returns" % asset_name) + self.log.debug("Using only returns of %s for gross returns" % asset_name) gross_returns_dict = self.dict_of_returns.get_returns_for_asset_as_single_dict( asset_name, type="gross" @@ -160,7 +160,7 @@ def get_dict_of_multiplied_cost_SR_for_asset_name( dict_of_cost_SR = self.get_dict_of_unadjusted_cost_SR_for_asset_name(asset_name) cost_multiplier = self.cost_multiplier if cost_multiplier != 1.0: - self.log.msg("Applying cost multiplier of %f" % cost_multiplier) + self.log.debug("Applying cost multiplier of %f" % cost_multiplier) dict_of_cost_SR = dict_of_cost_SR.apply_cost_multiplier( cost_multiplier=cost_multiplier ) @@ -180,7 +180,7 @@ def get_dict_of_unadjusted_cost_SR_for_asset_name( return self.get_unpooled_cost_SR_for_asset_name(asset_name) def get_dict_of_pooled_SR_costs(self, asset_name: str) -> dictOfSR: - self.log.msg("Using pooled cost SR") + self.log.debug("Using pooled cost SR") dict_of_costs = self.get_dict_of_cost_dicts_by_asset_name() @@ -189,7 +189,7 @@ def get_dict_of_pooled_SR_costs(self, asset_name: str) -> dictOfSR: return pooled_dict_of_costs def get_pooled_SR_costs_using_turnover(self, asset_name: str) -> dictOfSR: - self.log.msg("Using pooled turnover cost SR for %s" % asset_name) + self.log.debug("Using pooled turnover cost SR for %s" % asset_name) ## Costs we use are: costs for our instrument, multiplied by average turnover across instruments dict_of_costs = self.get_dict_of_cost_dicts_by_asset_name() @@ -202,7 +202,7 @@ def get_pooled_SR_costs_using_turnover(self, asset_name: str) -> dictOfSR: return costs def get_unpooled_cost_SR_for_asset_name(self, asset_name) -> dictOfSR: - self.log.msg("Using unpooled cost SR for %s" % asset_name) + self.log.debug("Using unpooled cost SR for %s" % asset_name) costs = self.dict_of_returns.get_annual_SR_dict_for_asset( asset_name, type="costs" diff --git a/systems/accounts/account_buffering_subsystem.py b/systems/accounts/account_buffering_subsystem.py index a3e529022a..0387be6005 100644 --- a/systems/accounts/account_buffering_subsystem.py +++ b/systems/accounts/account_buffering_subsystem.py @@ -72,7 +72,7 @@ def _get_buffered_subsystem_position_given_optimal_position_and_buffers( roundpositions: bool = True, ) -> pd.Series: - self.log.msg("Calculating buffered subsystem positions") + self.log.debug("Calculating buffered subsystem positions") trade_to_edge = self.config.buffer_trade_to_edge buffered_position = apply_buffer( diff --git a/systems/accounts/account_buffering_system.py b/systems/accounts/account_buffering_system.py index cfd603d83c..b21c01f31e 100644 --- a/systems/accounts/account_buffering_system.py +++ b/systems/accounts/account_buffering_system.py @@ -106,7 +106,7 @@ def _get_buffered_position_given_optimal_position_and_buffers( roundpositions: bool = True, ) -> pd.Series: - self.log.msg("Calculating buffered positions") + self.log.debug("Calculating buffered positions") trade_to_edge = self.config.buffer_trade_to_edge buffered_position = apply_buffer( diff --git a/systems/accounts/account_forecast.py b/systems/accounts/account_forecast.py index 427a841858..4050b78a02 100644 --- a/systems/accounts/account_forecast.py +++ b/systems/accounts/account_forecast.py @@ -178,7 +178,7 @@ def pandl_for_instrument_forecast( """ - self.log.msg( + self.log.debug( "Calculating pandl for instrument forecast for %s %s" % (instrument_code, rule_variation_name), instrument_code=instrument_code, diff --git a/systems/accounts/account_instruments.py b/systems/accounts/account_instruments.py index bdea58756a..f4c6f22cb5 100644 --- a/systems/accounts/account_instruments.py +++ b/systems/accounts/account_instruments.py @@ -40,7 +40,7 @@ def pandl_for_instrument( 0.13908407620762306 """ - self.log.msg( + self.log.debug( "Calculating pandl for instrument for %s" % instrument_code, instrument_code=instrument_code, ) @@ -88,7 +88,7 @@ def _pandl_for_instrument_with_positions( 0.13908407620762306 """ - self.log.msg( + self.log.debug( "Calculating pandl for instrument for %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/systems/accounts/account_subsystem.py b/systems/accounts/account_subsystem.py index 0bad50ca3f..a89569bfd7 100644 --- a/systems/accounts/account_subsystem.py +++ b/systems/accounts/account_subsystem.py @@ -82,7 +82,7 @@ def pandl_for_subsystem( 0.23422378634127036 """ - self.log.msg( + self.log.debug( "Calculating pandl for subsystem for instrument %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/systems/accounts/account_with_multiplier.py b/systems/accounts/account_with_multiplier.py index 6b0235cd40..09c1f922bd 100644 --- a/systems/accounts/account_with_multiplier.py +++ b/systems/accounts/account_with_multiplier.py @@ -57,7 +57,7 @@ def pandl_for_instrument_with_multiplier( """ - self.log.msg( + self.log.debug( "Calculating pandl for instrument for %s with capital multiplier" % instrument_code, instrument_code=instrument_code, diff --git a/systems/basesystem.py b/systems/basesystem.py index 102c97ec79..2b1e042c90 100644 --- a/systems/basesystem.py +++ b/systems/basesystem.py @@ -260,7 +260,7 @@ def _remove_instruments_from_instrument_list( days_required=days_required, ) - self.log.msg( + self.log.debug( "Following instruments removed entirely from sim: %s" % str(list_of_instruments_to_remove) ) @@ -300,7 +300,7 @@ def get_list_of_markets_not_trading_but_with_data( set(instrument_list).intersection(set(not_trading)) ) - self.log.msg( + self.log.debug( "Following instruments marked as not trading %s" % str(not_trading_in_instrument_list) ) @@ -349,7 +349,7 @@ def get_list_of_duplicate_instruments_to_remove(self): ) duplicate_list.sort() if len(duplicate_list) > 0: - self.log.msg( + self.log.debug( "Following instruments are 'duplicate_markets' %s " % str(duplicate_list) ) @@ -360,7 +360,7 @@ def get_list_of_ignored_instruments_to_remove(self) -> list: ignore_instruments = get_list_of_ignored_instruments_in_config(self.config) ignore_instruments.sort() if len(ignore_instruments) > 0: - self.log.msg( + self.log.debug( "Following instruments are marked as 'ignore_instruments': not included: %s" % str(ignore_instruments) ) @@ -374,7 +374,7 @@ def get_list_of_markets_with_trading_restrictions(self) -> list: trading_restrictions.sort() if len(trading_restrictions) > 0: ## will only log once as cached - self.log.msg( + self.log.debug( "Following instruments have restricted trading: %s " % str(trading_restrictions) ) @@ -385,7 +385,7 @@ def get_list_of_bad_markets(self) -> list: bad_markets.sort() if len(bad_markets) > 0: ## will only log once as cached - self.log.msg( + self.log.debug( "Following instruments are marked as 'bad_markets': %s" % str(bad_markets) ) @@ -405,7 +405,7 @@ def get_list_of_short_history(self, days_required: int = 750) -> list: too_short.sort() if len(too_short) > 0: - self.log.msg( + self.log.debug( "Following instruments have insufficient history: %s" % str(too_short) ) diff --git a/systems/buffering.py b/systems/buffering.py index c01cbc2092..c5675cdb9c 100644 --- a/systems/buffering.py +++ b/systems/buffering.py @@ -42,7 +42,7 @@ def calculate_buffers( log: pst_logger = logtoscreen(""), ) -> pd.Series: - log.msg( + log.debug( "Calculating buffers for %s" % instrument_code, instrument_code=instrument_code, ) @@ -50,7 +50,7 @@ def calculate_buffers( buffer_method = config.buffer_method if buffer_method == "forecast": - log.msg( + log.debug( "Calculating forecast method buffers for %s" % instrument_code, instrument_code=instrument_code, ) @@ -68,14 +68,14 @@ def calculate_buffers( ) elif buffer_method == "position": - log.msg( + log.debug( "Calculating position method buffer for %s" % instrument_code, instrument_code=instrument_code, ) buffer = get_position_method_buffer(config=config, position=position) elif buffer_method == "none": - log.msg( + log.debug( "None method, no buffering for %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/systems/forecast_combine.py b/systems/forecast_combine.py index 9f1dddd2c8..f6840b1079 100755 --- a/systems/forecast_combine.py +++ b/systems/forecast_combine.py @@ -85,7 +85,7 @@ def get_combined_forecast(self, instrument_code: str) -> pd.Series: 2015-12-10 21 2015-12-11 21 """ - self.log.msg( + self.log.debug( "Calculating combined forecast for %s" % (instrument_code), instrument_code=instrument_code, ) @@ -234,7 +234,7 @@ def get_unsmoothed_forecast_weights(self, instrument_code: str): 2015-12-10 0.5 0.5 2015-12-11 0.5 0.5 """ - self.log.msg( + self.log.debug( "Calculating forecast weights for %s" % (instrument_code), instrument_code=instrument_code, ) @@ -819,7 +819,7 @@ def _cheap_trading_rules_generic( self.log.warn(error_msg) else: - self.log.msg( + self.log.debug( "Only this set of rules %s is cheap enough to trade for %s" % (str(cheap_rule_list), instrument_code), instrument_code=instrument_code, @@ -1329,7 +1329,7 @@ def _get_forecast_mapping_function(self, instrument_code): b_param=configuration["b_param"], capped_value=forecast_cap, ) - self.log.msg( + self.log.debug( "Applying threshold mapping for %s threshold %.2f" % (instrument_code, configuration["threshold"]), instrument_code=instrument_code, @@ -1339,7 +1339,7 @@ def _get_forecast_mapping_function(self, instrument_code): # just use the default, applying capping post_process_func = _cap_combined_forecast kwargs = dict(forecast_cap=forecast_cap, forecast_floor=forecast_floor) - self.log.msg( + self.log.debug( "No mapping applied for %s" % instrument_code, instrument_code=instrument_code, ) @@ -1392,20 +1392,20 @@ def _get_fixed_weights_from_config( if instrument_code in forecast_weights_config: # nested dict fixed_weights = forecast_weights_config[instrument_code] - log.msg( + log.debug( "Nested dict of forecast weights for %s %s: weights different by instrument" % (instrument_code, str(fixed_weights)) ) elif config_is_auto_group(forecast_weights_config): ## autogrouping - log.msg("Auto grouping of weights for %s" % instrument_code) + log.debug("Auto grouping of weights for %s" % instrument_code) fixed_weights = _get_forecast_weights_for_instrument_with_autogrouping( forecast_weights_config=forecast_weights_config, expensive_trading_rules_post_processing=expensive_trading_rules_post_processing, ) else: fixed_weights = forecast_weights_config - log.msg( + log.debug( "Non-nested dict of forecast weights for %s %s: weights the same for all instruments" % (instrument_code, str(fixed_weights)) ) @@ -1491,7 +1491,7 @@ def _get_fixed_fdm_scalar_value_from_config( ) if error_msg == "": - log.msg( + log.debug( "Using fixed FDM multiplier of %.3f for %s" % (fixed_div_mult, instrument_code), instrument_code=instrument_code, diff --git a/systems/forecast_scale_cap.py b/systems/forecast_scale_cap.py index 8862a2546e..872cc059d3 100644 --- a/systems/forecast_scale_cap.py +++ b/systems/forecast_scale_cap.py @@ -56,7 +56,7 @@ def get_capped_forecast( 2015-12-11 0.200000 """ - self.log.msg( + self.log.debug( "Calculating capped forecast for %s %s" % (instrument_code, rule_variation_name), instrument_code=instrument_code, @@ -303,7 +303,7 @@ def _get_cross_sectional_forecasts_for_instrument( ## not pooled instrument_list = [instrument_code] - self.log.msg( + self.log.debug( "Getting cross sectional forecasts for scalar calculation for %s over %s" % (rule_variation_name, ", ".join(instrument_list)) ) diff --git a/systems/forecasting.py b/systems/forecasting.py index c1003cc5bf..4a3005299d 100644 --- a/systems/forecasting.py +++ b/systems/forecasting.py @@ -89,7 +89,7 @@ def get_raw_forecast( system = self.parent - self.log.msg( + self.log.debug( "Calculating raw forecast %s for %s" % (instrument_code, rule_variation_name), instrument_code=instrument_code, diff --git a/systems/portfolio.py b/systems/portfolio.py index 27ca08a444..924e92ddd6 100644 --- a/systems/portfolio.py +++ b/systems/portfolio.py @@ -85,7 +85,7 @@ def get_actual_position(self, instrument_code: str) -> pd.Series: KEY OUTPUT """ - self.log.msg( + self.log.debug( "Calculating actual position for %s" % instrument_code, instrument_code=instrument_code, ) @@ -108,7 +108,7 @@ def get_actual_buffers_for_position(self, instrument_code: str) -> pd.DataFrame: KEY OUTPUT """ - self.log.msg( + self.log.debug( "Calculating actual buffers for position for %s" % instrument_code, instrument_code=instrument_code, ) @@ -202,7 +202,7 @@ def get_notional_position(self, instrument_code: str) -> pd.Series: """ - self.log.msg( + self.log.debug( "Calculating notional position for %s" % instrument_code, instrument_code=instrument_code, ) @@ -535,7 +535,7 @@ def get_raw_fixed_instrument_weights(self) -> pd.DataFrame: 2015-12-11 0.333333 0.333333 0.333333 """ - self.log.msg("Calculating raw instrument weights") + self.log.debug("Calculating raw instrument weights") instrument_weights_dict = self.get_fixed_instrument_weights_from_config() # Now we have a dict, fixed_weights. @@ -791,7 +791,7 @@ def config_allocates_zero_instrument_weights_to_these_instruments( ) if len(allocate_zero_instrument_weights_to_these_instruments) > 0: - self.log.msg( + self.log.debug( "Following instruments will have zero weight in optimisation of instrument weights as configured zero or auto removal of configured bad%s" % str(allocate_zero_instrument_weights_to_these_instruments) ) @@ -810,7 +810,7 @@ def instruments_without_data_or_weights(self) -> list: if empty ] - self.log.msg( + self.log.debug( "Following instruments will have zero weight in optimisation of instrument weights as they have no positions (possibly too expensive?) %s" % str(list_of_empty_markets) ) @@ -942,7 +942,7 @@ def get_risk_scalar(self) -> pd.Series: "risk_overlay" ) if risk_overlay_config is arg_not_supplied: - self.log.msg("No risk overlay in config: won't apply risk scaling") + self.log.debug("No risk overlay in config: won't apply risk scaling") return 1.0 normal_risk = self.get_portfolio_risk_for_original_positions() diff --git a/systems/positionsizing.py b/systems/positionsizing.py index 599c3280a0..739ee41aa6 100644 --- a/systems/positionsizing.py +++ b/systems/positionsizing.py @@ -114,7 +114,7 @@ def get_subsystem_position(self, instrument_code: str) -> pd.Series: 2015-12-11 2.544598 """ - self.log.msg( + self.log.debug( "Calculating subsystem position for %s" % instrument_code, instrument_code=instrument_code, ) @@ -191,7 +191,7 @@ def get_volatility_scalar(self, instrument_code: str) -> pd.Series: 2015-12-11 10.344278 """ - self.log.msg( + self.log.debug( "Calculating volatility scalar for %s" % instrument_code, instrument_code=instrument_code, ) @@ -231,7 +231,7 @@ def get_instrument_value_vol(self, instrument_code: str) -> pd.Series: """ - self.log.msg( + self.log.debug( "Calculating instrument value vol for %s" % instrument_code, instrument_code=instrument_code, ) @@ -273,7 +273,7 @@ def get_instrument_currency_vol(self, instrument_code: str) -> pd.Series: """ - self.log.msg( + self.log.debug( "Calculating instrument currency vol for %s" % instrument_code, instrument_code=instrument_code, ) @@ -456,7 +456,7 @@ def get_vol_target_dict(self) -> dict: """ - self.log.msg("Getting vol target") + self.log.debug("Getting vol target") percentage_vol_target = self.get_percentage_vol_target() diff --git a/systems/provided/dynamic_small_system_optimise/accounts_stage.py b/systems/provided/dynamic_small_system_optimise/accounts_stage.py index fdde5408e9..b7ce5059f4 100644 --- a/systems/provided/dynamic_small_system_optimise/accounts_stage.py +++ b/systems/provided/dynamic_small_system_optimise/accounts_stage.py @@ -41,7 +41,7 @@ def pandl_for_optimised_instrument( self, instrument_code: str, delayfill: bool = True ) -> accountCurve: - self.log.msg( + self.log.debug( "Calculating pandl for instrument for %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/systems/provided/dynamic_small_system_optimise/optimisation.py b/systems/provided/dynamic_small_system_optimise/optimisation.py index 55f52df3ca..9c1a54cc24 100644 --- a/systems/provided/dynamic_small_system_optimise/optimisation.py +++ b/systems/provided/dynamic_small_system_optimise/optimisation.py @@ -124,12 +124,12 @@ def is_tracking_error_of_prior_smaller_than_buffer(self) -> bool: tracking_error_smaller_than_buffer = tracking_error < tracking_error_buffer if tracking_error_smaller_than_buffer: - self.log.msg( + self.log.debug( "Tracking error of current positions vs unrounded optimal is %.4f smaller than buffer %4.f, no trades needed" % (tracking_error, tracking_error_buffer) ) else: - self.log.msg( + self.log.debug( "Tracking error of current positions vs unrounded optimal is %.4f larger than buffer %.4f" % (tracking_error, tracking_error_buffer) ) @@ -175,7 +175,7 @@ def log_optimised_results( tracking_error = self.tracking_error_against_optimal(optimised_weights_as_np) costs = self.calculate_costs(optimised_weights_as_np) - self.log.msg( + self.log.debug( "%s weights, tracking error vs unrounded optimal %.4f costs %.4f" % (label, tracking_error, costs) ) @@ -197,7 +197,7 @@ def adjust_weights_for_size_of_tracking_error( tracking_error_of_prior=tracking_error_of_prior, speed_control=speed_control ) - self.log.msg( + self.log.debug( "Tracking error current vs optimised %.4f vs buffer %.4f doing %.3f of adjusting trades (0 means no trade)" % (tracking_error_of_prior, speed_control.tracking_error_buffer, adj_factor) ) diff --git a/systems/provided/dynamic_small_system_optimise/optimised_positions_stage.py b/systems/provided/dynamic_small_system_optimise/optimised_positions_stage.py index 3cafd8fff9..812c06cc36 100644 --- a/systems/provided/dynamic_small_system_optimise/optimised_positions_stage.py +++ b/systems/provided/dynamic_small_system_optimise/optimised_positions_stage.py @@ -51,7 +51,7 @@ def get_optimised_weights_df(self) -> seriesOfPortfolioWeights: @diagnostic() def get_optimised_position_df(self) -> pd.DataFrame: - self.log.msg("Optimising positions for small capital: may take a while!") + self.log.debug("Optimising positions for small capital: may take a while!") common_index = list(self.common_index()) progress = progressBar( len(common_index), @@ -62,7 +62,7 @@ def get_optimised_position_df(self) -> pd.DataFrame: previous_optimal_positions = portfolioWeights.allzeros(self.instrument_list()) position_list = [] for relevant_date in common_index: - # self.log.msg(relevant_date) + # self.log.debug(relevant_date) optimal_positions = self.get_optimal_positions_with_fixed_contract_values( relevant_date, previous_positions=previous_optimal_positions ) diff --git a/systems/provided/rob_system/forecastScaleCap.py b/systems/provided/rob_system/forecastScaleCap.py index 0b29e15935..a567f1e39d 100644 --- a/systems/provided/rob_system/forecastScaleCap.py +++ b/systems/provided/rob_system/forecastScaleCap.py @@ -6,7 +6,7 @@ class volAttenForecastScaleCap(ForecastScaleCap): @diagnostic() def get_vol_quantile_points(self, instrument_code): ## More properly this would go in raw data perhaps - self.log.msg("Calculating vol quantile for %s" % instrument_code) + self.log.debug("Calculating vol quantile for %s" % instrument_code) daily_vol = self.parent.rawdata.get_daily_percentage_volatility(instrument_code) ten_year_vol = daily_vol.rolling(2500, min_periods=10).mean() normalised_vol = daily_vol / ten_year_vol diff --git a/systems/rawdata.py b/systems/rawdata.py index 8890e73f59..7faa783ba3 100644 --- a/systems/rawdata.py +++ b/systems/rawdata.py @@ -54,7 +54,7 @@ def get_daily_prices(self, instrument_code) -> pd.Series: KEY OUTPUT """ - self.log.msg( + self.log.debug( "Calculating daily prices for %s" % instrument_code, instrument_code=instrument_code, ) @@ -70,7 +70,7 @@ def get_daily_prices(self, instrument_code) -> pd.Series: @input def get_natural_frequency_prices(self, instrument_code: str) -> pd.Series: - self.log.msg( + self.log.debug( "Retrieving natural prices for %s" % instrument_code, instrument_code=instrument_code, ) @@ -184,7 +184,7 @@ def daily_returns_volatility(self, instrument_code: str) -> pd.Series: 2015-12-11 0.058626 """ - self.log.msg( + self.log.debug( "Calculating daily volatility for %s" % instrument_code, instrument_code=instrument_code, ) @@ -281,7 +281,7 @@ def get_daily_vol_normalised_returns(self, instrument_code: str) -> pd.Series: 2015-12-10 -1.219510 2015-12-11 1.985413 """ - self.log.msg( + self.log.debug( "Calculating normalised return for %s" % instrument_code, instrument_code=instrument_code, ) @@ -304,7 +304,7 @@ def get_cumulative_daily_vol_normalised_returns( :return: pd.Series """ - self.log.msg( + self.log.debug( "Calculating cumulative normalised return for %s" % instrument_code, instrument_code=instrument_code, ) From f1c7ea2f40e32feae5096e029ee8c640dfe85374 Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Mon, 12 Jun 2023 10:14:03 +0100 Subject: [PATCH 2/5] log.terse() -> log.info() log.warn() -> log.warning() --- dashboard/app.py | 2 +- sysbrokers/IB/config/ib_fx_config.py | 6 ++--- sysbrokers/IB/config/ib_instrument_config.py | 10 +++++---- sysbrokers/IB/ib_Fx_prices_data.py | 4 ++-- sysbrokers/IB/ib_connection.py | 2 +- .../IB/ib_futures_contract_price_data.py | 2 +- sysbrokers/IB/ib_futures_contracts_data.py | 4 ++-- sysbrokers/IB/ib_orders.py | 6 ++--- syscontrol/run_process.py | 8 ++++--- sysdata/csv/csv_adjusted_prices.py | 2 +- sysdata/csv/csv_futures_contract_prices.py | 2 +- sysdata/csv/csv_multiple_prices.py | 2 +- sysdata/csv/csv_roll_calendars.py | 2 +- sysdata/csv/csv_roll_parameters.py | 2 +- sysdata/csv/csv_spot_fx.py | 2 +- sysdata/csv/csv_spreads.py | 2 +- sysdata/data_blob.py | 2 +- sysdata/futures/adjusted_prices.py | 6 ++--- sysdata/futures/contracts.py | 8 +++---- .../futures/futures_per_contract_prices.py | 12 +++++----- sysdata/futures/instruments.py | 6 ++--- sysdata/futures/multiple_prices.py | 6 ++--- sysdata/futures/roll_calendars.py | 4 ++-- sysdata/futures/rolls_parameters.py | 8 +++---- sysdata/futures/spreads.py | 6 ++--- sysdata/fx/spotfx.py | 14 ++++++------ sysdata/mongodb/mongo_override.py | 2 +- sysdata/mongodb/mongo_spread_costs.py | 4 ++-- sysdata/production/capital.py | 6 ++--- .../production/historic_contract_positions.py | 2 +- .../production/historic_strategy_positions.py | 4 ++-- sysdata/sim/futures_sim_data.py | 2 +- sysdata/sim/sim_data.py | 4 ++-- sysdata/tools/cleaner.py | 2 +- sysexecution/algos/algo.py | 2 +- sysexecution/algos/algo_market.py | 4 +++- sysexecution/algos/algo_original_best.py | 6 +++-- sysexecution/algos/allocate_algo_to_order.py | 2 +- sysexecution/algos/common_functions.py | 2 +- .../order_stacks/contract_order_stack.py | 2 +- sysexecution/order_stacks/order_stack.py | 2 +- ...eate_broker_orders_from_contract_orders.py | 4 +++- .../stack_handler/stackHandlerCore.py | 2 +- .../strategies/strategy_order_handling.py | 4 ++-- sysinit/futures/seed_price_data_from_IB.py | 4 ++-- syslogging/adapter.py | 16 -------------- syslogging/tests/logging_tests.py | 14 ------------ sysproduction/backup_arctic_to_csv.py | 22 ++++++++++++------- .../interactive_manual_check_fx_prices.py | 2 +- .../interactive_update_roll_status.py | 2 +- sysproduction/update_fx_prices.py | 4 ++-- sysproduction/update_historical_prices.py | 8 +++---- systems/accounts/account_instruments.py | 2 +- systems/accounts/account_portfolio.py | 2 +- systems/accounts/account_with_multiplier.py | 2 +- systems/forecast_combine.py | 12 +++++----- systems/portfolio.py | 20 ++++++++--------- .../accounts_stage.py | 2 +- systems/rawdata.py | 4 ++-- 59 files changed, 145 insertions(+), 157 deletions(-) diff --git a/dashboard/app.py b/dashboard/app.py index c4afaa1040..699d183bab 100644 --- a/dashboard/app.py +++ b/dashboard/app.py @@ -316,7 +316,7 @@ def visible_on_lan() -> bool: visible = visible_on_lan() if visible: data = dataBlob() - data.log.warn( + data.log.warning( "Starting dashboard with web page visible to all - security implications!!!!" ) app.run( diff --git a/sysbrokers/IB/config/ib_fx_config.py b/sysbrokers/IB/config/ib_fx_config.py index 798481067e..9ca25993c0 100644 --- a/sysbrokers/IB/config/ib_fx_config.py +++ b/sysbrokers/IB/config/ib_fx_config.py @@ -19,7 +19,7 @@ def get_ib_config_from_file(log) -> pd.DataFrame: try: config_data = pd.read_csv(IB_CCY_CONFIG_FILE) except BaseException: - log.warn("Can't read file %s" % IB_CCY_CONFIG_FILE) + log.warning("Can't read file %s" % IB_CCY_CONFIG_FILE) config_data = missing_file return config_data @@ -28,7 +28,7 @@ def get_ib_config_from_file(log) -> pd.DataFrame: def config_info_for_code(config_data: pd.DataFrame, currency_code, log) -> ibFXConfig: new_log = log.setup(**{CURRENCY_CODE_LOG_LABEL: currency_code}) if config_data is missing_file: - new_log.warn( + new_log.warning( "Can't get IB FX config for %s as config file missing" % currency_code ) @@ -45,7 +45,7 @@ def config_info_for_code(config_data: pd.DataFrame, currency_code, log) -> ibFXC def get_list_of_codes(log, config_data: pd.DataFrame) -> list: if config_data is missing_file: - log.warn("Can't get list of fxcodes for IB as config file missing") + log.warning("Can't get list of fxcodes for IB as config file missing") return [] list_of_codes = list(config_data.CODE) diff --git a/sysbrokers/IB/config/ib_instrument_config.py b/sysbrokers/IB/config/ib_instrument_config.py index 3d7e008f13..59a0ece652 100644 --- a/sysbrokers/IB/config/ib_instrument_config.py +++ b/sysbrokers/IB/config/ib_instrument_config.py @@ -27,7 +27,7 @@ def read_ib_config_from_file(log: pst_logger = logtoscreen("")) -> IBconfig: try: df = pd.read_csv(IB_FUTURES_CONFIG_FILE) except BaseException: - log.warn("Can't read file %s" % IB_FUTURES_CONFIG_FILE) + log.warning("Can't read file %s" % IB_FUTURES_CONFIG_FILE) return missing_file return IBconfig(df) @@ -43,7 +43,7 @@ def get_instrument_object_from_config( config = read_ib_config_from_file() if config is missing_file: - new_log.warn( + new_log.warning( "Can't get config for instrument %s as IB configuration file missing" % instrument_code ) @@ -53,7 +53,9 @@ def get_instrument_object_from_config( try: assert instrument_code in list_of_instruments except: - new_log.warn("Instrument %s is not in IB configuration file" % instrument_code) + new_log.warning( + "Instrument %s is not in IB configuration file" % instrument_code + ) raise missingInstrument futures_instrument_with_ib_data = _get_instrument_object_from_valid_config( @@ -200,7 +202,7 @@ def get_instrument_list_from_ib_config( config: IBconfig, log: pst_logger = logtoscreen("") ): if config is missing_file: - log.warn("Can't get list of instruments because IB config file missing") + log.warning("Can't get list of instruments because IB config file missing") return [] instrument_list = list(config.Instrument) diff --git a/sysbrokers/IB/ib_Fx_prices_data.py b/sysbrokers/IB/ib_Fx_prices_data.py index 8b86c94c5d..2c28aed73e 100644 --- a/sysbrokers/IB/ib_Fx_prices_data.py +++ b/sysbrokers/IB/ib_Fx_prices_data.py @@ -48,7 +48,7 @@ def _get_fx_prices_without_checking(self, currency_code: str) -> fxPrices: ib_config_for_code = self._get_config_info_for_code(currency_code) except missingInstrument: log = self.log.setup(**{CURRENCY_CODE_LOG_LABEL: currency_code}) - log.warn("Can't get prices as missing IB config for %s" % currency_code) + log.warning("Can't get prices as missing IB config for %s" % currency_code) return fxPrices.create_empty() data = self._get_fx_prices_with_ib_config(currency_code, ib_config_for_code) @@ -63,7 +63,7 @@ def _get_fx_prices_with_ib_config( log = self.log.setup(**{CURRENCY_CODE_LOG_LABEL: currency_code}) if len(raw_fx_prices_as_series) == 0: - log.warn( + log.warning( "No available IB prices for %s %s" % (currency_code, str(ib_config_for_code)) ) diff --git a/sysbrokers/IB/ib_connection.py b/sysbrokers/IB/ib_connection.py index b9f9a35eff..f1ab4df610 100644 --- a/sysbrokers/IB/ib_connection.py +++ b/sysbrokers/IB/ib_connection.py @@ -111,7 +111,7 @@ def close_connection(self): # Try and disconnect IB client self.ib.disconnect() except BaseException: - self.log.warn( + self.log.warning( "Trying to disconnect IB client failed... ensure process is killed" ) diff --git a/sysbrokers/IB/ib_futures_contract_price_data.py b/sysbrokers/IB/ib_futures_contract_price_data.py index 016cbb85c5..ab9d21b082 100644 --- a/sysbrokers/IB/ib_futures_contract_price_data.py +++ b/sysbrokers/IB/ib_futures_contract_price_data.py @@ -229,7 +229,7 @@ def _get_prices_at_frequency_for_contract_object_no_checking_with_expiry_flag( ) ) except missingContract: - new_log.warn("Can't get data for %s" % str(futures_contract_object)) + new_log.warning("Can't get data for %s" % str(futures_contract_object)) raise missingData price_data = self._get_prices_at_frequency_for_ibcontract_object_no_checking( diff --git a/sysbrokers/IB/ib_futures_contracts_data.py b/sysbrokers/IB/ib_futures_contracts_data.py index f3c264f2d8..2ee1b5798f 100644 --- a/sysbrokers/IB/ib_futures_contracts_data.py +++ b/sysbrokers/IB/ib_futures_contracts_data.py @@ -100,7 +100,7 @@ def get_actual_expiry_date_for_single_contract( """ log = futures_contract.specific_log(self.log) if futures_contract.is_spread_contract(): - log.warn("Can't find expiry for multiple leg contract here") + log.warning("Can't find expiry for multiple leg contract here") raise missingContract contract_object_with_ib_data = self.get_contract_object_with_IB_data( @@ -116,7 +116,7 @@ def _get_actual_expiry_date_given_single_contract_with_ib_metadata( ) -> expiryDate: log = futures_contract_with_ib_data.specific_log(self.log) if futures_contract_with_ib_data.is_spread_contract(): - log.warn("Can't find expiry for multiple leg contract here") + log.warning("Can't find expiry for multiple leg contract here") raise missingContract expiry_date = self.ib_client.broker_get_single_contract_expiry_date( diff --git a/sysbrokers/IB/ib_orders.py b/sysbrokers/IB/ib_orders.py index 626d2ba7bb..73f77a7624 100644 --- a/sysbrokers/IB/ib_orders.py +++ b/sysbrokers/IB/ib_orders.py @@ -225,7 +225,7 @@ def _create_broker_control_order_object( instrument_code=instrument_code, ) except ibOrderCouldntCreateException: - self.log.warn( + self.log.warning( "Couldn't create order from ib returned order %s, usual behaviour for FX and equities trades" % str(trade_with_contract_from_ib) ) @@ -317,7 +317,7 @@ def _send_broker_order_to_IB(self, broker_order: brokerOrder) -> tradeWithContra limit_price=limit_price, ) if placed_broker_trade_object is missing_order: - log.warn("Couldn't submit order") + log.warning("Couldn't submit order") return missing_order log.debug("Order submitted to IB") @@ -381,7 +381,7 @@ def cancel_order_on_stack(self, broker_order: brokerOrder): self.match_db_broker_order_to_control_order_from_brokers(broker_order) ) if matched_control_order is missing_order: - log.warn("Couldn't cancel non existent order") + log.warning("Couldn't cancel non existent order") return None self.cancel_order_given_control_object(matched_control_order) diff --git a/syscontrol/run_process.py b/syscontrol/run_process.py index 8dfe5fd105..a0fd03a4e2 100644 --- a/syscontrol/run_process.py +++ b/syscontrol/run_process.py @@ -148,7 +148,7 @@ def _finish_control_process(self): result_of_finish = self.data_control.finish_process(self.process_name) if result_of_finish is failure: - self.log.warn( + self.log.warning( "Process %s won't finish in process control as already close: weird!" % self.process_name ) @@ -300,11 +300,13 @@ def _check_if_okay_to_wait_before_starting_process( log = process_to_run.log if okay_to_run is process_running: - log.warn("Can't start process %s at all since already running" % process_name) + log.warning( + "Can't start process %s at all since already running" % process_name + ) return False elif okay_to_run is process_stop: - log.warn( + log.warning( "Can't start process %s at all since STOPPED by control" % process_name ) return False diff --git a/sysdata/csv/csv_adjusted_prices.py b/sysdata/csv/csv_adjusted_prices.py index 3359d3d5bb..442e6ef385 100644 --- a/sysdata/csv/csv_adjusted_prices.py +++ b/sysdata/csv/csv_adjusted_prices.py @@ -49,7 +49,7 @@ def _get_adjusted_prices_without_checking( try: instrpricedata = pd_readcsv(filename) except OSError: - self.log.warn("Can't find adjusted price file %s" % filename) + self.log.warning("Can't find adjusted price file %s" % filename) return futuresAdjustedPrices.create_empty() instrpricedata.columns = ["price"] diff --git a/sysdata/csv/csv_futures_contract_prices.py b/sysdata/csv/csv_futures_contract_prices.py index 3d7a2af553..780c8e462e 100644 --- a/sysdata/csv/csv_futures_contract_prices.py +++ b/sysdata/csv/csv_futures_contract_prices.py @@ -92,7 +92,7 @@ def _get_prices_at_frequency_for_contract_object_no_checking( ) except OSError: log = futures_contract_object.log(self.log) - log.warn("Can't find adjusted price file %s" % filename) + log.warning("Can't find adjusted price file %s" % filename) return futuresContractPrices.create_empty() instrpricedata = instrpricedata.groupby(level=0).last() diff --git a/sysdata/csv/csv_multiple_prices.py b/sysdata/csv/csv_multiple_prices.py index 3eb14443da..bc2016f279 100644 --- a/sysdata/csv/csv_multiple_prices.py +++ b/sysdata/csv/csv_multiple_prices.py @@ -84,7 +84,7 @@ def _read_instrument_prices(self, instrument_code: str) -> pd.DataFrame: try: instr_all_price_data = pd_readcsv(filename, date_index_name=DATE_INDEX_NAME) except OSError: - self.log.warn( + self.log.warning( "Can't find multiple price file %s or error reading" % filename, instrument_code=instrument_code, ) diff --git a/sysdata/csv/csv_roll_calendars.py b/sysdata/csv/csv_roll_calendars.py index 7dc07708e9..770b8a5d9c 100644 --- a/sysdata/csv/csv_roll_calendars.py +++ b/sysdata/csv/csv_roll_calendars.py @@ -48,7 +48,7 @@ def _get_roll_calendar_without_checking(self, instrument_code: str) -> rollCalen roll_calendar = pd_readcsv(filename, date_index_name=DATE_INDEX_NAME) except OSError: - self.log.warn("Can't find roll calendar file %s" % filename) + self.log.warning("Can't find roll calendar file %s" % filename) return rollCalendar.create_empty() roll_calendar = rollCalendar(roll_calendar) diff --git a/sysdata/csv/csv_roll_parameters.py b/sysdata/csv/csv_roll_parameters.py index 49645903fd..31af5fc2fb 100644 --- a/sysdata/csv/csv_roll_parameters.py +++ b/sysdata/csv/csv_roll_parameters.py @@ -103,7 +103,7 @@ def _add_roll_parameters_without_checking_for_existing_entry( ) all_parameters.write_to_file(self.config_file) - self.log.warn( + self.log.warning( "*** WRITTEN NEW ROLL PARAMETERS TO %s - copy to /data/futures/csvconfig/rollconfig.csv NOW ***" % self.config_file ) diff --git a/sysdata/csv/csv_spot_fx.py b/sysdata/csv/csv_spot_fx.py index 57ec69195b..563107e4ab 100644 --- a/sysdata/csv/csv_spot_fx.py +++ b/sysdata/csv/csv_spot_fx.py @@ -84,7 +84,7 @@ def _get_fx_prices_without_checking(self, code: str) -> fxPrices: filename, date_format=date_format, date_index_name=date_column ) except OSError: - self.log.warn( + self.log.warning( "Can't find currency price file %s" % filename, **{CURRENCY_CODE_LOG_LABEL: code}, ) diff --git a/sysdata/csv/csv_spreads.py b/sysdata/csv/csv_spreads.py index 881e50226b..47b7e67bc6 100644 --- a/sysdata/csv/csv_spreads.py +++ b/sysdata/csv/csv_spreads.py @@ -50,7 +50,7 @@ def _get_spreads_without_checking( try: spreads_from_pd = pd_readcsv(filename, date_index_name=DATE_INDEX_NAME) except OSError: - self.log.warn("Can't find spread file %s" % filename) + self.log.warning("Can't find spread file %s" % filename) return spreadsForInstrument() spreads_as_series = pd.Series(spreads_from_pd[SPREAD_COLUMN_NAME]) diff --git a/sysdata/data_blob.py b/sysdata/data_blob.py index d3bf8a552c..ec6d474cad 100644 --- a/sysdata/data_blob.py +++ b/sysdata/data_blob.py @@ -192,7 +192,7 @@ def _get_csv_paths_for_class(self, class_object) -> str: datapath = csv_data_paths.get(class_name, "") if datapath == "": - self.log.warn( + self.log.warning( "No key for %s in csv_data_paths, will use defaults (may break in production, should be fine in sim)" % class_name ) diff --git a/sysdata/futures/adjusted_prices.py b/sysdata/futures/adjusted_prices.py index 9caa3f7e54..70615f2633 100644 --- a/sysdata/futures/adjusted_prices.py +++ b/sysdata/futures/adjusted_prices.py @@ -45,14 +45,14 @@ def delete_adjusted_prices(self, instrument_code: str, are_you_sure: bool = Fals self._delete_adjusted_prices_without_any_warning_be_careful( instrument_code ) - self.log.terse( + self.log.info( "Deleted adjusted price data for %s" % instrument_code, instrument_code=instrument_code, ) else: # doesn't exist anyway - self.log.warn( + self.log.warning( "Tried to delete non existent adjusted prices for %s" % instrument_code, instrument_code=instrument_code, @@ -89,7 +89,7 @@ def add_adjusted_prices( instrument_code, adjusted_price_data ) - self.log.terse( + self.log.info( "Added data for instrument %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/sysdata/futures/contracts.py b/sysdata/futures/contracts.py index e8587dc4d8..f4263f97d3 100644 --- a/sysdata/futures/contracts.py +++ b/sysdata/futures/contracts.py @@ -54,10 +54,10 @@ def delete_contract_data( self._delete_contract_data_without_any_warning_be_careful( instrument_code, contract_date ) - log.terse("Deleted contract %s/%s" % (instrument_code, contract_date)) + log.info("Deleted contract %s/%s" % (instrument_code, contract_date)) else: # doesn't exist anyway - log.warn("Tried to delete non existent contract") + log.warning("Tried to delete non existent contract") else: log.error("You need to call delete_contract_data with a flag to be sure") @@ -88,14 +88,14 @@ def add_contract_data( if ignore_duplication: pass else: - log.warn( + log.warning( "There is already %s in the data, you have to delete it first" % (contract_object.key) ) return None self._add_contract_object_without_checking_for_existing_entry(contract_object) - log.terse("Added contract %s %s" % (instrument_code, contract_date)) + log.info("Added contract %s %s" % (instrument_code, contract_date)) def get_list_of_contract_dates_for_instrument_code( self, instrument_code: str, allow_expired: bool = False diff --git a/sysdata/futures/futures_per_contract_prices.py b/sysdata/futures/futures_per_contract_prices.py index 2d35b1e2c2..fb65b0fe98 100644 --- a/sysdata/futures/futures_per_contract_prices.py +++ b/sysdata/futures/futures_per_contract_prices.py @@ -301,7 +301,7 @@ def write_merged_prices_for_contract_object( if not_ignoring_duplication: if self.has_merged_price_data_for_contract(futures_contract_object): log = futures_contract_object.log(self.log) - log.warn( + log.warning( "There is already existing data for %s" % futures_contract_object.key ) @@ -332,7 +332,7 @@ def write_prices_at_frequency_for_contract_object( contract_object=futures_contract_object, frequency=frequency ): log = futures_contract_object.log(self.log) - log.warn( + log.warning( "There is already existing data for %s" % futures_contract_object.key ) @@ -390,7 +390,9 @@ def update_prices_at_frequency_for_contract( new_log.debug("No existing or additional data") return 0 else: - new_log.debug("No additional data since %s " % str(old_prices.index[-1])) + new_log.debug( + "No additional data since %s " % str(old_prices.index[-1]) + ) return 0 # We have guaranteed no duplication @@ -428,7 +430,7 @@ def delete_merged_prices_for_contract_object( ) else: log = futures_contract_object.log(self.log) - log.warn("Tried to delete non existent contract") + log.warning("Tried to delete non existent contract") def delete_prices_at_frequency_for_contract_object( self, @@ -453,7 +455,7 @@ def delete_prices_at_frequency_for_contract_object( ) else: log = futures_contract_object.log(self.log) - log.warn( + log.warning( "Tried to delete non existent contract at frequency %s" % frequency ) diff --git a/sysdata/futures/instruments.py b/sysdata/futures/instruments.py index d69fd04934..6b7b239e2c 100644 --- a/sysdata/futures/instruments.py +++ b/sysdata/futures/instruments.py @@ -101,11 +101,11 @@ def delete_instrument_data(self, instrument_code: str, are_you_sure: bool = Fals self._delete_instrument_data_without_any_warning_be_careful( instrument_code ) - self.log.terse("Deleted instrument object %s" % instrument_code) + self.log.info("Deleted instrument object %s" % instrument_code) else: # doesn't exist anyway - self.log.warn("Tried to delete non existent instrument") + self.log.warning("Tried to delete non existent instrument") else: self.log.error( "You need to call delete_instrument_data with a flag to be sure" @@ -137,7 +137,7 @@ def add_instrument_data( self._add_instrument_data_without_checking_for_existing_entry(instrument_object) - self.log.terse("Added instrument object %s" % instrument_object.instrument_code) + self.log.info("Added instrument object %s" % instrument_object.instrument_code) def get_list_of_instruments(self): raise NotImplementedError(USE_CHILD_CLASS_ERROR) diff --git a/sysdata/futures/multiple_prices.py b/sysdata/futures/multiple_prices.py index 4b3fb28bc3..fd7b6a9128 100644 --- a/sysdata/futures/multiple_prices.py +++ b/sysdata/futures/multiple_prices.py @@ -56,13 +56,13 @@ def delete_multiple_prices( self._delete_multiple_prices_without_any_warning_be_careful( instrument_code ) - log.terse("Deleted multiple price data for %s" % instrument_code) + log.info("Deleted multiple price data for %s" % instrument_code) return success else: # doesn't exist anyway - log.warn( + log.warning( "Tried to delete non existent multiple prices for %s" % instrument_code ) @@ -98,7 +98,7 @@ def add_multiple_prices( instrument_code, multiple_price_data ) - log.terse("Added data for instrument %s" % instrument_code) + log.info("Added data for instrument %s" % instrument_code) return success diff --git a/sysdata/futures/roll_calendars.py b/sysdata/futures/roll_calendars.py index f6f3c090f3..e47eb44311 100644 --- a/sysdata/futures/roll_calendars.py +++ b/sysdata/futures/roll_calendars.py @@ -40,11 +40,11 @@ def delete_roll_calendar(self, instrument_code: str, are_you_sure=False): self._delete_roll_calendar_data_without_any_warning_be_careful( instrument_code ) - self.log.terse("Deleted roll calendar for %s" % instrument_code) + self.log.info("Deleted roll calendar for %s" % instrument_code) else: # doesn't exist anyway - self.log.warn( + self.log.warning( "Tried to delete roll calendar for non existent instrument code %s" % instrument_code ) diff --git a/sysdata/futures/rolls_parameters.py b/sysdata/futures/rolls_parameters.py index 2b97b30387..9f0d29dcdc 100644 --- a/sysdata/futures/rolls_parameters.py +++ b/sysdata/futures/rolls_parameters.py @@ -47,11 +47,11 @@ def delete_roll_parameters(self, instrument_code: str, are_you_sure: bool = Fals self._delete_roll_parameters_data_without_any_warning_be_careful( instrument_code ) - self.log.terse("Deleted roll parameters for %s" % instrument_code) + self.log.info("Deleted roll parameters for %s" % instrument_code) else: # doesn't exist anyway - self.log.warn( + self.log.warning( "Tried to delete roll parameters for non existent instrument code %s" % instrument_code ) @@ -73,7 +73,7 @@ def add_roll_parameters( if ignore_duplication: pass else: - raise self.log.warn( + raise self.log.warning( "There is already %s in the data, you have to delete it first" % instrument_code ) @@ -82,7 +82,7 @@ def add_roll_parameters( instrument_code, roll_parameters ) - self.log.terse("Added roll parameters for instrument %s" % instrument_code) + self.log.info("Added roll parameters for instrument %s" % instrument_code) def is_code_in_data(self, instrument_code: str) -> bool: if instrument_code in self.get_list_of_instruments(): diff --git a/sysdata/futures/spreads.py b/sysdata/futures/spreads.py index 2d3c916b76..df8d1e36e2 100644 --- a/sysdata/futures/spreads.py +++ b/sysdata/futures/spreads.py @@ -38,14 +38,14 @@ def delete_spreads(self, instrument_code: str, are_you_sure: bool = False): if are_you_sure: if self.is_code_in_data(instrument_code): self._delete_spreads_without_any_warning_be_careful(instrument_code) - self.log.terse( + self.log.info( "Deleted spread data for %s" % instrument_code, instrument_code=instrument_code, ) else: # doesn't exist anyway - self.log.warn( + self.log.warning( "Tried to delete non existent spreads for %s" % instrument_code, instrument_code=instrument_code, ) @@ -79,7 +79,7 @@ def add_spreads( self._add_spreads_without_checking_for_existing_entry(instrument_code, spreads) - self.log.terse( + self.log.info( "Added data for instrument %s" % instrument_code, instrument_code=instrument_code, ) diff --git a/sysdata/fx/spotfx.py b/sysdata/fx/spotfx.py index 2d5e44e650..e8ad0f7ed0 100644 --- a/sysdata/fx/spotfx.py +++ b/sysdata/fx/spotfx.py @@ -84,7 +84,7 @@ def _get_fx_prices_for_inversion(self, fx_code: str) -> fxPrices: raw_fx_data = self._get_fx_prices_vs_default(currency2) if raw_fx_data.empty: log = self.log.setup(**{CURRENCY_CODE_LOG_LABEL: fx_code}) - log.warn( + log.warning( "Data for %s is missing, needed to calculate %s" % (currency2 + DEFAULT_CURRENCY, DEFAULT_CURRENCY + currency2) ) @@ -130,7 +130,7 @@ def _get_fx_prices_vs_default(self, currency1: str) -> fxPrices: def _get_fx_prices(self, code: str) -> fxPrices: if not self.is_code_in_data(code): log = self.log.setup(**{CURRENCY_CODE_LOG_LABEL: code}) - log.warn("Currency %s is missing from list of FX data" % code) + log.warning("Currency %s is missing from list of FX data" % code) return fxPrices.create_empty() @@ -144,13 +144,13 @@ def delete_fx_prices(self, code: str, are_you_sure=False): if are_you_sure: if self.is_code_in_data(code): self._delete_fx_prices_without_any_warning_be_careful(code) - log.terse("Deleted fx price data for %s" % code) + log.info("Deleted fx price data for %s" % code) else: # doesn't exist anyway - log.warn("Tried to delete non existent fx prices for %s" % code) + log.warning("Tried to delete non existent fx prices for %s" % code) else: - log.warn("You need to call delete_fx_prices with a flag to be sure") + log.warning("You need to call delete_fx_prices with a flag to be sure") def is_code_in_data(self, code: str) -> bool: if code in self.get_list_of_fxcodes(): @@ -166,14 +166,14 @@ def add_fx_prices( if ignore_duplication: pass else: - log.warn( + log.warning( "There is already %s in the data, you have to delete it first, or set ignore_duplication=True, or use update_fx_prices" % code ) return None self._add_fx_prices_without_checking_for_existing_entry(code, fx_price_data) - log.terse("Added fx data for code %s" % code) + log.info("Added fx data for code %s" % code) def update_fx_prices( self, code: str, new_fx_prices: fxPrices, check_for_spike=True diff --git a/sysdata/mongodb/mongo_override.py b/sysdata/mongodb/mongo_override.py index cc44441dc6..8a4e92018e 100644 --- a/sysdata/mongodb/mongo_override.py +++ b/sysdata/mongodb/mongo_override.py @@ -83,7 +83,7 @@ def _get_dict_of_items_with_overrides_for_type(self, override_type: str) -> dict return result_dict_of_overrides def _delete_all_overrides_without_checking(self): - self.log.warn("DELETING ALL OVERRIDES!") + self.log.warning("DELETING ALL OVERRIDES!") all_keys = self.mongo_data.get_list_of_all_dicts() for key in all_keys: self.mongo_data.delete_data_without_any_warning(key) diff --git a/sysdata/mongodb/mongo_spread_costs.py b/sysdata/mongodb/mongo_spread_costs.py index d5997c15c4..1778ed5f8c 100644 --- a/sysdata/mongodb/mongo_spread_costs.py +++ b/sysdata/mongodb/mongo_spread_costs.py @@ -48,14 +48,14 @@ def get_spread_cost(self, instrument_code: str) -> float: instrument_code ) except missingData: - self.log.warn( + self.log.warning( "No spread cost in database for %s, using 0" % instrument_code ) return 0.0 spread_cost = _cost_value_from_dict(result_dict) if np.isnan(spread_cost): - self.log.warn("No valid spread cost for %s, using 0" % instrument_code) + self.log.warning("No valid spread cost for %s, using 0" % instrument_code) return 0.0 return spread_cost diff --git a/sysdata/production/capital.py b/sysdata/production/capital.py index fe7723d7d0..64ce9c9ed5 100644 --- a/sysdata/production/capital.py +++ b/sysdata/production/capital.py @@ -418,7 +418,7 @@ def adjust_broker_account_for_delta(self, delta_value: float): self.capital_data.get_current_broker_account_value() ) except missingData: - self._capital_data.log.warn( + self._capital_data.log.warning( "Can't apply a delta to broker account value, since no value in data" ) raise @@ -447,7 +447,7 @@ def modify_account_values( :return: None """ if not are_you_sure: - self.capital_data.log.warn("You need to be sure to modify capital!") + self.capital_data.log.warning("You need to be sure to modify capital!") if date is arg_not_supplied: date = datetime.datetime.now() @@ -512,7 +512,7 @@ def delete_recent_capital( :return: """ if not are_you_sure: - self._capital_data.log.warn("You have to be sure to delete capital") + self._capital_data.log.warning("You have to be sure to delete capital") return failure self.capital_data.delete_recent_capital(last_date=last_date) diff --git a/sysdata/production/historic_contract_positions.py b/sysdata/production/historic_contract_positions.py index 6b41eb899a..78a5c25101 100644 --- a/sysdata/production/historic_contract_positions.py +++ b/sysdata/production/historic_contract_positions.py @@ -213,7 +213,7 @@ def _delete_last_position_for_contract_object_without_checking( ) except missingData: ## no existing data can't delete - self.log.warn( + self.log.warning( "Can't delete last position for %s, as none present" % str(contract_object) ) diff --git a/sysdata/production/historic_strategy_positions.py b/sysdata/production/historic_strategy_positions.py index f369a67d66..75d1909d7e 100644 --- a/sysdata/production/historic_strategy_positions.py +++ b/sysdata/production/historic_strategy_positions.py @@ -122,7 +122,7 @@ def delete_last_position_for_instrument_strategy_object( instrument_strategy=instrument_strategy ) else: - self.log.warn("Have to be sure to delete last position") + self.log.warning("Have to be sure to delete last position") def get_all_current_positions_as_df(self) -> pd.DataFrame: return ( @@ -167,7 +167,7 @@ def _delete_last_position_for_instrument_strategy_object_without_checking( ) except missingData: ## no existing data can't delete - self.log.warn( + self.log.warning( "Can't delete last position for %s, as none present" % str(instrument_strategy) ) diff --git a/sysdata/sim/futures_sim_data.py b/sysdata/sim/futures_sim_data.py index e11ed571d8..a17a6c3444 100644 --- a/sysdata/sim/futures_sim_data.py +++ b/sysdata/sim/futures_sim_data.py @@ -150,7 +150,7 @@ def get_raw_cost_data(self, instrument_code: str) -> instrumentCosts: instrument_code ) except missingInstrument: - self.log.warn( + self.log.warning( "Cost data missing for %s will use zero costs" % instrument_code ) return instrumentCosts() diff --git a/sysdata/sim/sim_data.py b/sysdata/sim/sim_data.py index 84177e9f7d..0855134eff 100644 --- a/sysdata/sim/sim_data.py +++ b/sysdata/sim/sim_data.py @@ -224,7 +224,7 @@ def get_value_of_block_price_move(self, instrument_code: str) -> float: :returns: float """ - self.log.warn( + self.log.warning( "Using base method of simData, value of block price move may not be accurate" ) @@ -246,7 +246,7 @@ def get_raw_cost_data(self, instrument_code: str) -> instrumentCosts: """ - self.log.warn("Using base method of simData, using zero costs") + self.log.warning("Using base method of simData, using zero costs") return instrumentCosts() diff --git a/sysdata/tools/cleaner.py b/sysdata/tools/cleaner.py index 917377811b..026b91aba3 100644 --- a/sysdata/tools/cleaner.py +++ b/sysdata/tools/cleaner.py @@ -85,7 +85,7 @@ def apply_price_cleaning( broker_prices = broker_prices.remove_negative_prices() new_price_length = len(broker_prices) if new_price_length < price_length: - log.warn( + log.warning( "Ignoring %d prices with negative prices ****COULD BE REAL PRICES****" % (price_length - new_price_length) ) diff --git a/sysexecution/algos/algo.py b/sysexecution/algos/algo.py index c1374db4d0..dfe726c823 100644 --- a/sysexecution/algos/algo.py +++ b/sysexecution/algos/algo.py @@ -144,7 +144,7 @@ def get_and_submit_broker_order_for_contract_order( ) if placed_broker_order_with_controls is missing_order: - log.warn("Order could not be submitted") + log.warning("Order could not be submitted") return missing_order log = placed_broker_order_with_controls.order.log_with_attributes(log) diff --git a/sysexecution/algos/algo_market.py b/sysexecution/algos/algo_market.py index ab7ef33225..ab13aea338 100644 --- a/sysexecution/algos/algo_market.py +++ b/sysexecution/algos/algo_market.py @@ -111,7 +111,9 @@ def manage_live_trade( break if is_order_cancelled: - log.warn("Order has been cancelled apparently by broker: not by algo!") + log.warning( + "Order has been cancelled apparently by broker: not by algo!" + ) break return broker_order_with_controls diff --git a/sysexecution/algos/algo_original_best.py b/sysexecution/algos/algo_original_best.py index ab78f3f347..836a19b5d4 100644 --- a/sysexecution/algos/algo_original_best.py +++ b/sysexecution/algos/algo_original_best.py @@ -133,7 +133,9 @@ def prepare_and_submit_trade(self) -> orderWithControls: ) else: # do a market order - log.debug("Conditions are wrong so doing market trade instead of limit trade") + log.debug( + "Conditions are wrong so doing market trade instead of limit trade" + ) broker_order_with_controls = ( self.get_and_submit_broker_order_for_contract_order( cut_down_contract_order, order_type=market_order_type @@ -213,7 +215,7 @@ def manage_live_trade( broker_order_with_controls_and_order_id ) if order_cancelled: - log.warn("Order has been cancelled: not by algo") + log.warning("Order has been cancelled: not by algo") break return broker_order_with_controls_and_order_id diff --git a/sysexecution/algos/allocate_algo_to_order.py b/sysexecution/algos/allocate_algo_to_order.py index 95a4c01e70..2f7a33cc35 100644 --- a/sysexecution/algos/allocate_algo_to_order.py +++ b/sysexecution/algos/allocate_algo_to_order.py @@ -93,7 +93,7 @@ def check_and_if_required_allocate_algo_to_single_contract_order( log.critical("Balance orders aren't executed, shouldn't even be here!") return missing_order else: - log.warn( + log.warning( "Don't recognise order type %s so allocating to default algo_market" % instrument_order_type ) diff --git a/sysexecution/algos/common_functions.py b/sysexecution/algos/common_functions.py index 031c2ed10e..513a1987af 100644 --- a/sysexecution/algos/common_functions.py +++ b/sysexecution/algos/common_functions.py @@ -50,7 +50,7 @@ def cancel_order( log.debug("Cancelled order") break if timer.finished: - log.warn("Ran out of time to cancel order - may cause weird behaviour!") + log.warning("Ran out of time to cancel order - may cause weird behaviour!") break return broker_order_with_controls diff --git a/sysexecution/order_stacks/contract_order_stack.py b/sysexecution/order_stacks/contract_order_stack.py index a1f4f2c51f..5dceb5fd98 100644 --- a/sysexecution/order_stacks/contract_order_stack.py +++ b/sysexecution/order_stacks/contract_order_stack.py @@ -25,7 +25,7 @@ def add_controlling_algo_ref(self, order_id: int, control_algo_ref: str): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't add controlling ago as order %d doesn't exist" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) try: diff --git a/sysexecution/order_stacks/order_stack.py b/sysexecution/order_stacks/order_stack.py index 36de6165ad..ef81c3e46e 100644 --- a/sysexecution/order_stacks/order_stack.py +++ b/sysexecution/order_stacks/order_stack.py @@ -95,7 +95,7 @@ def put_list_of_orders_on_stack( try: order_id = self.put_order_on_stack(order) except Exception as e: - log.warn( + log.warning( "Failed to put order %s on stack error %s, rolling back entire transaction" % (str(order), str(e)) ) diff --git a/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py b/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py index c45fa4e3bc..46e35042d4 100644 --- a/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py +++ b/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py @@ -343,7 +343,9 @@ def post_trade_processing( # release contract order from algo contract_order_id = broker_order.parent self.contract_stack.release_order_from_algo_control(contract_order_id) - self.log.debug("Released contract order %s from algo control" % contract_order_id) + self.log.debug( + "Released contract order %s from algo control" % contract_order_id + ) def add_trade_to_trade_limits(self, executed_order: brokerOrder): diff --git a/sysexecution/stack_handler/stackHandlerCore.py b/sysexecution/stack_handler/stackHandlerCore.py index 1eaf7e8284..cabc63e919 100644 --- a/sysexecution/stack_handler/stackHandlerCore.py +++ b/sysexecution/stack_handler/stackHandlerCore.py @@ -106,7 +106,7 @@ def put_children_on_stack( list_of_child_orders ) except failureWithRollback as e: - parent_log.warn( + parent_log.warning( "Tried to add child orders but %s; rolled back so can try again (parent %s)" % (str(e), str(parent_order)) ) diff --git a/sysexecution/strategies/strategy_order_handling.py b/sysexecution/strategies/strategy_order_handling.py index 46e2702bda..d3c234c818 100644 --- a/sysexecution/strategies/strategy_order_handling.py +++ b/sysexecution/strategies/strategy_order_handling.py @@ -157,11 +157,11 @@ def adjust_order_for_position_limits( if new_order.trade != order.trade: if new_order.is_zero_trade(): ## at position limit, can't do anything - log.warn( + log.warning( "Can't trade at all because of position limits %s" % str(order) ) else: - log.warn( + log.warning( "Can't do trade of %s because of position limits,instead will do %s" % (str(order), str(new_order.trade)) ) diff --git a/sysinit/futures/seed_price_data_from_IB.py b/sysinit/futures/seed_price_data_from_IB.py index 0069b2f2f4..40716e2bb8 100644 --- a/sysinit/futures/seed_price_data_from_IB.py +++ b/sysinit/futures/seed_price_data_from_IB.py @@ -62,13 +62,13 @@ def seed_price_data_for_contract_at_frequency( ) ) except missingData: - log.warn("Error getting data for %s" % str(contract_object)) + log.warning("Error getting data for %s" % str(contract_object)) return None log.debug("Got %d lines of prices for %s" % (len(prices), str(contract_object))) if len(prices) == 0: - log.warn("No price data for %s" % str(contract_object)) + log.warning("No price data for %s" % str(contract_object)) else: update_prices.overwrite_prices_at_frequency_for_contract( contract_object=contract_object, frequency=frequency, new_prices=prices diff --git a/syslogging/adapter.py b/syslogging/adapter.py index 1c71f65a95..0b61d148a7 100644 --- a/syslogging/adapter.py +++ b/syslogging/adapter.py @@ -62,22 +62,6 @@ def _merge_attributes(self, method, attributes): return merged - def terse(self, msg, *args, **kwargs): - warnings.warn( - "The 'terse' function is deprecated, " "use 'info' instead", - DeprecationWarning, - 2, - ) - self.log(logging.INFO, msg, *args, **kwargs) - - def warn(self, msg, *args, **kwargs): - warnings.warn( - "The 'warn' function is deprecated, " "use 'warning' instead", - DeprecationWarning, - 2, - ) - self.log(logging.WARNING, msg, *args, **kwargs) - def setup(self, **kwargs): # Create a copy of me with different attributes warnings.warn( diff --git a/syslogging/tests/logging_tests.py b/syslogging/tests/logging_tests.py index 4f231483e1..95797bc3b0 100644 --- a/syslogging/tests/logging_tests.py +++ b/syslogging/tests/logging_tests.py @@ -94,20 +94,6 @@ def test_label_bad(self): with pytest.raises(Exception): logger.label(stage="left", foo="bar") - def test_terse(self, caplog): - logger = get_logger("Terse") - logger.terse("terse() is an alias for INFO") - assert caplog.record_tuples == [ - ("Terse", logging.INFO, "terse() is an alias for INFO") - ] - - def test_warn(self, caplog): - logger = get_logger("Warn") - logger.warn("warn() is an alias for WARNING") - assert caplog.record_tuples == [ - ("Warn", logging.WARNING, "warn() is an alias for WARNING") - ] - def test_logtoscreen(self): screen = logtoscreen("logtoscreen") assert screen.name == "logtoscreen" diff --git a/sysproduction/backup_arctic_to_csv.py b/sysproduction/backup_arctic_to_csv.py index f807522f84..104aa998e6 100644 --- a/sysproduction/backup_arctic_to_csv.py +++ b/sysproduction/backup_arctic_to_csv.py @@ -231,9 +231,11 @@ def backup_futures_contract_prices_for_contract_to_csv( arctic_data, ignore_duplication=True, ) - data.log.debug("Written backup .csv of prices for %s" % str(futures_contract)) + data.log.debug( + "Written backup .csv of prices for %s" % str(futures_contract) + ) except BaseException: - data.log.warn( + data.log.warning( "Problem writing .csv of prices for %s" % str(futures_contract) ) @@ -254,7 +256,7 @@ def backup_fx_to_csv(data): ) data.log.debug("Written .csv backup for %s" % fx_code) except BaseException: - data.log.warn("Problem writing .csv backup for %s" % fx_code) + data.log.warning("Problem writing .csv backup for %s" % fx_code) def backup_multiple_to_csv(data): @@ -277,9 +279,11 @@ def backup_multiple_to_csv_for_instrument(data, instrument_code: str): data.csv_futures_multiple_prices.add_multiple_prices( instrument_code, arctic_data, ignore_duplication=True ) - data.log.debug("Written .csv backup multiple prices for %s" % instrument_code) + data.log.debug( + "Written .csv backup multiple prices for %s" % instrument_code + ) except BaseException: - data.log.warn( + data.log.warning( "Problem writing .csv backup multiple prices for %s" % instrument_code ) @@ -304,9 +308,11 @@ def backup_adj_to_csv_for_instrument(data: dataBlob, instrument_code: str): data.csv_futures_adjusted_prices.add_adjusted_prices( instrument_code, arctic_data, ignore_duplication=True ) - data.log.debug("Written .csv backup for adjusted prices %s" % instrument_code) + data.log.debug( + "Written .csv backup for adjusted prices %s" % instrument_code + ) except BaseException: - data.log.warn( + data.log.warning( "Problem writing .csv backup for adjusted prices %s" % instrument_code ) @@ -331,7 +337,7 @@ def backup_spreads_to_csv_for_instrument(data: dataBlob, instrument_code: str): ) data.log.debug("Written .csv backup for spreads %s" % instrument_code) except BaseException: - data.log.warn( + data.log.warning( "Problem writing .csv backup for spreads %s" % instrument_code ) diff --git a/sysproduction/interactive_manual_check_fx_prices.py b/sysproduction/interactive_manual_check_fx_prices.py index e663847802..1ba6f273f4 100644 --- a/sysproduction/interactive_manual_check_fx_prices.py +++ b/sysproduction/interactive_manual_check_fx_prices.py @@ -59,7 +59,7 @@ def update_manual_check_fx_prices_for_code(fx_code: str, data: dataBlob): new_fx_prices = data_broker.get_fx_prices(fx_code) # returns fxPrices object if len(new_fx_prices) == 0: - data.log.warn("No FX prices found for %s" % fx_code) + data.log.warning("No FX prices found for %s" % fx_code) old_fx_prices = db_currency_data.get_fx_prices(fx_code) diff --git a/sysproduction/interactive_update_roll_status.py b/sysproduction/interactive_update_roll_status.py index 781da6aca9..549f0a3ee9 100644 --- a/sysproduction/interactive_update_roll_status.py +++ b/sysproduction/interactive_update_roll_status.py @@ -596,7 +596,7 @@ def roll_adjusted_and_multiple_prices( try: rolling_adj_and_mult_object.write_new_rolled_data() except Exception as e: - data.log.warn( + data.log.warning( "%s went wrong when rolling: Going to roll-back to original multiple/adjusted prices" % e ) diff --git a/sysproduction/update_fx_prices.py b/sysproduction/update_fx_prices.py index f41b868611..7cc8f0f661 100644 --- a/sysproduction/update_fx_prices.py +++ b/sysproduction/update_fx_prices.py @@ -69,11 +69,11 @@ def report_fx_data_spike(data: dataBlob, fx_code: str): "Spike found in prices for %s: need to manually check by running interactive_manual_check_fx_prices" % str(fx_code) ) - data.log.warn(msg) + data.log.warning(msg) try: send_production_mail_msg(data, msg, "FX Price Spike %s" % str(fx_code)) except BaseException: - data.log.warn("Couldn't send email about price spike") + data.log.warning("Couldn't send email about price spike") if __name__ == "__main__": diff --git a/sysproduction/update_historical_prices.py b/sysproduction/update_historical_prices.py index 4852039e5f..fe6751369c 100644 --- a/sysproduction/update_historical_prices.py +++ b/sysproduction/update_historical_prices.py @@ -312,7 +312,7 @@ def update_historical_prices_for_instrument( contract_list = all_contracts_list.currently_sampling() if len(contract_list) == 0: - data.log.warn("No contracts marked for sampling for %s" % instrument_code) + data.log.warning("No contracts marked for sampling for %s" % instrument_code) return failure for contract_object in contract_list: @@ -445,7 +445,7 @@ def price_updating_or_errors( return failure if error_or_rows_added is failure: - data.log.warn("Something went wrong when adding rows") + data.log.warning("Something went wrong when adding rows") return failure return error_or_rows_added @@ -458,13 +458,13 @@ def report_price_spike(data: dataBlob, contract_object: futuresContract): "Spike found in prices for %s: need to manually check by running interactive_manual_check_historical_prices" % str(contract_object) ) - data.log.warn(msg) + data.log.warning(msg) try: send_production_mail_msg( data, msg, "Price Spike %s" % contract_object.instrument_code ) except BaseException: - data.log.warn( + data.log.warning( "Couldn't send email about price spike for %s" % str(contract_object) ) diff --git a/systems/accounts/account_instruments.py b/systems/accounts/account_instruments.py index 9b319a6685..de314acebb 100644 --- a/systems/accounts/account_instruments.py +++ b/systems/accounts/account_instruments.py @@ -186,7 +186,7 @@ def _pandl_for_instrument_with_cash_costs( ) -> accountCurve: if not roundpositions: - self.log.warn( + self.log.warning( "Using roundpositions=False with cash costs may lead to inaccurate costs (fixed costs, eg commissions will be overstated!!!" ) diff --git a/systems/accounts/account_portfolio.py b/systems/accounts/account_portfolio.py index 90b207bbc1..f6756a63ac 100644 --- a/systems/accounts/account_portfolio.py +++ b/systems/accounts/account_portfolio.py @@ -28,7 +28,7 @@ def portfolio(self, delayfill=True, roundpositions=True): 0.2638225179274214 """ - self.log.terse("Calculating pandl for portfolio") + self.log.info("Calculating pandl for portfolio") capital = self.get_notional_capital() instruments = self.get_instrument_list() dict_of_pandl_by_instrument = dict( diff --git a/systems/accounts/account_with_multiplier.py b/systems/accounts/account_with_multiplier.py index 09c1f922bd..62ce39d5ea 100644 --- a/systems/accounts/account_with_multiplier.py +++ b/systems/accounts/account_with_multiplier.py @@ -18,7 +18,7 @@ class accountWithMultiplier(accountPortfolio, accountBufferingSystemLevel): @output(not_pickable=True) def portfolio_with_multiplier(self, delayfill=True, roundpositions=True): - self.log.terse("Calculating pandl for portfolio with multiplier") + self.log.info("Calculating pandl for portfolio with multiplier") capital = self.get_actual_capital() instruments = self.get_instrument_list() port_pandl = [ diff --git a/systems/forecast_combine.py b/systems/forecast_combine.py index f6840b1079..fb62d0fed1 100755 --- a/systems/forecast_combine.py +++ b/systems/forecast_combine.py @@ -608,7 +608,7 @@ def calculation_of_raw_estimated_monthly_forecast_weights(self, instrument_code) :returns: TxK pd.DataFrame containing weights, columns are trading rule variation names, T covers all """ - self.log.terse("Calculating raw forecast weights for %s" % instrument_code) + self.log.info("Calculating raw forecast weights for %s" % instrument_code) config = self.config # Get some useful stuff from the config @@ -816,7 +816,7 @@ def _cheap_trading_rules_generic( "No rules are cheap enough for %s with threshold %.3f SR units! Raise threshold (system.config.forecast_weight_estimate['ceiling_cost_SR']), add rules, or drop instrument." % (instrument_code, ceiling_cost_SR) ) - self.log.warn(error_msg) + self.log.warning(error_msg) else: self.log.debug( @@ -852,7 +852,7 @@ def get_SR_cost_for_instrument_forecast( "You need an accounts stage in the system to estimate forecast costs for %s %s. Using costs of zero" % (instrument_code, rule_variation_name) ) - self.log.warn(warn_msg) + self.log.warning(warn_msg) return 0.0 return accounts.get_SR_cost_for_instrument_forecast( @@ -995,7 +995,7 @@ def _get_one_over_n_weights(self, instrument_code: str) -> dict: % (equal_weight, len(rules)) ) - self.log.warn(warn_msg, instrument_code=instrument_code) + self.log.warning(warn_msg, instrument_code=instrument_code) fixed_weights = dict([(rule_name, equal_weight) for rule_name in rules]) @@ -1129,7 +1129,7 @@ def get_forecast_diversification_multiplier_estimated( 2015-12-10 1.1 2015-12-11 1.1 """ - self.log.terse( + self.log.info( "Calculating forecast div multiplier for %s" % instrument_code, instrument_code=instrument_code, ) @@ -1283,7 +1283,7 @@ def get_forecast_correlation_matrices_from_instrument_code_list( # which function to use for calculation corr_func = resolve_function(corr_params.pop("func")) - self.log.terse( + self.log.info( "Calculating forecast correlations over %s" % ", ".join(codes_to_use) ) diff --git a/systems/portfolio.py b/systems/portfolio.py index d92121dbb9..b5643618e5 100644 --- a/systems/portfolio.py +++ b/systems/portfolio.py @@ -310,7 +310,7 @@ def get_estimated_instrument_diversification_multiplier(self) -> pd.Series: 2015-12-11 1.133153 """ - self.log.terse("Calculating instrument div. multiplier") + self.log.info("Calculating instrument div. multiplier") # Get some useful stuff from the config div_mult_params = copy(self.config.instrument_div_mult_estimate) @@ -358,7 +358,7 @@ def get_fixed_instrument_diversification_multiplier(self) -> pd.Series: div_mult = self.config.instrument_div_multiplier - self.log.terse("Using fixed diversification multiplier %f" % div_mult) + self.log.info("Using fixed diversification multiplier %f" % div_mult) # Now we have a fixed weight # Need to turn into a two row timeseries covering the range of forecast @@ -402,7 +402,7 @@ def get_instrument_correlation_matrix(self): [ 0.99 0.78858156 1. ]] """ - self.log.terse("Calculating instrument correlations") + self.log.info("Calculating instrument correlations") config = self.config @@ -487,7 +487,7 @@ def get_subsystem_positions_for_instrument_list( @diagnostic() def get_unsmoothed_raw_instrument_weights(self) -> pd.DataFrame: - self.log.terse("Calculating instrument weights") + self.log.info("Calculating instrument weights") if self.use_estimated_instrument_weights(): ## will probably be annnual @@ -576,7 +576,7 @@ def get_equal_instrument_weights_dict(self) -> dict: % (weight, len(instruments_with_weights)) ) - self.log.warn(warn_msg) + self.log.warning(warn_msg) instrument_weights = dict( [(instrument_code, weight) for instrument_code in instruments_with_weights] @@ -671,7 +671,7 @@ def calculation_of_raw_instrument_weights(self): returns_pre_processor = self.returns_pre_processor() - self.log.terse("Calculating raw instrument weights") + self.log.info("Calculating raw instrument weights") weight_func = weighting_func( returns_pre_processor, log=self.log, **weighting_params @@ -770,7 +770,7 @@ def config_allocates_zero_instrument_weights_to_these_instruments( ) if len(configured_bad_but_not_configured_zero_allocation) > 0: if auto_remove_bad_instruments: - self.log.warn( + self.log.warning( "*** Following instruments are listed as trading_restrictions and/or bad_markets and will be removed from instrument weight optimisation: ***\n%s" % str(configured_bad_but_not_configured_zero_allocation) ) @@ -779,14 +779,14 @@ def config_allocates_zero_instrument_weights_to_these_instruments( + configured_bad_but_not_configured_zero_allocation ) else: - self.log.warn( + self.log.warning( "*** Following instruments are listed as trading_restrictions and/or bad_markets but still included in instrument weight optimisation: ***\n%s" % str(configured_bad_but_not_configured_zero_allocation) ) - self.log.warn( + self.log.warning( "This is fine for dynamic systems where we remove them in later optimisation, but may be problematic for static systems" ) - self.log.warn( + self.log.warning( "Consider adding to config element allocate_zero_instrument_weights_to_these_instruments" ) diff --git a/systems/provided/dynamic_small_system_optimise/accounts_stage.py b/systems/provided/dynamic_small_system_optimise/accounts_stage.py index 70303b55f1..5ee6a6af5e 100644 --- a/systems/provided/dynamic_small_system_optimise/accounts_stage.py +++ b/systems/provided/dynamic_small_system_optimise/accounts_stage.py @@ -13,7 +13,7 @@ class accountForOptimisedStage(Account): @output(not_pickable=True) def optimised_portfolio(self, delayfill=True): - self.log.terse("Calculating pandl for portfolio") + self.log.info("Calculating pandl for portfolio") capital = self.get_notional_capital() instruments = self.get_instrument_list() dict_of_pandl_by_instrument = dict( diff --git a/systems/rawdata.py b/systems/rawdata.py index 7faa783ba3..8714559efd 100644 --- a/systems/rawdata.py +++ b/systems/rawdata.py @@ -406,7 +406,7 @@ def rolls_per_year(self, instrument_code: str) -> int: try: rolls_per_year = self.data_stage.get_rolls_per_year(instrument_code) except: - self.log.warn( + self.log.warning( "No roll data for %s, this is fine for spot instruments but not for futures" % instrument_code ) @@ -674,7 +674,7 @@ def daily_denominator_price(self, instrument_code: str) -> pd.Series: try: prices = self.get_instrument_raw_carry_data(instrument_code).PRICE except missingData: - self.log.warn( + self.log.warning( "No carry data found for %s, using adjusted prices to calculate percentage returns" % instrument_code ) From 558f1e6a3b9c585ff46da1029cd1bf24df44111c Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Mon, 12 Jun 2023 10:55:24 +0100 Subject: [PATCH 3/5] log.warn() -> log.warning() --- sysbrokers/IB/client/ib_client.py | 2 +- sysbrokers/IB/client/ib_contracts_client.py | 28 +++++++-------- sysbrokers/IB/client/ib_fx_client.py | 2 +- sysbrokers/IB/client/ib_price_client.py | 12 +++---- .../IB/ib_futures_contract_price_data.py | 10 +++--- sysexecution/algos/algo.py | 4 +-- sysexecution/algos/algo_original_best.py | 2 +- .../order_stacks/contract_order_stack.py | 6 ++-- .../order_stacks/instrument_order_stack.py | 2 +- sysexecution/order_stacks/order_stack.py | 34 +++++++++---------- sysexecution/stack_handler/fills.py | 4 +-- sysexecution/stack_handler/roll_orders.py | 4 +-- .../spawn_children_from_instrument_orders.py | 2 +- .../stack_handler/stackHandlerCore.py | 4 +-- .../strategies/strategy_order_handling.py | 2 +- sysproduction/data/backtest.py | 6 ++-- sysproduction/data/broker.py | 4 +-- sysproduction/data/controls.py | 2 +- sysproduction/data/positions.py | 2 +- sysproduction/reporting/data/rolls.py | 2 +- .../strategy_code/strategy_allocation.py | 2 +- .../strategy_code/strategy_report.py | 2 +- 22 files changed, 69 insertions(+), 69 deletions(-) diff --git a/sysbrokers/IB/client/ib_client.py b/sysbrokers/IB/client/ib_client.py index b7d8ee3ad3..728044ed4a 100644 --- a/sysbrokers/IB/client/ib_client.py +++ b/sysbrokers/IB/client/ib_client.py @@ -133,7 +133,7 @@ def error_handler( self.broker_message(msg=msg, log=self.log) def broker_error(self, msg, log, myerror_type): - log.warn(msg) + log.warning(msg) def broker_message(self, log, msg): log.debug(msg) diff --git a/sysbrokers/IB/client/ib_contracts_client.py b/sysbrokers/IB/client/ib_contracts_client.py index fc77ce2f1a..a9082047da 100644 --- a/sysbrokers/IB/client/ib_contracts_client.py +++ b/sysbrokers/IB/client/ib_contracts_client.py @@ -74,7 +74,7 @@ def broker_get_single_contract_expiry_date( """ specific_log = futures_contract_with_ib_data.specific_log(self.log) if futures_contract_with_ib_data.is_spread_contract(): - specific_log.warn("Can only find expiry for single leg contract!") + specific_log.warning("Can only find expiry for single leg contract!") raise missingContract try: @@ -84,7 +84,7 @@ def broker_get_single_contract_expiry_date( always_return_single_leg=True, ) except missingContract: - specific_log.warn("Contract is missing can't get expiry") + specific_log.warning("Contract is missing can't get expiry") raise missingContract expiry_date = ibcontract.lastTradeDateOrContractMonth @@ -110,7 +110,7 @@ def _ib_get_uncached_trading_hours( contract_object_with_ib_data ) except Exception as e: - specific_log.warn( + specific_log.warning( "%s when getting trading hours from %s!" % (str(e), str(contract_object_with_ib_data)) ) @@ -146,7 +146,7 @@ def ib_get_trading_hours_from_IB( ib_contract_details ) except Exception as e: - specific_log.warn( + specific_log.warning( "%s when getting trading hours from %s!" % (str(e), str(contract_object_with_ib_data)) ) @@ -220,7 +220,7 @@ def ib_get_saved_weekly_trading_hours_for_timezone_of_contract( time_zone_id = self.ib_get_timezoneid(contract_object_with_ib_data) except missingData: # problem getting timezoneid - specific_log.warn( + specific_log.warning( "No time zone ID, can't get trading hours for timezone for %s" % str(contract_object_with_ib_data) ) @@ -248,7 +248,7 @@ def ib_get_timezoneid(self, contract_object_with_ib_data: futuresContract) -> st ) time_zone_id = ib_contract_details.timeZoneId except Exception as e: - specific_log.warn( + specific_log.warning( "%s when getting time zone from %s!" % (str(e), str(contract_object_with_ib_data)) ) @@ -279,7 +279,7 @@ def ib_get_min_tick_size( contract_object_with_ib_data, always_return_single_leg=True ) except missingContract: - specific_log.warn("Can't get tick size as contract missing") + specific_log.warning("Can't get tick size as contract missing") raise ib_contract_details = self.ib.reqContractDetails(ib_contract)[0] @@ -287,7 +287,7 @@ def ib_get_min_tick_size( try: min_tick = ib_contract_details.minTick except Exception as e: - specific_log.warn( + specific_log.warning( "%s when getting min tick size from %s!" % (str(e), str(ib_contract_details)) ) @@ -304,7 +304,7 @@ def ib_get_price_magnifier( contract_object_with_ib_data, always_return_single_leg=True ) except missingContract: - specific_log.warn("Can't get price magnifier as contract missing") + specific_log.warning("Can't get price magnifier as contract missing") raise ib_contract_details = self.ib.reqContractDetails(ib_contract)[0] @@ -312,7 +312,7 @@ def ib_get_price_magnifier( try: price_magnifier = ib_contract_details.priceMagnifier except Exception as e: - specific_log.warn( + specific_log.warning( "%s when getting price magnifier from %s!" % (str(e), str(ib_contract_details)) ) @@ -327,7 +327,7 @@ def ib_get_contract_details(self, contract_object_with_ib_data: futuresContract) contract_object_with_ib_data, always_return_single_leg=True ) except missingContract: - specific_log.warn("Can't get trading hours as contract is missing") + specific_log.warning("Can't get trading hours as contract is missing") raise # returns a list but should only have one element @@ -523,7 +523,7 @@ def _get_vanilla_ib_futures_contract( futures_instrument_with_ib_data=futures_instrument_with_ib_data, ) except Exception as exception: - self.log.warn( + self.log.warning( "%s could not resolve contracts: %s" % (str(futures_instrument_with_ib_data), exception.args[0]) ) @@ -547,14 +547,14 @@ def ib_resolve_unique_contract(self, ibcontract_pattern, log: pst_logger = None) contract_chain = self.ib_get_contract_chain(ibcontract_pattern) if len(contract_chain) > 1: - log.warn( + log.warning( "Got multiple contracts for %s when only expected a single contract: Check contract date" % str(ibcontract_pattern) ) raise missingContract if len(contract_chain) == 0: - log.warn("Failed to resolve contract %s" % str(ibcontract_pattern)) + log.warning("Failed to resolve contract %s" % str(ibcontract_pattern)) raise missingContract resolved_contract = contract_chain[0] diff --git a/sysbrokers/IB/client/ib_fx_client.py b/sysbrokers/IB/client/ib_fx_client.py index 02eebafd41..4faf02da55 100644 --- a/sysbrokers/IB/client/ib_fx_client.py +++ b/sysbrokers/IB/client/ib_fx_client.py @@ -82,7 +82,7 @@ def broker_get_daily_fx_data( try: ibcontract = self.ib_spotfx_contract(ccy1, ccy2=ccy2) except missingContract: - log.warn("Can't find IB contract for %s%s" % (ccy1, ccy2)) + log.warning("Can't find IB contract for %s%s" % (ccy1, ccy2)) raise missingData # uses parent class ibClientPrices diff --git a/sysbrokers/IB/client/ib_price_client.py b/sysbrokers/IB/client/ib_price_client.py index 7123061015..9797fe5f8a 100644 --- a/sysbrokers/IB/client/ib_price_client.py +++ b/sysbrokers/IB/client/ib_price_client.py @@ -56,7 +56,7 @@ def broker_get_historical_futures_data_for_contract( contract_object_with_ib_broker_config, allow_expired=allow_expired ) except missingContract: - specific_log.warn( + specific_log.warning( "Can't resolve IB contract %s" % str(contract_object_with_ib_broker_config) ) @@ -82,7 +82,7 @@ def get_ticker_object( trade_list_for_multiple_legs=trade_list_for_multiple_legs, ) except missingContract: - specific_log.warn( + specific_log.warning( "Can't find matching IB contract for %s" % str(contract_object_with_ib_data) ) @@ -111,7 +111,7 @@ def cancel_market_data_for_contract_object( trade_list_for_multiple_legs=trade_list_for_multiple_legs, ) except missingContract: - specific_log.warn( + specific_log.warning( "Can't find matching IB contract for %s" % str(contract_object_with_ib_data) ) @@ -141,7 +141,7 @@ def ib_get_recent_bid_ask_tick_data( try: ibcontract = self.ib_futures_contract(contract_object_with_ib_data) except missingContract: - specific_log.warn( + specific_log.warning( "Can't find matching IB contract for %s" % str(contract_object_with_ib_data) ) @@ -177,7 +177,7 @@ def _get_generic_data_for_contract( bar_freq ) except Exception as exception: - log.warn(exception) + log.warning(exception) raise missingData price_data_raw = self._ib_get_historical_data_of_duration_and_barSize( @@ -199,7 +199,7 @@ def _raw_ib_data_to_df( ) -> pd.DataFrame: if price_data_raw is None: - log.warn("No price data from IB") + log.warning("No price data from IB") raise missingData price_data_as_df = price_data_raw[["open", "high", "low", "close", "volume"]] diff --git a/sysbrokers/IB/ib_futures_contract_price_data.py b/sysbrokers/IB/ib_futures_contract_price_data.py index ab9d21b082..8bc9fc9dba 100644 --- a/sysbrokers/IB/ib_futures_contract_price_data.py +++ b/sysbrokers/IB/ib_futures_contract_price_data.py @@ -256,14 +256,14 @@ def _get_prices_at_frequency_for_ibcontract_object_no_checking( allow_expired=allow_expired, ) except missingData: - new_log.warn( + new_log.warning( "Something went wrong getting IB price data for %s" % str(contract_object_with_ib_broker_config) ) raise if len(price_data) == 0: - new_log.warn( + new_log.warning( "No IB price data found for %s" % str(contract_object_with_ib_broker_config) ) @@ -284,7 +284,7 @@ def get_ticker_object_for_order(self, order: contractOrder) -> tickerObject: ) ) except missingContract: - new_log.warn("Can't get data for %s" % str(contract_object)) + new_log.warning("Can't get data for %s" % str(contract_object)) return futuresContractPrices.create_empty() ticker_with_bs = self.ib_client.get_ticker_object( @@ -309,7 +309,7 @@ def cancel_market_data_for_order(self, order: ibBrokerOrder): ) ) except missingContract: - new_log.warn("Can't get data for %s" % str(contract_object)) + new_log.warning("Can't get data for %s" % str(contract_object)) return futuresContractPrices.create_empty() self.ib_client.cancel_market_data_for_contract_object( @@ -335,7 +335,7 @@ def get_recent_bid_ask_tick_data_for_contract_object( ) ) except missingContract: - new_log.warn("Can't get data for %s" % str(contract_object)) + new_log.warning("Can't get data for %s" % str(contract_object)) return dataFrameOfRecentTicks.create_empty() try: diff --git a/sysexecution/algos/algo.py b/sysexecution/algos/algo.py index dfe726c823..bba7367534 100644 --- a/sysexecution/algos/algo.py +++ b/sysexecution/algos/algo.py @@ -173,7 +173,7 @@ def get_market_data_for_order_modifies_ticker_object( ) ) except missingData: - log.warn( + log.warning( "Can't get market data for %s so not trading with limit order %s" % (contract_order.instrument_code, str(contract_order)) ) @@ -231,7 +231,7 @@ def round_limit_price_to_tick_size( min_tick = self.data_broker.get_min_tick_size_for_contract(contract) except missingContract: log = contract_order.log_with_attributes(self.data.log) - log.warn( + log.warning( "Couldn't find min tick size for %s, not rounding limit price %f" % (str(contract), limit_price) ) diff --git a/sysexecution/algos/algo_original_best.py b/sysexecution/algos/algo_original_best.py index 836a19b5d4..eb40d7885e 100644 --- a/sysexecution/algos/algo_original_best.py +++ b/sysexecution/algos/algo_original_best.py @@ -337,7 +337,7 @@ def is_market_about_to_close( ) if short_of_time is market_closed: - log.warn("Market has closed for active limit order %s!" % str(order)) + log.warning("Market has closed for active limit order %s!" % str(order)) return True return short_of_time diff --git a/sysexecution/order_stacks/contract_order_stack.py b/sysexecution/order_stacks/contract_order_stack.py index 5dceb5fd98..5854810d0d 100644 --- a/sysexecution/order_stacks/contract_order_stack.py +++ b/sysexecution/order_stacks/contract_order_stack.py @@ -39,7 +39,7 @@ def add_controlling_algo_ref(self, order_id: int, control_algo_ref: str): control_algo_ref, order_id, ) - log.warn(error_msg) + log.warning(error_msg) raise Exception(error_msg) def release_order_from_algo_control(self, order_id: int): @@ -47,7 +47,7 @@ def release_order_from_algo_control(self, order_id: int): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't add controlling ago as order %d doesn't exist" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) order_is_not_controlled = not existing_order.is_order_controlled_by_algo() @@ -65,7 +65,7 @@ def release_order_from_algo_control(self, order_id: int): str(e), order_id, ) - log.warn(error_msg) + log.warning(error_msg) raise Exception(error_msg) def get_order_with_id_from_stack(self, order_id: int) -> contractOrder: diff --git a/sysexecution/order_stacks/instrument_order_stack.py b/sysexecution/order_stacks/instrument_order_stack.py index 2094da853c..a35788aeab 100644 --- a/sysexecution/order_stacks/instrument_order_stack.py +++ b/sysexecution/order_stacks/instrument_order_stack.py @@ -127,7 +127,7 @@ def _put_adjusting_order_on_stack( error_msg = "Adjusted order %s is zero, zero orders not allowed" % str( adjusted_order ) - log.warn(error_msg) + log.warning(error_msg) raise zeroOrderException(error_msg) order_id = self._put_order_on_stack_and_get_order_id(adjusted_order) diff --git a/sysexecution/order_stacks/order_stack.py b/sysexecution/order_stacks/order_stack.py index ef81c3e46e..fac38be46f 100644 --- a/sysexecution/order_stacks/order_stack.py +++ b/sysexecution/order_stacks/order_stack.py @@ -115,7 +115,7 @@ def put_list_of_orders_on_stack( "Didn't put list of %d orders on stack but did manage to rollback" % len(list_of_orders) ) - self.log.warn(error_msg) + self.log.warning(error_msg) raise failureWithRollback(error_msg) # success, unlock orders that we've just placed on the stack @@ -130,7 +130,7 @@ def rollback_list_of_orders_on_stack(self, list_of_order_ids: list): if len(list_of_order_ids) == 0: return None - self.log.warn("Rolling back addition of orders %s" % str(list_of_order_ids)) + self.log.warning("Rolling back addition of orders %s" % str(list_of_order_ids)) for order_id in list_of_order_ids: self.unlock_order_on_stack(order_id) @@ -260,7 +260,7 @@ def add_children_to_order_without_existing_children( existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't add children to non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) log = existing_order.log_with_attributes(self.log) @@ -271,7 +271,7 @@ def add_children_to_order_without_existing_children( "Can't add children to order that already has children %s" % str(existing_order.children) ) - log.warn(error_msg) + log.warning(error_msg) raise Exception(error_msg) new_order = copy(existing_order) @@ -283,7 +283,7 @@ def add_another_child_to_order(self, order_id: int, new_child: int): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't add children to non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) existing_order.add_another_child(new_child) @@ -294,7 +294,7 @@ def remove_children_from_order(self, order_id: int): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't remove children from non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) new_order = copy(existing_order) @@ -320,7 +320,7 @@ def change_fill_quantity_for_order( existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't apply fill to non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) if existing_order.fill == fill_qty: @@ -335,7 +335,7 @@ def change_fill_quantity_for_order( fill_qty, filled_price=filled_price, fill_datetime=fill_datetime ) except overFilledOrder as e: - log.warn(str(e)) + log.warning(str(e)) raise overFilledOrder(e) self._change_order_on_stack(order_id, new_order) @@ -351,14 +351,14 @@ def zero_out(self, order_id: int): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't zero out non existent order" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) log = existing_order.log_with_attributes(existing_order) if not existing_order.active: # already inactive - log.warn("Can't zero out order which is already inactive") + log.warning("Can't zero out order which is already inactive") return None new_order = copy(existing_order) @@ -373,7 +373,7 @@ def deactivate_order(self, order_id: int): existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't deactivate non existent order" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) log = existing_order.log_with_attributes(self.log) @@ -429,7 +429,7 @@ def _change_order_on_stack( existing_order = self.get_order_with_id_from_stack(order_id) if existing_order is missing_order: error_msg = "Can't change non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) log = existing_order.log_with_attributes(self.log) @@ -438,14 +438,14 @@ def _change_order_on_stack( if lock_status is True: # already locked can't change error_msg = "Can't change locked order %s" % str(existing_order) - log.warn(error_msg) + log.warning(error_msg) raise Exception(error_msg) if check_if_inactive: existing_order_is_inactive = not existing_order.active if existing_order_is_inactive: error_msg = "Can't change order %s as inactive" % str(existing_order) - log.warn(error_msg) + log.warning(error_msg) self._change_order_on_stack_no_checking(order_id, new_order) @@ -453,7 +453,7 @@ def unlock_order_on_stack(self, order_id: int): order = self.get_order_with_id_from_stack(order_id) if order is missing_order: error_msg = "Can't unlock non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) order.unlock_order() @@ -463,7 +463,7 @@ def lock_order_on_stack(self, order_id: int): order = self.get_order_with_id_from_stack(order_id) if order is missing_order: error_msg = "Can't lock non existent order %d" % order_id - self.log.warn(error_msg) + self.log.warning(error_msg) raise missingOrder(error_msg) order.lock_order() @@ -475,7 +475,7 @@ def _put_order_on_stack_and_get_order_id(self, order: Order) -> int: order_has_existing_id = not order.order_id is no_order_id if order_has_existing_id: log = order.log_with_attributes(self.log) - log.warn( + log.warning( "Order %s already has order ID will be ignored and allocated a new ID!" % str(order) ) diff --git a/sysexecution/stack_handler/fills.py b/sysexecution/stack_handler/fills.py index 47f32db04f..addf46333c 100644 --- a/sysexecution/stack_handler/fills.py +++ b/sysexecution/stack_handler/fills.py @@ -59,7 +59,7 @@ def apply_broker_fill_from_broker_to_broker_database(self, broker_order_id: int) if matched_broker_order is missing_order: log = db_broker_order.log_with_attributes(self.log) - log.warn( + log.warning( "Order in database %s does not match any broker orders: can't fill" % db_broker_order ) @@ -85,7 +85,7 @@ def apply_broker_order_fills_to_database( ) if result is fill_exceeds_trade: - self.log.warn( + self.log.warning( "Fill for exceeds trade for %s, ignoring fill... (hopefully will go away)" % (broker_order) ) diff --git a/sysexecution/stack_handler/roll_orders.py b/sysexecution/stack_handler/roll_orders.py index 05330e162f..c22d011b64 100644 --- a/sysexecution/stack_handler/roll_orders.py +++ b/sysexecution/stack_handler/roll_orders.py @@ -145,7 +145,7 @@ def add_instrument_and_list_of_contract_orders_to_stack( ) except Exception as parent_order_error: - parent_log.warn( + parent_log.warning( "Couldn't put parent order %s on instrument order stack error %s" % (str(instrument_order), str(parent_order_error)) ) @@ -332,7 +332,7 @@ def create_contract_roll_orders( else: log = instrument_order.log_with_attributes(data.log) roll_state = diag_positions.get_roll_state(instrument_code) - log.warn("Roll state %s is unexpected, might have changed" % str(roll_state)) + log.warning("Roll state %s is unexpected, might have changed" % str(roll_state)) return missing_order contract_orders = allocate_algo_to_list_of_contract_orders( diff --git a/sysexecution/stack_handler/spawn_children_from_instrument_orders.py b/sysexecution/stack_handler/spawn_children_from_instrument_orders.py index 5190a3fd5f..080790ad4d 100644 --- a/sysexecution/stack_handler/spawn_children_from_instrument_orders.py +++ b/sysexecution/stack_handler/spawn_children_from_instrument_orders.py @@ -499,7 +499,7 @@ def add_reference_price_to_a_direct_child_order( ) except missingData: log = instrument_order.log_with_attributes(data.log) - log.warn( + log.warning( "Couldn't adjust reference price for order %s child %s going from %s to %s, can't do TCA" % ( str(instrument_order), diff --git a/sysexecution/stack_handler/stackHandlerCore.py b/sysexecution/stack_handler/stackHandlerCore.py index cabc63e919..7fe21a3b9c 100644 --- a/sysexecution/stack_handler/stackHandlerCore.py +++ b/sysexecution/stack_handler/stackHandlerCore.py @@ -136,7 +136,7 @@ def add_children_to_parent_or_rollback_children( except Exception as e: try: child_stack.rollback_list_of_orders_on_stack(list_of_child_ids) - parent_log.warn( + parent_log.warning( "Tried to add child orders to parent but %s; rolled back so can try again (parent %s)" % (str(e), str(parent_order)) ) @@ -183,7 +183,7 @@ def rollback_parents_and_children_and_handle_exceptions( list_of_child_order_ids=list_of_child_order_ids, parent_order_id=parent_order_id, ) - parent_log.warn( + parent_log.warning( "Error %s when adding a set of parents and children but managed to rollback" % str(error_from_adding_child_orders) ) diff --git a/sysexecution/strategies/strategy_order_handling.py b/sysexecution/strategies/strategy_order_handling.py index d3c234c818..36ea397274 100644 --- a/sysexecution/strategies/strategy_order_handling.py +++ b/sysexecution/strategies/strategy_order_handling.py @@ -190,7 +190,7 @@ def submit_order(self, order: instrumentOrder): except zeroOrderException: # we checked for zero already, which means that there is an existing order on the stack # An existing order of the same size - log.warn( + log.warning( "Ignoring new order as either zero size or it replicates an existing order on the stack" ) diff --git a/sysproduction/data/backtest.py b/sysproduction/data/backtest.py index 9257bef241..0c0daece46 100644 --- a/sysproduction/data/backtest.py +++ b/sysproduction/data/backtest.py @@ -150,7 +150,7 @@ def get_loader_config(data: dataBlob, strategy_name: str) -> dict: object="sysproduction.strategy_code.run_system_classic.runSystemClassic", function="system_method", ) - data.log.warn( + data.log.warning( "No configuration strategy_list/strategy_name/load_backtests; using defaults %s" % str(strategy_loader_config) ) @@ -279,7 +279,7 @@ def pickle_state(data, system, backtest_filename): data.log.debug("Pickled backtest state to %s" % backtest_filename) return success except Exception as e: - data.log.warn( + data.log.warning( "Couldn't save backtest state to %s error %s" % (backtest_filename, e) ) return failure @@ -294,7 +294,7 @@ def copy_config_file(data, resolved_backtest_config_filename, config_save_filena ) return success except Exception as e: - data.log.warn( + data.log.warning( "Couldn't copy config file from %s to %s error %s" % (resolved_backtest_config_filename, config_save_filename, e) ) diff --git a/sysproduction/data/broker.py b/sysproduction/data/broker.py index 89eb36c06c..c3dbc65f9f 100644 --- a/sysproduction/data/broker.py +++ b/sysproduction/data/broker.py @@ -116,7 +116,7 @@ def broker_fx_market_order( trade, ccy1, ccy2=ccy2, account_id=account_id ) if result is missing_order: - self.log.warn( + self.log.warning( "%s %s is not recognised by broker - try inverting" % (ccy1, ccy2) ) @@ -288,7 +288,7 @@ def get_current_size_for_contract_order_by_leg( contract_order ) except missingData: - self.log.warn("Can't get market conditions, setting available size to zero") + self.log.warning("Can't get market conditions, setting available size to zero") side_qty = offside_qty = len(contract_order.trade) * [0] return side_qty, offside_qty diff --git a/sysproduction/data/controls.py b/sysproduction/data/controls.py index 5acdcba47f..31272792cc 100644 --- a/sysproduction/data/controls.py +++ b/sysproduction/data/controls.py @@ -684,7 +684,7 @@ def reset_position_limit_for_instrument_to_original_value(self, instrument_code) ) ) except missingData: - self.log.warn("No temporary position limit stored") + self.log.warning("No temporary position limit stored") return None self.set_abs_position_limit_for_instrument( diff --git a/sysproduction/data/positions.py b/sysproduction/data/positions.py index 4ab082f5ff..92cad7d612 100644 --- a/sysproduction/data/positions.py +++ b/sysproduction/data/positions.py @@ -284,7 +284,7 @@ def update_expiry_for_single_contract( ) except ContractNotFound: log = original_contract.specific_log(self.data.log) - log.warn( + log.warning( "Contract %s is missing from database - expiry not found and will mismatch" % str(original_contract) ) diff --git a/sysproduction/reporting/data/rolls.py b/sysproduction/reporting/data/rolls.py index 8ec0b72446..0b3ff1bd43 100644 --- a/sysproduction/reporting/data/rolls.py +++ b/sysproduction/reporting/data/rolls.py @@ -521,7 +521,7 @@ def rollback_adjustment( instrument_code, current_multiple_prices, ignore_duplication=True ) except Exception as e: - data.log.warn( + data.log.warning( "***** ROLLBACK FAILED! %s!You may need to rebuild your data! Check before trading!! *****" % e ) diff --git a/sysproduction/strategy_code/strategy_allocation.py b/sysproduction/strategy_code/strategy_allocation.py index fea99dab62..ea5412edf6 100644 --- a/sysproduction/strategy_code/strategy_allocation.py +++ b/sysproduction/strategy_code/strategy_allocation.py @@ -64,7 +64,7 @@ def strategy_weights_if_none_passed(data: dataBlob) -> dict: list_of_strategies = get_list_of_strategies_from_config(data) count_of_strateges = len(list_of_strategies) weight = 100.0 / count_of_strateges - data.log.warn( + data.log.warning( "No configuration for strategy weight defined in private config; equally weighting across %s each gets %f percent" % (str(list_of_strategies), weight) ) diff --git a/sysproduction/strategy_code/strategy_report.py b/sysproduction/strategy_code/strategy_report.py index 67be9000d5..b44bd6659e 100644 --- a/sysproduction/strategy_code/strategy_report.py +++ b/sysproduction/strategy_code/strategy_report.py @@ -26,7 +26,7 @@ def get_reporting_function_for_strategy_name(data: dataBlob, strategy_name: str) reporting_config = config_for_strategy["reporting_code"] reporting_function = reporting_config["function"] except BaseException: - data.log.warn( + data.log.warning( "Something went wrong for reporting with strategy %s, using default function %s" % (strategy_name, default_reporting_method) ) From 99ce79997a97043d1d73b30ed433c2f00255afca Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Mon, 12 Jun 2023 10:58:40 +0100 Subject: [PATCH 4/5] black betty --- sysproduction/data/broker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sysproduction/data/broker.py b/sysproduction/data/broker.py index c3dbc65f9f..ea37a3450d 100644 --- a/sysproduction/data/broker.py +++ b/sysproduction/data/broker.py @@ -288,7 +288,9 @@ def get_current_size_for_contract_order_by_leg( contract_order ) except missingData: - self.log.warning("Can't get market conditions, setting available size to zero") + self.log.warning( + "Can't get market conditions, setting available size to zero" + ) side_qty = offside_qty = len(contract_order.trade) * [0] return side_qty, offside_qty From 456596f3c68c62ac3374cc271397adadfa98f4b4 Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Wed, 28 Jun 2023 11:51:04 +0100 Subject: [PATCH 5/5] log.msg() -> log.debug() --- syslogdiag/email_via_db_interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syslogdiag/email_via_db_interface.py b/syslogdiag/email_via_db_interface.py index 0cf7e3c415..0bdb55a786 100644 --- a/syslogdiag/email_via_db_interface.py +++ b/syslogdiag/email_via_db_interface.py @@ -42,10 +42,10 @@ def send_email_and_record_date_or_store_on_fail( try: send_mail_msg(body, subject) record_date_of_email_send(data, subject) - data.log.msg("Sent email subject %s" % subject) + data.log.debug("Sent email subject %s" % subject) except Exception as e: # problem sending emails will store instead - data.log.msg( + data.log.debug( "Problem %s sending email subject %s, will store message instead" % (str(e), subject) )