|
1 | | -from datetime import timedelta |
2 | | -from unittest import TestCase |
| 1 | +# from datetime import timedelta |
| 2 | +# from unittest import TestCase |
3 | 3 |
|
4 | | -import pandas as pd |
5 | | -import talib as ta |
6 | | -import numpy as np |
7 | | -import tulipy as ti |
8 | | -from investing_algorithm_framework import CSVOHLCVMarketDataSource |
| 4 | +# import pandas as pd |
| 5 | +# import numpy as np |
| 6 | +# import tulipy as ti |
| 7 | +# from investing_algorithm_framework import CSVOHLCVMarketDataSource |
9 | 8 |
|
10 | | -import pyindicators as pyi |
| 9 | +# import pyindicators as pyi |
11 | 10 |
|
12 | 11 |
|
13 | | -class Test(TestCase): |
| 12 | +# class Test(TestCase): |
14 | 13 |
|
15 | | - def test(self): |
16 | | - data_source = CSVOHLCVMarketDataSource( |
17 | | - csv_file_path="../test_data/OHLCV_BTC-EUR_BINANCE_15m" |
18 | | - "_2023-12-01:00:00_2023-12-25:00:00.csv", |
19 | | - ) |
20 | | - data_source.end_date = data_source.start_date \ |
21 | | - + timedelta(days=4, hours=4) |
| 14 | +# def test(self): |
| 15 | +# data_source = CSVOHLCVMarketDataSource( |
| 16 | +# csv_file_path="../test_data/OHLCV_BTC-EUR_BINANCE_15m" |
| 17 | +# "_2023-12-01:00:00_2023-12-25:00:00.csv", |
| 18 | +# ) |
| 19 | +# data_source.end_date = data_source.start_date \ |
| 20 | +# + timedelta(days=4, hours=4) |
22 | 21 |
|
23 | | - while not data_source.empty(): |
24 | | - data = data_source.get_data(market_credential_service=None) |
25 | | - df = pd.DataFrame( |
26 | | - data, |
27 | | - columns=['Date', 'Open', 'High', 'Low', 'Close', 'Volume'] |
28 | | - ) |
29 | | - pyi_rsi = pyi.rsi(series=df["Close"], timeperiod=14) |
30 | | - ta_rsi = ta.RSI(df["Close"], timeperiod=14).astype('float64') |
31 | | - ti_rsi = pd.Series(ti.rsi(df["Close"].to_numpy(), period=14)) |
32 | | - # # Define a tolerance for comparison |
33 | | - tolerance = 1e-9 |
34 | | - # |
35 | | - # # Compare the two Series with tolerance |
36 | | - nan_mask = ~np.isnan(pyi_rsi) & ~np.isnan(ta_rsi) |
37 | | - comparison_result = np.abs( |
38 | | - ta_rsi[nan_mask] - ti_rsi[nan_mask]) <= tolerance |
| 22 | +# while not data_source.empty(): |
| 23 | +# data = data_source.get_data(market_credential_service=None) |
| 24 | +# df = pd.DataFrame( |
| 25 | +# data, |
| 26 | +# columns=['Date', 'Open', 'High', 'Low', 'Close', 'Volume'] |
| 27 | +# ) |
| 28 | +# pyi_rsi = pyi.rsi(series=df["Close"], timeperiod=14) |
| 29 | +# ta_rsi = ta.RSI(df["Close"], timeperiod=14).astype('float64') |
| 30 | +# ti_rsi = pd.Series(ti.rsi(df["Close"].to_numpy(), period=14)) |
| 31 | +# # # Define a tolerance for comparison |
| 32 | +# tolerance = 1e-9 |
| 33 | +# # |
| 34 | +# # # Compare the two Series with tolerance |
| 35 | +# nan_mask = ~np.isnan(pyi_rsi) & ~np.isnan(ta_rsi) |
| 36 | +# comparison_result = np.abs( |
| 37 | +# ta_rsi[nan_mask] - ti_rsi[nan_mask]) <= tolerance |
39 | 38 |
|
40 | | - print(ta_rsi.iloc[-1], ti_rsi.iloc[-1]) |
41 | | - # data_source.start_date = \ |
42 | | - # data_source.start_date + timedelta(minutes=15) |
43 | | - # data_source.end_date = data_source.end_date + timedelta(minutes=15) |
44 | | - # self.assertTrue(all(comparison_result)) |
| 39 | +# print(ta_rsi.iloc[-1], ti_rsi.iloc[-1]) |
| 40 | +# # data_source.start_date = \ |
| 41 | +# # data_source.start_date + timedelta(minutes=15) |
| 42 | +# # data_source.end_date = data_source.end_date + timedelta(minutes=15) |
| 43 | +# # self.assertTrue(all(comparison_result)) |
0 commit comments