siglab-py 0.1.11__py3-none-any.whl → 0.1.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of siglab-py might be problematic. Click here for more details.
- siglab_py/ordergateway/client.py +16 -3
- siglab_py/ordergateway/gateway.py +1 -0
- siglab_py/ordergateway/test_ordergateway.py +4 -4
- {siglab_py-0.1.11.dist-info → siglab_py-0.1.12.dist-info}/METADATA +1 -1
- {siglab_py-0.1.11.dist-info → siglab_py-0.1.12.dist-info}/RECORD +7 -7
- {siglab_py-0.1.11.dist-info → siglab_py-0.1.12.dist-info}/WHEEL +0 -0
- {siglab_py-0.1.11.dist-info → siglab_py-0.1.12.dist-info}/top_level.txt +0 -0
siglab_py/ordergateway/client.py
CHANGED
|
@@ -31,13 +31,15 @@ class Order:
|
|
|
31
31
|
side : str, # buy/sell
|
|
32
32
|
amount : float,
|
|
33
33
|
order_type : str, # market/limit
|
|
34
|
-
leg_room_bps : float = 0
|
|
34
|
+
leg_room_bps : float = 0,
|
|
35
|
+
fees_ccy : Union[str, None] = None
|
|
35
36
|
) -> None:
|
|
36
37
|
self.ticker = ticker
|
|
37
38
|
self.side = side.strip().lower()
|
|
38
39
|
self.amount = amount
|
|
39
40
|
self.order_type = order_type.strip().lower()
|
|
40
41
|
self.leg_room_bps = leg_room_bps
|
|
42
|
+
self.fees_ccy = fees_ccy
|
|
41
43
|
|
|
42
44
|
def to_dict(self) -> Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES]:
|
|
43
45
|
return {
|
|
@@ -45,7 +47,8 @@ class Order:
|
|
|
45
47
|
"side" : self.side,
|
|
46
48
|
"amount" : self.amount,
|
|
47
49
|
"order_type" : self.order_type,
|
|
48
|
-
"leg_room_bps" : self.leg_room_bps
|
|
50
|
+
"leg_room_bps" : self.leg_room_bps,
|
|
51
|
+
"fees_ccy" : self.fees_ccy
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
'''
|
|
@@ -60,15 +63,17 @@ class DivisiblePosition(Order):
|
|
|
60
63
|
amount : float,
|
|
61
64
|
order_type : str, # market/limit
|
|
62
65
|
leg_room_bps : float,
|
|
66
|
+
fees_ccy : Union[str, None] = None,
|
|
63
67
|
slices : int = 1,
|
|
64
68
|
wait_fill_threshold_ms : float = -1
|
|
65
69
|
) -> None:
|
|
66
|
-
super().__init__(ticker, side, amount, order_type, leg_room_bps)
|
|
70
|
+
super().__init__(ticker, side, amount, order_type, leg_room_bps, fees_ccy)
|
|
67
71
|
self.slices = slices
|
|
68
72
|
self.wait_fill_threshold_ms = wait_fill_threshold_ms
|
|
69
73
|
self.multiplier = 1
|
|
70
74
|
self.filled_amount : Union[float, None] = None
|
|
71
75
|
self.average_cost : Union[float, None] = None
|
|
76
|
+
self.fees : Union[float, None] = None
|
|
72
77
|
self.pos : Union[float, None] = None # in base ccy, after execution. (Not in USDT or quote ccy, Not in # contracts)
|
|
73
78
|
|
|
74
79
|
self.executions : Dict[str, Dict[str, Any]] = {}
|
|
@@ -86,6 +91,7 @@ class DivisiblePosition(Order):
|
|
|
86
91
|
side=self.side,
|
|
87
92
|
amount=slice_amount_in_base_ccy,
|
|
88
93
|
leg_room_bps=self.leg_room_bps,
|
|
94
|
+
fees_ccy=self.fees_ccy,
|
|
89
95
|
order_type=self.order_type)
|
|
90
96
|
|
|
91
97
|
else:
|
|
@@ -95,6 +101,7 @@ class DivisiblePosition(Order):
|
|
|
95
101
|
side=self.side,
|
|
96
102
|
amount=remaining_amount_in_base_ccy,
|
|
97
103
|
leg_room_bps=self.leg_room_bps,
|
|
104
|
+
fees_ccy=self.fees_ccy,
|
|
98
105
|
order_type=self.order_type)
|
|
99
106
|
|
|
100
107
|
slices.append(slice)
|
|
@@ -171,6 +178,12 @@ class DivisiblePosition(Order):
|
|
|
171
178
|
average_cost = average_cost / sum([ self.executions[order_id]['amount'] for order_id in self.executions ])
|
|
172
179
|
return average_cost
|
|
173
180
|
|
|
181
|
+
def get_fees(self) -> float:
|
|
182
|
+
fees : float = 0
|
|
183
|
+
if self.fees_ccy:
|
|
184
|
+
fees = sum([ float(self.executions[order_id]['fee']['cost']) for order_id in self.executions if self.executions[order_id]['fee'] and self.executions[order_id]['fee']['currency'].strip().upper()==self.fees_ccy.strip().upper() ])
|
|
185
|
+
return fees
|
|
186
|
+
|
|
174
187
|
def to_dict(self) -> Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES]:
|
|
175
188
|
rv = super().to_dict()
|
|
176
189
|
rv['slices'] = self.slices
|
|
@@ -649,6 +649,7 @@ async def execute_one_position(
|
|
|
649
649
|
|
|
650
650
|
position.filled_amount = position.get_filled_amount()
|
|
651
651
|
position.average_cost = position.get_average_cost()
|
|
652
|
+
position.fees = position.get_fees()
|
|
652
653
|
|
|
653
654
|
balances = await exchange.fetch_balance() # type: ignore
|
|
654
655
|
if param['default_type']!='spot':
|
|
@@ -77,12 +77,12 @@ if __name__ == '__main__':
|
|
|
77
77
|
|
|
78
78
|
positions_2 : List[DivisiblePosition] = [
|
|
79
79
|
DivisiblePosition(
|
|
80
|
-
ticker = 'SUSHI/
|
|
81
|
-
side = '
|
|
82
|
-
amount =
|
|
80
|
+
ticker = 'SUSHI/USDT:USDT',
|
|
81
|
+
side = 'buy',
|
|
82
|
+
amount = 10,
|
|
83
83
|
leg_room_bps = 5,
|
|
84
84
|
order_type = 'limit',
|
|
85
|
-
slices=
|
|
85
|
+
slices=5,
|
|
86
86
|
wait_fill_threshold_ms=15000
|
|
87
87
|
),
|
|
88
88
|
]
|
|
@@ -10,10 +10,10 @@ siglab_py/market_data_providers/deribit_options_expiry_provider.py,sha256=e9Ee8T
|
|
|
10
10
|
siglab_py/market_data_providers/orderbooks_provider.py,sha256=cBp-HYCups2Uiwzw0SaUwxrg4unJvnm2TDqIK8f4hUg,15674
|
|
11
11
|
siglab_py/market_data_providers/test_provider.py,sha256=wBLCgcWjs7FGZJXWsNyn30lkOLa_cgpuvqRakMC0wbA,2221
|
|
12
12
|
siglab_py/ordergateway/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
siglab_py/ordergateway/client.py,sha256=
|
|
13
|
+
siglab_py/ordergateway/client.py,sha256=MW35JPeBAtayu4pNdpPVflabTZL51PwqSznDadteO1A,8973
|
|
14
14
|
siglab_py/ordergateway/encrypt_keys_util.py,sha256=-qi87db8To8Yf1WS1Q_Cp2Ya7ZqgWlRqSHfNXCM7wE4,1339
|
|
15
|
-
siglab_py/ordergateway/gateway.py,sha256=
|
|
16
|
-
siglab_py/ordergateway/test_ordergateway.py,sha256=
|
|
15
|
+
siglab_py/ordergateway/gateway.py,sha256=t1gnmd1TazVA50_-j5PqsmxVjtikAcA6TRbe743T6Qs,35487
|
|
16
|
+
siglab_py/ordergateway/test_ordergateway.py,sha256=DH4djEZeWZr69lTx_xG9_N8S_E2wAG4S3430VisU5w4,3805
|
|
17
17
|
siglab_py/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
siglab_py/tests/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
siglab_py/tests/integration/market_data_util_tests.py,sha256=HFESIXEdQmrbDV3DvLiDLq0iE-4itysxSFur_Th4jjE,5207
|
|
@@ -24,7 +24,7 @@ siglab_py/util/analytic_util.py,sha256=QLabbEMqM4rKKH2PE_LqxIyo-BUdCRhkLybLATBIm
|
|
|
24
24
|
siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
|
|
25
25
|
siglab_py/util/market_data_util.py,sha256=3qTq71xGvQXj0ORKJV50IN5FP_mCBF_gvdmlPyhdyco,16439
|
|
26
26
|
siglab_py/util/retry_util.py,sha256=mxYuRFZRZoaQQjENcwPmxhxixtd1TFvbxIdPx4RwfRc,743
|
|
27
|
-
siglab_py-0.1.
|
|
28
|
-
siglab_py-0.1.
|
|
29
|
-
siglab_py-0.1.
|
|
30
|
-
siglab_py-0.1.
|
|
27
|
+
siglab_py-0.1.12.dist-info/METADATA,sha256=8Kl22xSXPW_oxgIxBHzHlEO0oENGTbZPnSnT6ju-Lm4,1097
|
|
28
|
+
siglab_py-0.1.12.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
29
|
+
siglab_py-0.1.12.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
|
|
30
|
+
siglab_py-0.1.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|