forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathib_capital_data.py
56 lines (45 loc) · 1.7 KB
/
ib_capital_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from sysbrokers.IB.ib_connection import connectionIB
from sysbrokers.IB.client.ib_accounting_client import ibAccountingClient
from sysbrokers.broker_capital_data import brokerCapitalData
from sysdata.data_blob import dataBlob
from syscore.constants import arg_not_supplied
from sysobjects.spot_fx_prices import listOfCurrencyValues
from syslogging.logger import *
class ibCapitalData(brokerCapitalData):
def __init__(
self,
ibconnection: connectionIB,
data: dataBlob,
log: pst_logger = get_logger("ibCapitalData"),
):
super().__init__(log=log, data=data)
self._ibconnection = ibconnection
@property
def ibconnection(self) -> connectionIB:
return self._ibconnection
@property
def ib_client(self) -> ibAccountingClient:
client = getattr(self, "_ib_client", None)
if client is None:
client = self._ib_client = ibAccountingClient(
ibconnection=self.ibconnection, log=self.log
)
return client
def __repr__(self):
return "IB capital data"
def get_account_value_across_currency(
self, account_id: str = arg_not_supplied
) -> listOfCurrencyValues:
return self.ib_client.broker_get_account_value_across_currency(
account_id=account_id
)
def get_excess_liquidity_value_across_currency(
self, account_id: str = arg_not_supplied
) -> listOfCurrencyValues:
return self.ib_client.broker_get_excess_liquidity_value_across_currency(
account_id=account_id
)
"""
Can add other functions not in parent class to get IB specific stuff which could be required for
strategy decomposition
"""