siglab-py 0.1.31__py3-none-any.whl → 0.1.33__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 +3 -3
- siglab_py/util/analytic_util.py +18 -12
- {siglab_py-0.1.31.dist-info → siglab_py-0.1.33.dist-info}/METADATA +1 -1
- {siglab_py-0.1.31.dist-info → siglab_py-0.1.33.dist-info}/RECORD +6 -6
- {siglab_py-0.1.31.dist-info → siglab_py-0.1.33.dist-info}/WHEEL +0 -0
- {siglab_py-0.1.31.dist-info → siglab_py-0.1.33.dist-info}/top_level.txt +0 -0
siglab_py/ordergateway/client.py
CHANGED
|
@@ -138,7 +138,7 @@ class DivisiblePosition(Order):
|
|
|
138
138
|
|
|
139
139
|
def get_filled_amount(self) -> float:
|
|
140
140
|
# filled_amount is in base ccy
|
|
141
|
-
filled_amount = sum([ self.executions[order_id]['filled'] if 'filled' in self.executions[order_id] else 0 * self.multiplier for order_id in self.executions ])
|
|
141
|
+
filled_amount = sum([ self.executions[order_id]['filled'] if 'filled' in self.executions[order_id] and self.executions[order_id]['filled'] else 0 * self.multiplier for order_id in self.executions ])
|
|
142
142
|
if self.side=='sell':
|
|
143
143
|
filled_amount = -1 * filled_amount
|
|
144
144
|
return filled_amount
|
|
@@ -189,14 +189,14 @@ class DivisiblePosition(Order):
|
|
|
189
189
|
}
|
|
190
190
|
'''
|
|
191
191
|
total_amount : float = sum([ self.executions[order_id]['amount'] for order_id in self.executions ])
|
|
192
|
-
average_cost = sum([ (self.executions[order_id]['average'] if 'average' in self.executions[order_id] else 0 if self.executions[order_id]['average'] else self.executions[order_id]['price']) * self.executions[order_id]['amount'] for order_id in self.executions ])
|
|
192
|
+
average_cost = sum([ (self.executions[order_id]['average'] if 'average' in self.executions[order_id] and self.executions[order_id]['average'] else 0 if self.executions[order_id]['average'] else self.executions[order_id]['price']) * self.executions[order_id]['amount'] for order_id in self.executions ])
|
|
193
193
|
average_cost = average_cost / total_amount if total_amount!=0 else 0
|
|
194
194
|
return average_cost
|
|
195
195
|
|
|
196
196
|
def get_fees(self) -> float:
|
|
197
197
|
fees : float = 0
|
|
198
198
|
if self.fees_ccy:
|
|
199
|
-
fees = sum([ float(self.executions[order_id]['fee']['cost'] if self.executions[order_id]['fee'] else 0) 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() ])
|
|
199
|
+
fees = sum([ float(self.executions[order_id]['fee']['cost'] if self.executions[order_id]['fee'] and self.executions[order_id]['fee']['cost'] else 0) 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() ])
|
|
200
200
|
return fees
|
|
201
201
|
|
|
202
202
|
def to_dict(self) -> Dict[JSON_SERIALIZABLE_TYPES, JSON_SERIALIZABLE_TYPES]:
|
siglab_py/util/analytic_util.py
CHANGED
|
@@ -86,11 +86,17 @@ def compute_candles_stats(
|
|
|
86
86
|
|
|
87
87
|
pd_candles['is_green'] = pd_candles['close'] >= pd_candles['open']
|
|
88
88
|
|
|
89
|
+
close_short_periods_rolling = pd_candles['close'].rolling(window=int(sliding_window_how_many_candles/slow_fast_interval_ratio))
|
|
90
|
+
close_long_periods_rolling = pd_candles['close'].rolling(window=sliding_window_how_many_candles)
|
|
91
|
+
close_short_periods_ewm = pd_candles['close'].ewm(span=int(sliding_window_how_many_candles/slow_fast_interval_ratio), adjust=False)
|
|
92
|
+
close_long_periods_ewm = pd_candles['close'].ewm(span=sliding_window_how_many_candles, adjust=False)
|
|
93
|
+
|
|
94
|
+
|
|
89
95
|
pd_candles['pct_change_close'] = pd_candles['close'].pct_change() * 100
|
|
90
|
-
pd_candles['sma_short_periods'] =
|
|
91
|
-
pd_candles['sma_long_periods'] =
|
|
92
|
-
pd_candles['ema_short_periods'] =
|
|
93
|
-
pd_candles['ema_long_periods'] =
|
|
96
|
+
pd_candles['sma_short_periods'] = close_short_periods_rolling.mean()
|
|
97
|
+
pd_candles['sma_long_periods'] = close_long_periods_rolling.mean()
|
|
98
|
+
pd_candles['ema_short_periods'] = close_short_periods_ewm.mean()
|
|
99
|
+
pd_candles['ema_long_periods'] = close_long_periods_ewm.mean()
|
|
94
100
|
pd_candles['ema_close'] = pd_candles['ema_long_periods'] # Alias, shorter name
|
|
95
101
|
pd_candles['std'] = pd_candles['close'].rolling(window=sliding_window_how_many_candles).std()
|
|
96
102
|
|
|
@@ -106,15 +112,15 @@ def compute_candles_stats(
|
|
|
106
112
|
pd_candles['ema_volume_short_periods'] = pd_candles['volume'].ewm(span=sliding_window_how_many_candles/slow_fast_interval_ratio, adjust=False).mean()
|
|
107
113
|
pd_candles['ema_volume_long_periods'] = pd_candles['volume'].ewm(span=sliding_window_how_many_candles, adjust=False).mean()
|
|
108
114
|
|
|
109
|
-
pd_candles['max_short_periods'] =
|
|
110
|
-
pd_candles['max_long_periods'] =
|
|
111
|
-
pd_candles['idmax_short_periods'] =
|
|
112
|
-
pd_candles['idmax_long_periods'] =
|
|
115
|
+
pd_candles['max_short_periods'] = close_short_periods_rolling.max()
|
|
116
|
+
pd_candles['max_long_periods'] = close_long_periods_rolling.max()
|
|
117
|
+
pd_candles['idmax_short_periods'] = close_short_periods_rolling.apply(lambda x : x.idxmax())
|
|
118
|
+
pd_candles['idmax_long_periods'] = close_long_periods_rolling.apply(lambda x : x.idxmax())
|
|
113
119
|
|
|
114
|
-
pd_candles['min_short_periods'] =
|
|
115
|
-
pd_candles['min_long_periods'] =
|
|
116
|
-
pd_candles['idmin_short_periods'] =
|
|
117
|
-
pd_candles['idmin_long_periods'] =
|
|
120
|
+
pd_candles['min_short_periods'] = close_short_periods_rolling.min()
|
|
121
|
+
pd_candles['min_long_periods'] = close_long_periods_rolling.min()
|
|
122
|
+
pd_candles['idmin_short_periods'] = close_short_periods_rolling.apply(lambda x : x.idxmin())
|
|
123
|
+
pd_candles['idmin_long_periods'] = close_long_periods_rolling.apply(lambda x : x.idxmin())
|
|
118
124
|
|
|
119
125
|
|
|
120
126
|
# ATR https://medium.com/codex/detecting-ranging-and-trending-markets-with-choppiness-index-in-python-1942e6450b58
|
|
@@ -13,7 +13,7 @@ siglab_py/market_data_providers/futu_candles_ta_to_csv.py,sha256=S4GXaJ7AveEh-Cm
|
|
|
13
13
|
siglab_py/market_data_providers/orderbooks_provider.py,sha256=olt-3LIkoyzQWfNNQRhJtKibLbkTutt_q_rCCTM7i1g,16216
|
|
14
14
|
siglab_py/market_data_providers/test_provider.py,sha256=wBLCgcWjs7FGZJXWsNyn30lkOLa_cgpuvqRakMC0wbA,2221
|
|
15
15
|
siglab_py/ordergateway/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
siglab_py/ordergateway/client.py,sha256=
|
|
16
|
+
siglab_py/ordergateway/client.py,sha256=XgY4l8ue2f1hrFAla6VwzpFzsOmIW-6SkvulOGSVAGQ,9841
|
|
17
17
|
siglab_py/ordergateway/encrypt_keys_util.py,sha256=-qi87db8To8Yf1WS1Q_Cp2Ya7ZqgWlRqSHfNXCM7wE4,1339
|
|
18
18
|
siglab_py/ordergateway/gateway.py,sha256=FoE-OUBrHJ2fdKAfvGue1yQ2P67falWoyoEGCV8ScfA,37219
|
|
19
19
|
siglab_py/ordergateway/test_ordergateway.py,sha256=_Gz2U_VqljogGWqGyNDYYls1INqUiig9veyPttfGRpg,3901
|
|
@@ -24,11 +24,11 @@ siglab_py/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
|
24
24
|
siglab_py/tests/unit/analytic_util_tests.py,sha256=BzT__hxfqXMRAKvqtYDVYNrcMGGDF3-gFoXhxiJ0Lew,3703
|
|
25
25
|
siglab_py/tests/unit/market_data_util_tests.py,sha256=A1y83itISmMJdn6wLpfwcr4tGola8wTf1D1xbelMvgw,2026
|
|
26
26
|
siglab_py/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
siglab_py/util/analytic_util.py,sha256=
|
|
27
|
+
siglab_py/util/analytic_util.py,sha256=xo9gD1ELQt_1v84yu9d4NgxtOIXthePZGipvDrjZAQ8,43834
|
|
28
28
|
siglab_py/util/aws_util.py,sha256=KGmjHrr1rpnnxr33nXHNzTul4tvyyxl9p6gpwNv0Ygc,2557
|
|
29
29
|
siglab_py/util/market_data_util.py,sha256=qRKsFKZMYsaC18ImSWug6dRAOo2_GS1NZM-j0EYMViE,19319
|
|
30
30
|
siglab_py/util/retry_util.py,sha256=mxYuRFZRZoaQQjENcwPmxhxixtd1TFvbxIdPx4RwfRc,743
|
|
31
|
-
siglab_py-0.1.
|
|
32
|
-
siglab_py-0.1.
|
|
33
|
-
siglab_py-0.1.
|
|
34
|
-
siglab_py-0.1.
|
|
31
|
+
siglab_py-0.1.33.dist-info/METADATA,sha256=skhdhJMkkOwglY5aDjlkzczs9xb-FSXrlLYGuxeFntU,980
|
|
32
|
+
siglab_py-0.1.33.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
33
|
+
siglab_py-0.1.33.dist-info/top_level.txt,sha256=AbD4VR9OqmMOGlMJLkAVPGQMtUPIQv0t1BF5xmcLJSk,10
|
|
34
|
+
siglab_py-0.1.33.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|