Skip to content

Commit

Permalink
log.msg() -> log.debug()
Browse files Browse the repository at this point in the history
  • Loading branch information
bug-or-feature committed Jun 9, 2023
1 parent 9e5d824 commit 02c4cbc
Show file tree
Hide file tree
Showing 85 changed files with 263 additions and 278 deletions.
2 changes: 1 addition & 1 deletion sysbrokers/IB/client/ib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sysbrokers/IB/client/ib_price_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sysbrokers/IB/ib_Fx_prices_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion sysbrokers/IB/ib_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions sysbrokers/IB/ib_futures_contracts_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ 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:
min_tick_size = self.ib_client.ib_get_min_tick_size(
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
Expand All @@ -186,15 +186,15 @@ 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:
price_magnifier = self.ib_client.ib_get_price_magnifier(
contract_object_with_ib_data
)
except missingContract:
new_log.msg("No contract found")
new_log.debug("No contract found")
raise

return price_magnifier
Expand All @@ -214,15 +214,15 @@ 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:
trading_hours = self.ib_client.ib_get_trading_hours(
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
6 changes: 3 additions & 3 deletions sysbrokers/IB/ib_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions syscontrol/report_process_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions syscontrol/run_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions syscontrol/timer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions sysdata/arctic/arctic_adjusted_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sysdata/arctic/arctic_futures_per_contract_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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))
)
Expand Down
4 changes: 2 additions & 2 deletions sysdata/arctic/arctic_multiple_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sysdata/arctic/arctic_spotfx_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
)
4 changes: 2 additions & 2 deletions sysdata/arctic/arctic_spreads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sysdata/config/configdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sysdata/csv/csv_multiple_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion sysdata/csv/csv_roll_calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion sysdata/csv/csv_spot_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)
Expand Down
10 changes: 5 additions & 5 deletions sysdata/futures/futures_per_contract_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion sysdata/futures/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
2 changes: 1 addition & 1 deletion sysdata/futures/roll_calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading

0 comments on commit 02c4cbc

Please sign in to comment.