Skip to content

Commit 20600c8

Browse files
author
rob
committed
refactored last pull
1 parent 21150a2 commit 20600c8

18 files changed

+87
-56
lines changed

sysbrokers/IB/ib_Fx_prices_data.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919

2020
class ibFxPricesData(brokerFxPricesData):
21-
def __init__(
22-
self, ibconnection, data_blob: dataBlob, log=logtoscreen("ibFxPricesData")
23-
):
24-
super().__init__(log=log)
21+
def __init__(self, ibconnection, data: dataBlob, log=logtoscreen("ibFxPricesData")):
22+
super().__init__(log=log, data=data)
2523
self._ibconnection = ibconnection
2624
self._dataBlob = data_blob
2725

sysbrokers/IB/ib_capital_data.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ class ibCapitalData(brokerCapitalData):
1414
def __init__(
1515
self,
1616
ibconnection: connectionIB,
17-
data_blob: dataBlob,
17+
data: dataBlob,
1818
log: logger = logtoscreen("ibCapitalData"),
1919
):
20-
super().__init__(log=log)
20+
super().__init__(log=log, data=data)
2121
self._ibconnection = ibconnection
22-
self._dataBlob = data_blob
2322

2423
@property
2524
def ibconnection(self) -> connectionIB:

sysbrokers/IB/ib_contract_position_data.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ class ibContractPositionData(brokerContractPositionData):
1717
def __init__(
1818
self,
1919
ibconnection: connectionIB,
20-
data_blob: dataBlob,
20+
data: dataBlob,
2121
log=logtoscreen("ibContractPositionData"),
2222
):
23-
super().__init__(log=log)
23+
super().__init__(log=log, data=data)
2424
self._ibconnection = ibconnection
25-
self._dataBlob = data_blob
26-
27-
@property
28-
def data(self):
29-
return self._dataBlob
3025

3126
@property
3227
def ibconnection(self) -> connectionIB:

sysbrokers/IB/ib_futures_contract_price_data.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,15 @@ class ibFuturesContractPriceData(brokerFuturesContractPriceData):
7676
def __init__(
7777
self,
7878
ibconnection: connectionIB,
79-
data_blob: dataBlob,
79+
data: dataBlob,
8080
log=logtoscreen("ibFuturesContractPriceData"),
8181
):
82-
super().__init__(log=log)
82+
super().__init__(log=log, data=data)
8383
self._ibconnection = ibconnection
84-
self._dataBlob = data_blob
8584

8685
def __repr__(self):
8786
return "IB Futures per contract price data %s" % str(self.ib_client)
8887

89-
@property
90-
def data(self):
91-
return self._dataBlob
92-
9388
@property
9489
def ibconnection(self) -> connectionIB:
9590
return self._ibconnection

sysbrokers/IB/ib_futures_contracts_data.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,15 @@ class ibFuturesContractData(brokerFuturesContractData):
2828
def __init__(
2929
self,
3030
ibconnection: connectionIB,
31-
data_blob: dataBlob,
31+
data: dataBlob,
3232
log=logtoscreen("ibFuturesContractData"),
3333
):
34-
super().__init__(log=log)
34+
super().__init__(log=log, data=data)
3535
self._ibconnection = ibconnection
36-
self._dataBlob = data_blob
3736

3837
def __repr__(self):
3938
return "IB Futures per contract data %s" % str(self.ib_client)
4039

41-
@property
42-
def data(self):
43-
return self._dataBlob
44-
4540
@property
4641
def ibconnection(self) -> connectionIB:
4742
return self._ibconnection

sysbrokers/IB/ib_fx_handling.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class ibFxHandlingData(brokerFxHandlingData):
1212
def __init__(
1313
self,
1414
ibconnection: connectionIB,
15-
data_blob: dataBlob,
15+
data: dataBlob,
1616
log=logtoscreen("ibFXHandlingData"),
1717
):
18-
super().__init__(log=log)
18+
super().__init__(log=log, data=data)
1919
self._ibconnection = ibconnection
20-
self._dataBlob = data_blob
20+
self._data = data
2121

2222
def __repr__(self):
2323
return "IB FX handling data %s" % str(self.ib_client)

sysbrokers/IB/ib_instruments_data.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ class ibFuturesInstrumentData(brokerFuturesInstrumentData):
4242
def __init__(
4343
self,
4444
ibconnection: connectionIB,
45-
data_blob: dataBlob,
45+
data: dataBlob,
4646
log=logtoscreen("ibFuturesContractData"),
4747
):
48-
super().__init__(log=log)
48+
super().__init__(log=log, data=data)
4949
self._ibconnection = ibconnection
50-
self._dataBlob = data_blob
5150

5251
def __repr__(self):
5352
return "IB Futures per contract data %s" % str(self.ibconnection)

sysbrokers/IB/ib_orders.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,15 @@ class ibExecutionStackData(brokerExecutionStackData):
9595
def __init__(
9696
self,
9797
ibconnection: connectionIB,
98-
data_blob: dataBlob,
98+
data: dataBlob,
9999
log=logtoscreen("ibExecutionStackData"),
100100
):
101-
super().__init__(log=log)
101+
super().__init__(log=log, data=data)
102102
self._ibconnection = ibconnection
103-
self._dataBlob = data_blob
104103

105104
def __repr__(self):
106105
return "IB orders %s" % str(self.ib_client)
107106

108-
@property
109-
def data(self):
110-
return self._dataBlob
111-
112107
@property
113108
def ibconnection(self) -> connectionIB:
114109
return self._ibconnection

sysbrokers/IB/ib_static_data.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ class ibStaticData(brokerStaticData):
99
def __init__(
1010
self,
1111
ibconnection: connectionIB,
12-
data_blob: dataBlob,
12+
data: dataBlob,
1313
log=logtoscreen("ibStaticData"),
1414
):
15-
super().__init__(log=log)
15+
super().__init__(log=log, data=data)
1616
self._ibconnection = ibconnection
17-
self._dataBlob = data_blob
1817

1918
def __repr__(self):
2019
return "IB static data %s" % str(self.ib_client)

sysbrokers/broker_capital_data.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
from sysdata.production.new_capital import capitalData
66
from syslogdiag.logger import logger
77
from syslogdiag.log_to_screen import logtoscreen
8+
from sysdata.data_blob import dataBlob
89

910

1011
class brokerCapitalData(capitalData):
11-
def __init__(self, log: logger = logtoscreen("brokerCapitalData")):
12+
def __init__(self, data: dataBlob, log: logger = logtoscreen("brokerCapitalData")):
13+
1214
super().__init__(log=log)
15+
self._data = data
1316

1417
def get_account_value_across_currency(
1518
self, account_id: str = arg_not_supplied
@@ -20,3 +23,7 @@ def get_excess_liquidity_value_across_currency(
2023
self, account_id: str = arg_not_supplied
2124
) -> listOfCurrencyValues:
2225
raise NotImplementedError
26+
27+
@property
28+
def data(self) -> dataBlob:
29+
return self._data

sysbrokers/broker_contract_position_data.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
from syscore.constants import arg_not_supplied
44

55
from sysdata.production.historic_positions import contractPositionData
6-
6+
from sysdata.data_blob import dataBlob
77
from sysobjects.production.positions import listOfContractPositions
88

99

1010
class brokerContractPositionData(contractPositionData):
11-
def __init__(self, log=logtoscreen("brokerFuturesContractPriceData")):
11+
def __init__(
12+
self, data: dataBlob, log=logtoscreen("brokerFuturesContractPriceData")
13+
):
1214
super().__init__(log=log)
15+
self._data = data
1316

1417
def get_all_current_positions_as_list_with_contract_objects(
1518
self, account_id=arg_not_supplied
@@ -39,3 +42,7 @@ def _get_list_of_args_dict(self) -> list:
3942

4043
def get_list_of_instruments_with_any_position(self):
4144
raise Exception("Not implemented for broker")
45+
46+
@property
47+
def data(self):
48+
return self._data

sysbrokers/broker_execution_stack.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### An inheritance of a general order stack that includes methods for actually talking to the broker
22
from syscore.constants import arg_not_supplied
3+
from sysdata.data_blob import dataBlob
34

45
from sysexecution.order_stacks.broker_order_stack import brokerOrderStackData
56
from sysexecution.order_stacks.broker_order_stack import orderWithControls
@@ -11,8 +12,9 @@
1112

1213

1314
class brokerExecutionStackData(brokerOrderStackData):
14-
def __init__(self, log=logtoscreen("brokerExecutionStackData")):
15+
def __init__(self, data: dataBlob, log=logtoscreen("brokerExecutionStackData")):
1516
super().__init__(log=log)
17+
self._data = data
1618

1719
def get_list_of_broker_orders_with_account_id(
1820
self, account_id: str = arg_not_supplied
@@ -48,3 +50,7 @@ def modify_limit_price_given_control_object(
4850
) -> orderWithControls:
4951
# throw orderCannotBeModified if can't be modified
5052
raise NotImplementedError
53+
54+
@property
55+
def data(self):
56+
return self._data

sysbrokers/broker_futures_contract_data.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
from syscore.exceptions import missingContract
33
from syscore.constants import market_closed
44
from sysdata.futures.contracts import futuresContractData
5-
5+
from sysdata.data_blob import dataBlob
66
from sysobjects.contract_dates_and_expiries import expiryDate
77
from sysobjects.contracts import futuresContract
88

99
from syslogdiag.log_to_screen import logtoscreen
1010

1111

1212
class brokerFuturesContractData(futuresContractData):
13-
def __init__(self, log=logtoscreen("brokerFuturesContractData")):
13+
def __init__(self, data: dataBlob, log=logtoscreen("brokerFuturesContractData")):
1414
super().__init__(log=log)
15+
self._data = data
1516

1617
def get_actual_expiry_date_for_single_contract(
1718
self, futures_contract: futuresContract
@@ -79,3 +80,7 @@ def _add_contract_object_without_checking_for_existing_entry(
7980
self, contract_object: futuresContract
8081
):
8182
raise NotImplementedError("Broker is read only")
83+
84+
@property
85+
def data(self):
86+
return self._data

sysbrokers/broker_futures_contract_price_data.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sysdata.futures.futures_per_contract_prices import (
44
futuresContractPriceData,
55
)
6-
6+
from sysdata.data_blob import dataBlob
77

88
from sysexecution.tick_data import tickerObject, dataFrameOfRecentTicks
99
from sysexecution.orders.contract_orders import contractOrder
@@ -24,8 +24,11 @@ class brokerFuturesContractPriceData(futuresContractPriceData):
2424
2525
"""
2626

27-
def __init__(self, log=logtoscreen("brokerFuturesContractPriceData")):
27+
def __init__(
28+
self, data: dataBlob, log=logtoscreen("brokerFuturesContractPriceData")
29+
):
2830
super().__init__(log=log)
31+
self._data = data
2932

3033
def get_prices_at_frequency_for_potentially_expired_contract_object(
3134
self, contract: futuresContract, freq: Frequency = DAILY_PRICE_FREQ
@@ -53,3 +56,7 @@ def _delete_merged_prices_for_contract_object_with_no_checks_be_careful(
5356
self, futures_contract_object: futuresContract
5457
):
5558
raise NotImplementedError("Broker is a read only source of prices")
59+
60+
@property
61+
def data(self):
62+
return self._data

sysbrokers/broker_fx_handling.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from syscore.constants import arg_not_supplied
22
from sysdata.base_data import baseData
3+
from sysdata.data_blob import dataBlob
34
from sysbrokers.broker_trade import brokerTrade
45

56
from syslogdiag.log_to_screen import logtoscreen
67

78

89
### generic base class for FX handling
910
class brokerFxHandlingData(baseData):
10-
def __init__(self, log=logtoscreen("brokerFXHandlingData")):
11+
def __init__(self, data: dataBlob, log=logtoscreen("brokerFXHandlingData")):
1112
super().__init__(log=log)
13+
self._data = data
1214

1315
def broker_fx_balances(self, account_id: str = arg_not_supplied) -> dict:
1416
raise NotImplementedError
@@ -22,3 +24,7 @@ def broker_fx_market_order(
2224
) -> brokerTrade:
2325

2426
raise NotImplementedError
27+
28+
@property
29+
def data(self) -> dataBlob:
30+
return self._data

sysbrokers/broker_fx_prices_data.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from sysdata.data_blob import dataBlob
12
from sysdata.fx.spotfx import fxPricesData
23
from sysobjects.spot_fx_prices import fxPrices
34
from syslogdiag.log_to_screen import logtoscreen
45

56

67
class brokerFxPricesData(fxPricesData):
7-
def __init__(self, log=logtoscreen("brokerFxPricesData")):
8+
def __init__(self, data: dataBlob, log=logtoscreen("brokerFxPricesData")):
89
super().__init__(log=log)
10+
self._data = data
911

1012
def get_list_of_fxcodes(self) -> list:
1113
raise NotImplementedError
@@ -24,3 +26,7 @@ def _delete_fx_prices_without_any_warning_be_careful(self, *args, **kwargs):
2426

2527
def _add_fx_prices_without_checking_for_existing_entry(self, *args, **kwargs):
2628
raise NotImplementedError("Broker is a read only source of prices")
29+
30+
@property
31+
def data(self) -> dataBlob:
32+
return self._data

sysbrokers/broker_instrument_data.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from sysdata.data_blob import dataBlob
12
from sysdata.futures.instruments import futuresInstrumentData
23

34
from syslogdiag.log_to_screen import logtoscreen
@@ -12,8 +13,9 @@ class brokerFuturesInstrumentData(futuresInstrumentData):
1213
1314
"""
1415

15-
def __init__(self, log=logtoscreen("brokerFuturesInstrumentData")):
16+
def __init__(self, data: dataBlob, log=logtoscreen("brokerFuturesInstrumentData")):
1617
super().__init__(log=log)
18+
self._data = data
1719

1820
def get_brokers_instrument_code(self, instrument_code: str) -> str:
1921
raise NotImplementedError
@@ -23,3 +25,7 @@ def get_instrument_code_from_broker_code(self, broker_code: str) -> str:
2325

2426
def get_list_of_instruments(self) -> list:
2527
raise NotImplementedError
28+
29+
@property
30+
def data(self) -> dataBlob:
31+
return self._data

sysbrokers/broker_static_data.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from sysdata.base_data import baseData
2+
from sysdata.data_blob import dataBlob
23
from syslogdiag.log_to_screen import logtoscreen
34

45

56
class brokerStaticData(baseData):
6-
def __init__(self, log=logtoscreen("brokerStaticData")):
7+
def __init__(self, data: dataBlob, log=logtoscreen("brokerStaticData")):
78
super().__init__(log=log)
9+
self._data = data
810

911
def get_broker_clientid(self) -> int:
1012
raise NotImplementedError
@@ -14,3 +16,7 @@ def get_broker_account(self) -> str:
1416

1517
def get_broker_name(self) -> str:
1618
raise NotImplementedError
19+
20+
@property
21+
def data(self) -> dataBlob:
22+
return self._data

0 commit comments

Comments
 (0)