siglab-py 0.3.8__tar.gz → 0.3.10__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.
- {siglab_py-0.3.8 → siglab_py-0.3.10}/PKG-INFO +1 -1
- {siglab_py-0.3.8 → siglab_py-0.3.10}/pyproject.toml +1 -1
- {siglab_py-0.3.8 → siglab_py-0.3.10}/setup.cfg +1 -1
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/analytic_util.py +8 -1
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/market_data_util.py +45 -44
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py.egg-info/PKG-INFO +1 -1
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py.egg-info/SOURCES.txt +0 -1
- siglab_py-0.3.8/siglab_py/util/test_market_data_analytic_util.py +0 -64
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/constants.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/exchanges/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/exchanges/any_exchange.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/exchanges/futubull.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/aggregated_orderbook_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/candles_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/candles_ta_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/deribit_options_expiry_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/orderbooks_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/test_provider.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/ordergateway/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/ordergateway/client.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/ordergateway/encrypt_keys_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/ordergateway/gateway.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/ordergateway/test_ordergateway.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/integration/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/integration/market_data_util_tests.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/unit/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/unit/analytic_util_tests.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/unit/market_data_util_tests.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/tests/unit/trading_util_tests.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/__init__.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/aws_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/notification_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/retry_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/slack_notification_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/util/trading_util.py +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py.egg-info/dependency_links.txt +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py.egg-info/requires.txt +0 -0
- {siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "siglab_py"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.10"
|
|
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"}
|
|
@@ -894,4 +894,11 @@ def compute_pair_stats(
|
|
|
894
894
|
pd_candles['close_spread_std'] = std
|
|
895
895
|
pd_candles['zscore_close_spread'] = (pd_candles['close_spread'] - mean)/std
|
|
896
896
|
pd_candles['zscore_close_spread_min'] = pd_candles['zscore_close_spread'].rolling(how_many_candles).min()
|
|
897
|
-
pd_candles['zscore_close_spread_max'] = pd_candles['zscore_close_spread'].rolling(how_many_candles).max()
|
|
897
|
+
pd_candles['zscore_close_spread_max'] = pd_candles['zscore_close_spread'].rolling(how_many_candles).max()
|
|
898
|
+
|
|
899
|
+
calculate_slope(
|
|
900
|
+
pd_data=pd_candles,
|
|
901
|
+
src_col_name='zscore_close_spread',
|
|
902
|
+
slope_col_name='zscore_slope',
|
|
903
|
+
sliding_window_how_many_candles=how_many_candles
|
|
904
|
+
)
|
|
@@ -516,55 +516,56 @@ def _fetch_candles_ccxt(
|
|
|
516
516
|
candle_size : str,
|
|
517
517
|
num_candles_limit : int = 100
|
|
518
518
|
) -> Dict[str, Union[pd.DataFrame, None]]:
|
|
519
|
-
|
|
519
|
+
rsp = {}
|
|
520
520
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
candles
|
|
521
|
+
for ticker in normalized_symbols:
|
|
522
|
+
def _fetch_ohlcv(exchange, symbol, timeframe, since, limit, params) -> Union[List, NoReturn]:
|
|
523
|
+
one_timeframe = f"1{timeframe[-1]}"
|
|
524
|
+
candles = exchange.fetch_ohlcv(symbol=symbol, timeframe=one_timeframe, since=since, limit=limit, params=params)
|
|
525
|
+
if candles and len(candles)>0:
|
|
526
|
+
candles.sort(key=lambda x : x[0], reverse=False)
|
|
526
527
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
def _calc_increment(candle_size):
|
|
530
|
-
increment = 1
|
|
531
|
-
num_intervals = int(candle_size[0])
|
|
532
|
-
interval_type = candle_size[-1]
|
|
533
|
-
if interval_type == "m":
|
|
534
|
-
increment = 60
|
|
535
|
-
elif interval_type == "h":
|
|
536
|
-
increment = 60*60
|
|
537
|
-
elif interval_type == "d":
|
|
538
|
-
increment = 60*60*24
|
|
539
|
-
else:
|
|
540
|
-
raise ValueError(f"Invalid candle_size {candle_size}")
|
|
541
|
-
return num_intervals * increment
|
|
542
|
-
|
|
543
|
-
all_candles = []
|
|
544
|
-
params = {}
|
|
545
|
-
this_cutoff = start_ts
|
|
546
|
-
while this_cutoff<end_ts:
|
|
547
|
-
candles = _fetch_ohlcv(exchange=exchange, symbol=ticker, timeframe=candle_size, since=int(this_cutoff * 1000), limit=num_candles_limit, params=params)
|
|
548
|
-
if candles and len(candles)>0:
|
|
549
|
-
all_candles = all_candles + [[ int(x[0]), float(x[1]), float(x[2]), float(x[3]), float(x[4]), float(x[5]) ] for x in candles if x[1] and x[2] and x[3] and x[4] and x[5] ]
|
|
550
|
-
|
|
551
|
-
record_ts = max([int(record[0]) for record in candles])
|
|
552
|
-
record_ts_str : str = str(record_ts)
|
|
553
|
-
if len(record_ts_str)==13:
|
|
554
|
-
record_ts = int(int(record_ts_str)/1000) # Convert from milli-seconds to seconds
|
|
528
|
+
return candles
|
|
555
529
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
530
|
+
def _calc_increment(candle_size):
|
|
531
|
+
increment = 1
|
|
532
|
+
num_intervals = int(candle_size[0])
|
|
533
|
+
interval_type = candle_size[-1]
|
|
534
|
+
if interval_type == "m":
|
|
535
|
+
increment = 60
|
|
536
|
+
elif interval_type == "h":
|
|
537
|
+
increment = 60*60
|
|
538
|
+
elif interval_type == "d":
|
|
539
|
+
increment = 60*60*24
|
|
540
|
+
else:
|
|
541
|
+
raise ValueError(f"Invalid candle_size {candle_size}")
|
|
542
|
+
return num_intervals * increment
|
|
543
|
+
|
|
544
|
+
all_candles = []
|
|
545
|
+
params = {}
|
|
546
|
+
this_cutoff = start_ts
|
|
547
|
+
while this_cutoff<end_ts:
|
|
548
|
+
candles = _fetch_ohlcv(exchange=exchange, symbol=ticker, timeframe=candle_size, since=int(this_cutoff * 1000), limit=num_candles_limit, params=params)
|
|
549
|
+
if candles and len(candles)>0:
|
|
550
|
+
all_candles = all_candles + [[ int(x[0]), float(x[1]), float(x[2]), float(x[3]), float(x[4]), float(x[5]) ] for x in candles if x[1] and x[2] and x[3] and x[4] and x[5] ]
|
|
551
|
+
|
|
552
|
+
record_ts = max([int(record[0]) for record in candles])
|
|
553
|
+
record_ts_str : str = str(record_ts)
|
|
554
|
+
if len(record_ts_str)==13:
|
|
555
|
+
record_ts = int(int(record_ts_str)/1000) # Convert from milli-seconds to seconds
|
|
556
|
+
|
|
557
|
+
this_cutoff = record_ts + _calc_increment(candle_size)
|
|
558
|
+
else:
|
|
559
|
+
this_cutoff += _calc_increment(candle_size)
|
|
559
560
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
561
|
+
columns = ['exchange', 'symbol', 'timestamp_ms', 'open', 'high', 'low', 'close', 'volume']
|
|
562
|
+
pd_all_candles = pd.DataFrame([ [ exchange.name, ticker, x[0], x[1], x[2], x[3], x[4], x[5] ] for x in all_candles], columns=columns)
|
|
563
|
+
fix_column_types(pd_all_candles)
|
|
564
|
+
pd_all_candles['pct_chg_on_close'] = pd_all_candles['close'].pct_change()
|
|
564
565
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
566
|
+
rsp[ticker] = pd_all_candles
|
|
567
|
+
|
|
568
|
+
return rsp
|
|
568
569
|
|
|
569
570
|
def fetch_deribit_btc_option_expiries(
|
|
570
571
|
market: str = 'BTC'
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
import time
|
|
3
|
-
from typing import Union
|
|
4
|
-
import pandas as pd
|
|
5
|
-
|
|
6
|
-
from ccxt.okx import okx
|
|
7
|
-
|
|
8
|
-
from market_data_util import fetch_candles
|
|
9
|
-
from analytic_util import compute_candles_stats
|
|
10
|
-
|
|
11
|
-
base_ccy : str = "BTC"
|
|
12
|
-
# ticker = "GRIFFAIN/USDT:USDT"
|
|
13
|
-
# ticker = "OL/USDT:USDT"
|
|
14
|
-
ticker = f"{base_ccy}/USDT:USDT"
|
|
15
|
-
|
|
16
|
-
reload_raw_candles : bool = True
|
|
17
|
-
raw_candles_file : str = f"{base_ccy}_raw_candles.csv"
|
|
18
|
-
candles_with_ta_file : str = f"{base_ccy}_candles_ta.csv"
|
|
19
|
-
|
|
20
|
-
param = {
|
|
21
|
-
'rateLimit' : 100, # In ms
|
|
22
|
-
'options' : {
|
|
23
|
-
'defaultType': 'swap', # Should test linear instead
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exchange = okx(param) # type: ignore
|
|
27
|
-
|
|
28
|
-
start_date : datetime = datetime(2024,1,1)
|
|
29
|
-
end_date : datetime = datetime(2025,4,22)
|
|
30
|
-
candle_size : str = '1h'
|
|
31
|
-
ma_long_intervals : int = 24*30
|
|
32
|
-
ma_short_intervals : int = 24
|
|
33
|
-
boillenger_std_multiples : int = 2
|
|
34
|
-
pypy_compatible : bool = False
|
|
35
|
-
|
|
36
|
-
markets = exchange.load_markets()
|
|
37
|
-
assert(ticker in markets)
|
|
38
|
-
|
|
39
|
-
start = time.time()
|
|
40
|
-
|
|
41
|
-
if reload_raw_candles:
|
|
42
|
-
pd_candles: Union[pd.DataFrame, None] = fetch_candles(
|
|
43
|
-
start_ts=int(start_date.timestamp()),
|
|
44
|
-
end_ts=int(end_date.timestamp()),
|
|
45
|
-
exchange=exchange,
|
|
46
|
-
normalized_symbols=[ ticker ],
|
|
47
|
-
candle_size=candle_size
|
|
48
|
-
)[ ticker ]
|
|
49
|
-
|
|
50
|
-
pd_candles.to_csv(raw_candles_file) # type: ignore
|
|
51
|
-
else:
|
|
52
|
-
pd_candles = pd.read_csv(raw_candles_file) # type: ignore
|
|
53
|
-
|
|
54
|
-
compute_candles_stats(
|
|
55
|
-
pd_candles=pd_candles, # type: ignore
|
|
56
|
-
boillenger_std_multiples=boillenger_std_multiples,
|
|
57
|
-
sliding_window_how_many_candles=ma_long_intervals,
|
|
58
|
-
slow_fast_interval_ratio=(ma_long_intervals/ma_short_intervals),
|
|
59
|
-
pypy_compat=pypy_compatible
|
|
60
|
-
)
|
|
61
|
-
pd_candles.to_csv(candles_with_ta_file) # type: ignore
|
|
62
|
-
|
|
63
|
-
compute_candles_stats_elapsed_ms = int((time.time() - start) *1000)
|
|
64
|
-
print(f"elapsed (ms): {compute_candles_stats_elapsed_ms}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/ccxt_candles_ta_to_csv.py
RENAMED
|
File without changes
|
|
File without changes
|
{siglab_py-0.3.8 → siglab_py-0.3.10}/siglab_py/market_data_providers/futu_candles_ta_to_csv.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|