Skip to content

Commit 0442242

Browse files
author
rob
committed
fix issue with backup
1 parent 9c0dab1 commit 0442242

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

sysbrokers/IB/client/ib_client.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def log(self):
103103
return self._log
104104

105105
def error_handler(
106-
self, reqid: int, error_code: int, error_string: str, contract: ibContract
106+
self, reqid: int, error_code: int, error_string: str, ib_contract: ibContract
107107
):
108108
"""
109109
Error handler called from server
@@ -116,34 +116,22 @@ def error_handler(
116116
:return: success
117117
"""
118118

119-
msg = "Reqid %d: %d %s" % (reqid, error_code, error_string)
120-
121-
log_to_use = self._get_log_for_contract(contract)
119+
msg = "Reqid %d: %d %s for %s" % (
120+
reqid,
121+
error_code,
122+
error_string,
123+
str(ib_contract),
124+
)
122125

123126
iserror = error_code in IB_IS_ERROR
124127
if iserror:
125128
# Serious requires some action
126129
myerror_type = IB_ERROR_TYPES.get(error_code, "generic")
127-
self.broker_error(msg=msg, myerror_type=myerror_type, log=log_to_use)
130+
self.broker_error(msg=msg, myerror_type=myerror_type, log=self.log)
128131

129132
else:
130133
# just a general message
131-
self.broker_message(msg=msg, log=log_to_use)
132-
133-
def _get_log_for_contract(self, contract: ibContract) -> pst_logger:
134-
if contract is None:
135-
log_to_use = self.log.setup()
136-
else:
137-
ib_expiry_str = contract.lastTradeDateOrContractMonth
138-
instrument_code = self.get_instrument_code_from_broker_contract_object(
139-
contract
140-
)
141-
if instrument_code is missing_contract:
142-
instrument_code = "UNKNOWN (%s)" % contract.symbol
143-
futures_contract = futuresContract(instrument_code, ib_expiry_str)
144-
log_to_use = futures_contract.specific_log(self.log)
145-
146-
return log_to_use
134+
self.broker_message(msg=msg, log=self.log)
147135

148136
def broker_error(self, msg, log, myerror_type):
149137
log.warn(msg)

sysdata/csv/csv_contract_position_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def __repr__(self):
2929
return "csvContractPositionData accessing %s" % self._datapath
3030

3131
def _write_updated_position_series_for_contract_object(
32-
self, contract_object: futuresContract, update_series: pd.Series
32+
self, contract_object: futuresContract, updated_series: pd.Series
3333
):
34-
position_df = pd.DataFrame(update_series)
34+
position_df = pd.DataFrame(updated_series)
3535
filename = self._filename_given_contract(contract_object)
3636
position_df.to_csv(filename, index_label=DATE_INDEX_NAME)
3737

0 commit comments

Comments
 (0)