siglab-py 0.5.38__tar.gz → 0.5.48__tar.gz

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.

Files changed (45) hide show
  1. {siglab_py-0.5.38 → siglab_py-0.5.48}/PKG-INFO +1 -1
  2. {siglab_py-0.5.38 → siglab_py-0.5.48}/pyproject.toml +1 -1
  3. {siglab_py-0.5.38 → siglab_py-0.5.48}/setup.cfg +1 -1
  4. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/exchanges/futubull.py +11 -2
  5. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py +6 -4
  6. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/ordergateway/encrypt_keys_util.py +1 -1
  7. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/unit/analytic_util_tests.py +4 -2
  8. siglab_py-0.5.48/siglab_py/tests/unit/simple_math_tests.py +87 -0
  9. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/analytic_util.py +10 -1
  10. siglab_py-0.5.48/siglab_py/util/simple_math.py +30 -0
  11. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py.egg-info/PKG-INFO +1 -1
  12. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py.egg-info/SOURCES.txt +2 -0
  13. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/__init__.py +0 -0
  14. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/constants.py +0 -0
  15. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/exchanges/__init__.py +0 -0
  16. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/exchanges/any_exchange.py +0 -0
  17. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/__init__.py +0 -0
  18. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/aggregated_orderbook_provider.py +0 -0
  19. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/candles_provider.py +0 -0
  20. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/candles_ta_provider.py +0 -0
  21. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py +0 -0
  22. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/deribit_options_expiry_provider.py +0 -0
  23. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/orderbooks_provider.py +0 -0
  24. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/test_provider.py +0 -0
  25. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/market_data_providers/tg_monitor.py +0 -0
  26. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/ordergateway/__init__.py +0 -0
  27. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/ordergateway/client.py +0 -0
  28. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/ordergateway/gateway.py +0 -0
  29. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/ordergateway/test_ordergateway.py +0 -0
  30. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/__init__.py +0 -0
  31. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/integration/__init__.py +0 -0
  32. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/integration/market_data_util_tests.py +0 -0
  33. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/unit/__init__.py +0 -0
  34. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/unit/market_data_util_tests.py +0 -0
  35. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/tests/unit/trading_util_tests.py +0 -0
  36. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/__init__.py +0 -0
  37. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/aws_util.py +0 -0
  38. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/market_data_util.py +0 -0
  39. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/notification_util.py +0 -0
  40. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/retry_util.py +0 -0
  41. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/slack_notification_util.py +0 -0
  42. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py/util/trading_util.py +0 -0
  43. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py.egg-info/dependency_links.txt +0 -0
  44. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py.egg-info/requires.txt +0 -0
  45. {siglab_py-0.5.38 → siglab_py-0.5.48}/siglab_py.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: siglab_py
3
- Version: 0.5.38
3
+ Version: 0.5.48
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "siglab_py"
7
- version = "0.5.38"
7
+ version = "0.5.48"
8
8
  description = "Market data fetches, TA calculations and generic order gateway."
9
9
  authors = [{name = "r0bbarh00d", email = "r0bbarh00d@gmail.com"}]
10
10
  license = {text = "MIT"}
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = siglab_py
3
- version = 0.5.38
3
+ version = 0.5.48
4
4
  description = Market data fetches, TA calculations and generic order gateway.
5
5
  author = r0bbarh00d
6
6
  author_email = r0bbarh00d@gmail.com
@@ -4,7 +4,7 @@ https://www.futuhk.com/en/support/categories/909?global_content=%7B%22promote_id
4
4
 
5
5
  Fees: https://www.futuhk.com/en/commissionnew#crypto
6
6
 
7
- Subscribe L2 data: https://openapi.futunn.com/futu-api-doc/en/intro/authority.html#5331
7
+ Subscribe L2 data: https://openapi.futunn.com/futu-api-doc/en/intro/authority.html
8
8
 
9
9
  Investor Protection: https://www.futuhk.com/en
10
10
 
@@ -15,8 +15,17 @@ Margin Trading:
15
15
  Download Futu OpenD
16
16
  https://www.futuhk.com/en/support/topic1_464?global_content=%7B%22promote_id%22%3A13765%2C%22sub_promote_id%22%3A10%7D
17
17
 
18
- If you run the installer version "Futu_OpenD-GUI_9.0.5008_Windows.exe", it'd be installed under:
18
+ If you run the installer version "Futu_OpenD-GUI_9.0.5008_Windows.exe", it'd be installed under C-Drive:
19
19
  C:\\Users\\xxx\\AppData\\Roaming\\Futu_OpenD\\Futu_OpenD.exe
20
+ Unfortunately, log folder also under C-drive as a result, and they are big.
21
+
22
+ For command line version: https://openapi.futunn.com/futu-api-doc/opend/opend-cmd.html
23
+ Binary under downloaded package (You can put it under for example D-drive):
24
+ ...\Futu_OpenD_9.4.5408_Windows\Futu_OpenD_9.4.5408_Windows
25
+
26
+ Put a batch file "start_futu_opend.bat", if login_pwd include special characters, enclose pwd with double quotes:
27
+ FutuOpenD -login_account=1234567 -login_pwd="... Your Secret here ..."
28
+ Config file is "FutuOpenD.xml", you can adjust logging verbosity here.
20
29
 
21
30
  Architecture: https://openapi.futunn.com/futu-api-doc/en/intro/intro.html
22
31
 
@@ -17,15 +17,17 @@ from siglab_py.util.analytic_util import compute_candles_stats
17
17
  '''
18
18
  Usage:
19
19
  set PYTHONPATH=%PYTHONPATH%;D:\dev\siglab\siglab_py
20
- python futu_candles_ta_to_csv.py --symbol HK.00700 --end_date "2025-03-11 0:0:0" --start_date "2021-03-11 0:0:0" --market HK --trdmarket HK --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible N
20
+ python futu_candles_ta_to_csv.py --symbol HK.00700 --end_date "2025-03-11 0:0:0" --start_date "2021-03-11 0:0:0" --candle_size 1h --market HK --trdmarket HK --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible N
21
+ python futu_candles_ta_to_csv.py --symbol HK.02840 --end_date "2025-07-30 0:0:0" --start_date "2018-01-01 0:0:0" --candle_size 1h --market HK --trdmarket HK --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible N
22
+ python futu_candles_ta_to_csv.py --symbol AAPL --end_date "2025-03-11 0:0:0" --start_date "2024-03-11 0:0:0" --candle_size 1h --market US --trdmarket US --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible N
21
23
 
22
- python futu_candles_ta_to_csv.py --symbol AAPL --end_date "2025-03-11 0:0:0" --start_date "2024-03-11 0:0:0" --market US --trdmarket US --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible N
23
-
24
- Gold contracts? Note, symbol is case sensitive with Futu.
24
+ Gold contracts? Note, symbol is case sensitive with Futu. So, "GCmain" is correct, "GCMain" is in-correct.
25
25
  python futu_candles_ta_to_csv.py --symbol US.GCmain --end_date "2025-03-11 0:0:0" --start_date "2021-03-11 0:0:0" --market US --trdmarket FUTURES --security_firm FUTUSECURITIES --security_type FUTURE --compute_ta Y --pypy_compatible N
26
26
 
27
27
  (Remember: python -mpip install siglab_py)
28
28
 
29
+ Gold future contract specification: https://www.futunn.com/en/futures/GCMAIN-US/contract-specs
30
+
29
31
  This script is pypy compatible. Set "pypy_compatible" to True, in which case "compute_candles_stats" will skip calculation for TAs which requires: scipy, statsmodels, scikit-learn, sklearn.preprocessing
30
32
  pypy futu_candles_ta_to_csv.py --symbol HK.00700 --end_date "2025-03-11 0:0:0" --start_date "2024-03-11 0:0:0" --market HK --trdmarket HK --security_firm FUTUSECURITIES --security_type STOCK --compute_ta Y --pypy_compatible Y
31
33
 
@@ -1,5 +1,5 @@
1
1
  from typing import Union
2
- from util.aws_util import AwsKmsUtil
2
+ from siglab_py.util.aws_util import AwsKmsUtil
3
3
 
4
4
  '''
5
5
  From command line, run 'aws configure' with IAM user's Access key ID and Secret access key. (Assume you have awscli installed)
@@ -45,18 +45,20 @@ class AnalyticUtilTests(unittest.TestCase):
45
45
  'exchange', 'symbol', 'timestamp_ms',
46
46
  'open', 'high', 'low', 'close', 'volume',
47
47
  'datetime', 'datetime_utc', 'year', 'month', 'day', 'hour', 'minute', 'dayofweek',
48
- 'pct_chg_on_close', 'candle_height',
48
+ 'pct_chg_on_close', 'candle_height', 'candle_body_height',
49
49
  'week_of_month', 'apac_trading_hr', 'emea_trading_hr', 'amer_trading_hr',
50
50
  'is_green', 'pct_change_close',
51
51
  'sma_short_periods', 'sma_long_periods', 'ema_short_periods', 'ema_long_periods', 'ema_close',
52
52
  'std', 'std_percent',
53
53
  'vwap_short_periods', 'vwap_long_periods',
54
- 'candle_height_percent', 'candle_height_percent_rounded',
54
+ 'candle_height_percent', 'candle_height_percent_rounded', 'candle_body_height_percent', 'candle_body_height_percent_rounded',
55
55
  'log_return', 'interval_hist_vol', 'annualized_hist_vol',
56
56
  'chop_against_ema',
57
57
  'ema_volume_short_periods', 'ema_volume_long_periods',
58
58
  'ema_cross', 'ema_cross_last', 'ema_bullish_cross_last_id', 'ema_bearish_cross_last_id',
59
59
  'max_short_periods', 'max_long_periods', 'idmax_short_periods', 'idmax_long_periods', 'min_short_periods', 'min_long_periods', 'idmin_short_periods', 'idmin_long_periods',
60
+ 'max_candle_body_height_percent_long_periods', 'idmax_candle_body_height_percent_long_periods',
61
+ 'min_candle_body_height_percent_long_periods', 'idmin_candle_body_height_percent_long_periods',
60
62
  'price_swing_short_periods', 'price_swing_long_periods',
61
63
  'trend_from_highs_long_periods', 'trend_from_lows_long_periods', 'trend_from_highs_short_periods', 'trend_from_lows_short_periods',
62
64
  'h_l', 'h_pc', 'l_pc', 'tr', 'atr', 'atr_avg_short_periods', 'atr_avg_long_periods',
@@ -0,0 +1,87 @@
1
+ import unittest
2
+ from typing import List
3
+
4
+ from util.simple_math import generate_rand_nums
5
+
6
+ class SimpleMathTests(unittest.TestCase):
7
+
8
+ def test_generate_rand_nums(self):
9
+ range_min : float = 0
10
+ range_max : float = 1
11
+ size : int = 100
12
+ percentage_in_range : float = 91
13
+ abs_min : float = -0.5
14
+ abs_max : float = 1.1
15
+
16
+ rand_nums : List[float] = generate_rand_nums(
17
+ range_min = range_min,
18
+ range_max = range_max,
19
+ size = size,
20
+ percent_in_range = percentage_in_range,
21
+ abs_min = abs_min,
22
+ abs_max = abs_max
23
+ )
24
+
25
+ assert(len(rand_nums)==size)
26
+ assert(len([x for x in rand_nums if x>=range_min and x<=range_max]) == (percentage_in_range/100) * size)
27
+ assert(len([x for x in rand_nums if x<abs_min or x>abs_max]) == 0)
28
+
29
+
30
+ range_min = -1
31
+ range_max = 1
32
+ percentage_in_range = 91
33
+ abs_min = -1.5
34
+ abs_max = 1.5
35
+
36
+ rand_nums : List[float] = generate_rand_nums(
37
+ range_min = range_min,
38
+ range_max = range_max,
39
+ size = size,
40
+ percent_in_range = percentage_in_range,
41
+ abs_min = abs_min,
42
+ abs_max = abs_max
43
+ )
44
+
45
+ assert(len(rand_nums)==size)
46
+ assert(len([x for x in rand_nums if x>=range_min and x<=range_max]) == (percentage_in_range/100) * size)
47
+ assert(len([x for x in rand_nums if x<abs_min or x>abs_max]) == 0)
48
+
49
+
50
+ range_min = 0
51
+ range_max = 100
52
+ percentage_in_range = 91
53
+ abs_min = -150
54
+ abs_max = 150
55
+
56
+ rand_nums : List[float] = generate_rand_nums(
57
+ range_min = range_min,
58
+ range_max = range_max,
59
+ size = size,
60
+ percent_in_range = percentage_in_range,
61
+ abs_min = abs_min,
62
+ abs_max = abs_max
63
+ )
64
+
65
+ assert(len(rand_nums)==size)
66
+ assert(len([x for x in rand_nums if x>=range_min and x<=range_max]) == (percentage_in_range/100) * size)
67
+ assert(len([x for x in rand_nums if x<abs_min or x>abs_max]) == 0)
68
+
69
+
70
+ range_min = -100
71
+ range_max = 100
72
+ percentage_in_range = 91
73
+ abs_min = -150
74
+ abs_max = 150
75
+
76
+ rand_nums : List[float] = generate_rand_nums(
77
+ range_min = range_min,
78
+ range_max = range_max,
79
+ size = size,
80
+ percent_in_range = percentage_in_range,
81
+ abs_min = abs_min,
82
+ abs_max = abs_max
83
+ )
84
+
85
+ assert(len(rand_nums)==size)
86
+ assert(len([x for x in rand_nums if x>=range_min and x<=range_max]) == (percentage_in_range/100) * size)
87
+ assert(len([x for x in rand_nums if x<abs_min or x>abs_max]) == 0)
@@ -121,6 +121,7 @@ def compute_candles_stats(
121
121
  pypy_compat : bool = True
122
122
  ):
123
123
  pd_candles['candle_height'] = pd_candles['high'] - pd_candles['low']
124
+ pd_candles['candle_body_height'] = pd_candles['close'] - pd_candles['open']
124
125
 
125
126
  '''
126
127
  market_data_gizmo inserted dummy lines --> Need exclude those or "TypeError: unorderable types for comparison": pd_btc_candles = pd_btc_candles[pd_btc_candles.close.notnull()]
@@ -157,6 +158,9 @@ def compute_candles_stats(
157
158
  pd_candles['candle_height_percent'] = pd_candles['candle_height'] / pd_candles['ema_close'] * 100
158
159
  pd_candles['candle_height_percent_rounded'] = pd_candles['candle_height_percent'].round().astype('Int64')
159
160
 
161
+ pd_candles['candle_body_height_percent'] = pd_candles['candle_body_height'] / pd_candles['ema_close'] * 100
162
+ pd_candles['candle_body_height_percent_rounded'] = pd_candles['candle_body_height_percent'].round().astype('Int64')
163
+
160
164
  '''
161
165
  To annualize volatility:
162
166
  if candle_interval == '1m':
@@ -235,6 +239,11 @@ def compute_candles_stats(
235
239
  pd_candles['idmin_short_periods'] = close_short_periods_rolling.apply(lambda x : x.idxmin())
236
240
  pd_candles['idmin_long_periods'] = close_long_periods_rolling.apply(lambda x : x.idxmin())
237
241
 
242
+ pd_candles['max_candle_body_height_percent_long_periods'] = pd_candles['candle_body_height_percent'].rolling(window=sliding_window_how_many_candles).max()
243
+ pd_candles['idmax_candle_body_height_percent_long_periods'] = pd_candles['candle_body_height_percent'].rolling(window=sliding_window_how_many_candles).apply(lambda x : x.idxmax())
244
+ pd_candles['min_candle_body_height_percent_long_periods'] = pd_candles['candle_body_height_percent'].rolling(window=sliding_window_how_many_candles).min()
245
+ pd_candles['idmin_candle_body_height_percent_long_periods'] = pd_candles['candle_body_height_percent'].rolling(window=sliding_window_how_many_candles).apply(lambda x : x.idxmin())
246
+
238
247
  pd_candles['price_swing_short_periods'] = np.where(
239
248
  pd_candles['idmax_short_periods'] > pd_candles['idmin_short_periods'],
240
249
  pd_candles['max_short_periods'] - pd_candles['min_short_periods'], # Up swing
@@ -580,7 +589,7 @@ def compute_candles_stats(
580
589
  pd_data=pd_candles,
581
590
  src_col_name='ema_rsi',
582
591
  slope_col_name='ema_rsi_slope',
583
- sliding_window_how_many_candles=int(sliding_window_how_many_candles)
592
+ sliding_window_how_many_candles=int(rsi_trend_sliding_window_how_many_candles)
584
593
  )
585
594
 
586
595
  pd_candles['regular_divergence'] = (
@@ -0,0 +1,30 @@
1
+ import random
2
+ from typing import List
3
+
4
+ def generate_rand_nums(
5
+ range_min : float = 0,
6
+ range_max : float = 1,
7
+ size=100, # list size
8
+ percent_in_range : float = 100,
9
+ abs_min : float = 0,
10
+ abs_max : float = 1
11
+ ):
12
+ assert(range_min<range_max)
13
+
14
+ if abs_min>range_min:
15
+ abs_min = range_min
16
+ if abs_max<range_max:
17
+ abs_max = range_max
18
+
19
+ result = []
20
+ for _ in range(int(size * percent_in_range/100)):
21
+ result.append(random.uniform(range_min, range_max))
22
+ for _ in range(size - len(result)):
23
+ if random.uniform(0, 1)>0.5:
24
+ result.append(random.uniform(abs_min, range_min))
25
+ else:
26
+ result.append(random.uniform(range_max, abs_max))
27
+
28
+ random.shuffle(result)
29
+
30
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: siglab_py
3
- Version: 0.5.38
3
+ Version: 0.5.48
4
4
  Summary: Market data fetches, TA calculations and generic order gateway.
5
5
  Author: r0bbarh00d
6
6
  Author-email: r0bbarh00d <r0bbarh00d@gmail.com>
@@ -31,6 +31,7 @@ siglab_py/tests/integration/market_data_util_tests.py
31
31
  siglab_py/tests/unit/__init__.py
32
32
  siglab_py/tests/unit/analytic_util_tests.py
33
33
  siglab_py/tests/unit/market_data_util_tests.py
34
+ siglab_py/tests/unit/simple_math_tests.py
34
35
  siglab_py/tests/unit/trading_util_tests.py
35
36
  siglab_py/util/__init__.py
36
37
  siglab_py/util/analytic_util.py
@@ -38,5 +39,6 @@ siglab_py/util/aws_util.py
38
39
  siglab_py/util/market_data_util.py
39
40
  siglab_py/util/notification_util.py
40
41
  siglab_py/util/retry_util.py
42
+ siglab_py/util/simple_math.py
41
43
  siglab_py/util/slack_notification_util.py
42
44
  siglab_py/util/trading_util.py