investing-algorithm-framework 6.9.1__py3-none-any.whl → 7.19.15__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 investing-algorithm-framework might be problematic. Click here for more details.
- investing_algorithm_framework/__init__.py +147 -44
- investing_algorithm_framework/app/__init__.py +23 -6
- investing_algorithm_framework/app/algorithm/algorithm.py +5 -41
- investing_algorithm_framework/app/algorithm/algorithm_factory.py +17 -10
- investing_algorithm_framework/app/analysis/__init__.py +15 -0
- investing_algorithm_framework/app/analysis/backtest_data_ranges.py +121 -0
- investing_algorithm_framework/app/analysis/backtest_utils.py +107 -0
- investing_algorithm_framework/app/analysis/permutation.py +116 -0
- investing_algorithm_framework/app/analysis/ranking.py +297 -0
- investing_algorithm_framework/app/app.py +1322 -707
- investing_algorithm_framework/app/context.py +196 -88
- investing_algorithm_framework/app/eventloop.py +590 -0
- investing_algorithm_framework/app/reporting/__init__.py +16 -5
- investing_algorithm_framework/app/reporting/ascii.py +57 -202
- investing_algorithm_framework/app/reporting/backtest_report.py +284 -170
- investing_algorithm_framework/app/reporting/charts/__init__.py +10 -2
- investing_algorithm_framework/app/reporting/charts/entry_exist_signals.py +66 -0
- investing_algorithm_framework/app/reporting/charts/equity_curve.py +37 -0
- investing_algorithm_framework/app/reporting/charts/equity_curve_drawdown.py +11 -26
- investing_algorithm_framework/app/reporting/charts/line_chart.py +11 -0
- investing_algorithm_framework/app/reporting/charts/ohlcv_data_completeness.py +51 -0
- investing_algorithm_framework/app/reporting/charts/rolling_sharp_ratio.py +1 -1
- investing_algorithm_framework/app/reporting/generate.py +100 -114
- investing_algorithm_framework/app/reporting/tables/key_metrics_table.py +40 -32
- investing_algorithm_framework/app/reporting/tables/time_metrics_table.py +34 -27
- investing_algorithm_framework/app/reporting/tables/trade_metrics_table.py +23 -19
- investing_algorithm_framework/app/reporting/tables/trades_table.py +1 -1
- investing_algorithm_framework/app/reporting/tables/utils.py +1 -0
- investing_algorithm_framework/app/reporting/templates/report_template.html.j2 +10 -16
- investing_algorithm_framework/app/strategy.py +315 -175
- investing_algorithm_framework/app/task.py +5 -3
- investing_algorithm_framework/cli/cli.py +30 -12
- investing_algorithm_framework/cli/deploy_to_aws_lambda.py +131 -34
- investing_algorithm_framework/cli/initialize_app.py +20 -1
- investing_algorithm_framework/cli/templates/app_aws_lambda_function.py.template +18 -6
- investing_algorithm_framework/cli/templates/aws_lambda_dockerfile.template +22 -0
- investing_algorithm_framework/cli/templates/aws_lambda_dockerignore.template +92 -0
- investing_algorithm_framework/cli/templates/aws_lambda_requirements.txt.template +2 -2
- investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +1 -1
- investing_algorithm_framework/create_app.py +3 -5
- investing_algorithm_framework/dependency_container.py +25 -39
- investing_algorithm_framework/domain/__init__.py +45 -38
- investing_algorithm_framework/domain/backtesting/__init__.py +21 -0
- investing_algorithm_framework/domain/backtesting/backtest.py +503 -0
- investing_algorithm_framework/domain/backtesting/backtest_date_range.py +96 -0
- investing_algorithm_framework/domain/backtesting/backtest_evaluation_focuss.py +242 -0
- investing_algorithm_framework/domain/backtesting/backtest_metrics.py +459 -0
- investing_algorithm_framework/domain/backtesting/backtest_permutation_test.py +275 -0
- investing_algorithm_framework/domain/backtesting/backtest_run.py +605 -0
- investing_algorithm_framework/domain/backtesting/backtest_summary_metrics.py +162 -0
- investing_algorithm_framework/domain/backtesting/combine_backtests.py +280 -0
- investing_algorithm_framework/domain/config.py +27 -0
- investing_algorithm_framework/domain/constants.py +6 -34
- investing_algorithm_framework/domain/data_provider.py +200 -56
- investing_algorithm_framework/domain/exceptions.py +34 -1
- investing_algorithm_framework/domain/models/__init__.py +10 -19
- investing_algorithm_framework/domain/models/base_model.py +0 -6
- investing_algorithm_framework/domain/models/data/__init__.py +7 -0
- investing_algorithm_framework/domain/models/data/data_source.py +214 -0
- investing_algorithm_framework/domain/models/{market_data_type.py → data/data_type.py} +7 -7
- investing_algorithm_framework/domain/models/market/market_credential.py +6 -0
- investing_algorithm_framework/domain/models/order/order.py +34 -13
- investing_algorithm_framework/domain/models/order/order_status.py +1 -1
- investing_algorithm_framework/domain/models/order/order_type.py +1 -1
- investing_algorithm_framework/domain/models/portfolio/portfolio.py +14 -1
- investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +5 -1
- investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +51 -11
- investing_algorithm_framework/domain/models/position/__init__.py +2 -1
- investing_algorithm_framework/domain/models/position/position.py +9 -0
- investing_algorithm_framework/domain/models/position/position_size.py +41 -0
- investing_algorithm_framework/domain/models/risk_rules/__init__.py +7 -0
- investing_algorithm_framework/domain/models/risk_rules/stop_loss_rule.py +51 -0
- investing_algorithm_framework/domain/models/risk_rules/take_profit_rule.py +55 -0
- investing_algorithm_framework/domain/models/snapshot_interval.py +0 -1
- investing_algorithm_framework/domain/models/strategy_profile.py +19 -151
- investing_algorithm_framework/domain/models/time_frame.py +7 -0
- investing_algorithm_framework/domain/models/time_interval.py +33 -0
- investing_algorithm_framework/domain/models/time_unit.py +63 -1
- investing_algorithm_framework/domain/models/trade/__init__.py +0 -2
- investing_algorithm_framework/domain/models/trade/trade.py +56 -32
- investing_algorithm_framework/domain/models/trade/trade_status.py +8 -2
- investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +106 -41
- investing_algorithm_framework/domain/models/trade/trade_take_profit.py +161 -99
- investing_algorithm_framework/domain/order_executor.py +19 -0
- investing_algorithm_framework/domain/portfolio_provider.py +20 -1
- investing_algorithm_framework/domain/services/__init__.py +0 -13
- investing_algorithm_framework/domain/strategy.py +1 -29
- investing_algorithm_framework/domain/utils/__init__.py +5 -1
- investing_algorithm_framework/domain/utils/custom_tqdm.py +22 -0
- investing_algorithm_framework/domain/utils/jupyter_notebook_detection.py +19 -0
- investing_algorithm_framework/domain/utils/polars.py +17 -14
- investing_algorithm_framework/download_data.py +40 -10
- investing_algorithm_framework/infrastructure/__init__.py +13 -25
- investing_algorithm_framework/infrastructure/data_providers/__init__.py +7 -4
- investing_algorithm_framework/infrastructure/data_providers/ccxt.py +811 -546
- investing_algorithm_framework/infrastructure/data_providers/csv.py +433 -122
- investing_algorithm_framework/infrastructure/data_providers/pandas.py +599 -0
- investing_algorithm_framework/infrastructure/database/__init__.py +6 -2
- investing_algorithm_framework/infrastructure/database/sql_alchemy.py +81 -0
- investing_algorithm_framework/infrastructure/models/__init__.py +0 -13
- investing_algorithm_framework/infrastructure/models/order/order.py +9 -3
- investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +27 -8
- investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +21 -7
- investing_algorithm_framework/infrastructure/order_executors/__init__.py +2 -0
- investing_algorithm_framework/infrastructure/order_executors/backtest_oder_executor.py +28 -0
- investing_algorithm_framework/infrastructure/repositories/repository.py +16 -2
- investing_algorithm_framework/infrastructure/repositories/trade_repository.py +2 -2
- investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +6 -0
- investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +6 -0
- investing_algorithm_framework/infrastructure/services/__init__.py +0 -4
- investing_algorithm_framework/services/__init__.py +105 -8
- investing_algorithm_framework/services/backtesting/backtest_service.py +536 -476
- investing_algorithm_framework/services/configuration_service.py +14 -4
- investing_algorithm_framework/services/data_providers/__init__.py +5 -0
- investing_algorithm_framework/services/data_providers/data_provider_service.py +850 -0
- investing_algorithm_framework/{app/reporting → services}/metrics/__init__.py +48 -17
- investing_algorithm_framework/{app/reporting → services}/metrics/drawdown.py +10 -10
- investing_algorithm_framework/{app/reporting → services}/metrics/equity_curve.py +2 -2
- investing_algorithm_framework/{app/reporting → services}/metrics/exposure.py +60 -2
- investing_algorithm_framework/services/metrics/generate.py +358 -0
- investing_algorithm_framework/{app/reporting → services}/metrics/profit_factor.py +36 -0
- investing_algorithm_framework/{app/reporting → services}/metrics/recovery.py +2 -2
- investing_algorithm_framework/{app/reporting → services}/metrics/returns.py +146 -147
- investing_algorithm_framework/services/metrics/risk_free_rate.py +28 -0
- investing_algorithm_framework/{app/reporting/metrics/sharp_ratio.py → services/metrics/sharpe_ratio.py} +6 -10
- investing_algorithm_framework/{app/reporting → services}/metrics/sortino_ratio.py +3 -7
- investing_algorithm_framework/services/metrics/trades.py +500 -0
- investing_algorithm_framework/services/metrics/volatility.py +97 -0
- investing_algorithm_framework/{app/reporting → services}/metrics/win_rate.py +70 -3
- investing_algorithm_framework/services/order_service/order_backtest_service.py +21 -31
- investing_algorithm_framework/services/order_service/order_service.py +9 -71
- investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -2
- investing_algorithm_framework/services/portfolios/portfolio_service.py +3 -13
- investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +62 -96
- investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -3
- investing_algorithm_framework/services/repository_service.py +5 -2
- investing_algorithm_framework/services/trade_order_evaluator/__init__.py +9 -0
- investing_algorithm_framework/services/trade_order_evaluator/backtest_trade_oder_evaluator.py +113 -0
- investing_algorithm_framework/services/trade_order_evaluator/default_trade_order_evaluator.py +51 -0
- investing_algorithm_framework/services/trade_order_evaluator/trade_order_evaluator.py +80 -0
- investing_algorithm_framework/services/trade_service/__init__.py +7 -1
- investing_algorithm_framework/services/trade_service/trade_service.py +51 -29
- investing_algorithm_framework/services/trade_service/trade_stop_loss_service.py +39 -0
- investing_algorithm_framework/services/trade_service/trade_take_profit_service.py +41 -0
- investing_algorithm_framework-7.19.15.dist-info/METADATA +537 -0
- {investing_algorithm_framework-6.9.1.dist-info → investing_algorithm_framework-7.19.15.dist-info}/RECORD +159 -148
- investing_algorithm_framework/app/reporting/evaluation.py +0 -243
- investing_algorithm_framework/app/reporting/metrics/risk_free_rate.py +0 -8
- investing_algorithm_framework/app/reporting/metrics/volatility.py +0 -69
- investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +0 -3
- investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -9
- investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -47
- investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -120
- investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- investing_algorithm_framework/domain/models/backtesting/backtest_results.py +0 -440
- investing_algorithm_framework/domain/models/data_source.py +0 -21
- investing_algorithm_framework/domain/models/date_range.py +0 -64
- investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -34
- investing_algorithm_framework/domain/models/trading_data_types.py +0 -48
- investing_algorithm_framework/domain/models/trading_time_frame.py +0 -223
- investing_algorithm_framework/domain/services/market_data_sources.py +0 -543
- investing_algorithm_framework/domain/services/market_service.py +0 -153
- investing_algorithm_framework/domain/services/observable.py +0 -51
- investing_algorithm_framework/domain/services/observer.py +0 -19
- investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -16
- investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -746
- investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -270
- investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -312
- investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -5
- investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -471
- investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -7
- investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -2
- investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -322
- investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -10
- investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -269
- investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -350
- investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -377
- investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -296
- investing_algorithm_framework-6.9.1.dist-info/METADATA +0 -440
- /investing_algorithm_framework/{app/reporting → services}/metrics/alpha.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/beta.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/cagr.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/calmar_ratio.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/mean_daily_return.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/price_efficiency.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/standard_deviation.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/treynor_ratio.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/ulcer.py +0 -0
- /investing_algorithm_framework/{app/reporting → services}/metrics/value_at_risk.py +0 -0
- {investing_algorithm_framework-6.9.1.dist-info → investing_algorithm_framework-7.19.15.dist-info}/LICENSE +0 -0
- {investing_algorithm_framework-6.9.1.dist-info → investing_algorithm_framework-7.19.15.dist-info}/WHEEL +0 -0
- {investing_algorithm_framework-6.9.1.dist-info → investing_algorithm_framework-7.19.15.dist-info}/entry_points.txt +0 -0
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
from datetime import timedelta, datetime
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
from investing_algorithm_framework.domain.exceptions import \
|
|
5
|
-
OperationalException
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TradingTimeFrame(Enum):
|
|
9
|
-
ONE_MINUTE = "ONE_MINUTE"
|
|
10
|
-
FIFTEEN_MINUTE = "FIFTEEN_MINUTE"
|
|
11
|
-
ONE_HOUR = "ONE_HOUR"
|
|
12
|
-
TWO_HOUR = "TWO_HOUR"
|
|
13
|
-
ONE_DAY = 'ONE_DAY'
|
|
14
|
-
ONE_MONTH = "ONE_MONTH"
|
|
15
|
-
ONE_YEAR = "ONE_YEAR"
|
|
16
|
-
|
|
17
|
-
def create_time_frame_from_limit(self, limit: int = 50):
|
|
18
|
-
|
|
19
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
20
|
-
hold = 1
|
|
21
|
-
start_date = datetime.now() - timedelta(minutes=limit)
|
|
22
|
-
elif TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
23
|
-
hold = 15
|
|
24
|
-
start_date = datetime.now() - timedelta(minutes=(limit * 15))
|
|
25
|
-
elif TradingTimeFrame.ONE_HOUR.equals(self):
|
|
26
|
-
hold = 60
|
|
27
|
-
start_date = datetime.now() - timedelta(hours=limit)
|
|
28
|
-
elif TradingTimeFrame.TWO_HOUR.equals(self):
|
|
29
|
-
hold = 60 * 2
|
|
30
|
-
start_date = datetime.now() - timedelta(hours=limit)
|
|
31
|
-
elif TradingTimeFrame.ONE_DAY.equals(self):
|
|
32
|
-
hold = 60 * 24
|
|
33
|
-
start_date = datetime.now() - timedelta(days=limit)
|
|
34
|
-
elif TradingTimeFrame.ONE_MONTH.equals(self):
|
|
35
|
-
hold = 60 * 24 * 30
|
|
36
|
-
start_date = datetime.now() - timedelta(weeks=(4 * limit))
|
|
37
|
-
else:
|
|
38
|
-
hold = 60 * 24 * 365
|
|
39
|
-
start_date = datetime.now() - timedelta(days=(limit * 365))
|
|
40
|
-
|
|
41
|
-
iteration = 1
|
|
42
|
-
dates = []
|
|
43
|
-
while iteration < limit or \
|
|
44
|
-
start_date + timedelta(minutes=hold) < datetime.now():
|
|
45
|
-
dates.append(start_date + timedelta(minutes=hold))
|
|
46
|
-
start_date += timedelta(minutes=hold)
|
|
47
|
-
iteration += 1
|
|
48
|
-
|
|
49
|
-
dates.append(datetime.now())
|
|
50
|
-
return dates
|
|
51
|
-
|
|
52
|
-
def create_time_frame_from_start_date(self, start_date: datetime):
|
|
53
|
-
|
|
54
|
-
if start_date > datetime.now():
|
|
55
|
-
raise OperationalException("Start date cannot be in the future")
|
|
56
|
-
|
|
57
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
58
|
-
hold = 1
|
|
59
|
-
elif TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
60
|
-
hold = 15
|
|
61
|
-
elif TradingTimeFrame.ONE_HOUR.equals(self):
|
|
62
|
-
hold = 60
|
|
63
|
-
elif TradingTimeFrame.TWO_HOUR.equals(self):
|
|
64
|
-
hold = 60 * 2
|
|
65
|
-
elif TradingTimeFrame.ONE_DAY.equals(self):
|
|
66
|
-
hold = 60 * 24
|
|
67
|
-
elif TradingTimeFrame.ONE_MONTH.equals(self):
|
|
68
|
-
hold = 60 * 24 * 30
|
|
69
|
-
else:
|
|
70
|
-
hold = 60 * 24 * 365
|
|
71
|
-
|
|
72
|
-
iteration = 1
|
|
73
|
-
dates = []
|
|
74
|
-
|
|
75
|
-
while start_date < datetime.now():
|
|
76
|
-
dates.append(start_date + timedelta(minutes=hold))
|
|
77
|
-
start_date += timedelta(minutes=hold)
|
|
78
|
-
iteration += 1
|
|
79
|
-
|
|
80
|
-
dates.append(datetime.now())
|
|
81
|
-
return dates
|
|
82
|
-
|
|
83
|
-
def to_ccxt_string(self):
|
|
84
|
-
|
|
85
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
86
|
-
return "1m"
|
|
87
|
-
|
|
88
|
-
if TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
89
|
-
return "15m"
|
|
90
|
-
|
|
91
|
-
if TradingTimeFrame.ONE_HOUR.equals(self):
|
|
92
|
-
return "1h"
|
|
93
|
-
|
|
94
|
-
if TradingTimeFrame.TWO_HOUR.equals(self):
|
|
95
|
-
return "2h"
|
|
96
|
-
|
|
97
|
-
if TradingTimeFrame.ONE_DAY.equals(self):
|
|
98
|
-
return "1d"
|
|
99
|
-
|
|
100
|
-
if TradingTimeFrame.ONE_MONTH.equals(self):
|
|
101
|
-
return "1m"
|
|
102
|
-
|
|
103
|
-
if TradingTimeFrame.ONE_YEAR.equals(self):
|
|
104
|
-
return "1y"
|
|
105
|
-
|
|
106
|
-
raise OperationalException("Data time unit value is not supported")
|
|
107
|
-
|
|
108
|
-
@staticmethod
|
|
109
|
-
def from_value(value):
|
|
110
|
-
|
|
111
|
-
if isinstance(value, TradingTimeFrame):
|
|
112
|
-
for data_time_unit in TradingTimeFrame:
|
|
113
|
-
|
|
114
|
-
if value == data_time_unit:
|
|
115
|
-
return data_time_unit
|
|
116
|
-
|
|
117
|
-
elif isinstance(value, str):
|
|
118
|
-
return TradingTimeFrame.from_string(value)
|
|
119
|
-
|
|
120
|
-
raise ValueError(
|
|
121
|
-
"Could not convert value to data time unit"
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
@staticmethod
|
|
125
|
-
def from_string(value: str):
|
|
126
|
-
|
|
127
|
-
if isinstance(value, str):
|
|
128
|
-
for data_time_unit in TradingTimeFrame:
|
|
129
|
-
|
|
130
|
-
if value.upper() == data_time_unit.value:
|
|
131
|
-
return data_time_unit
|
|
132
|
-
|
|
133
|
-
raise ValueError(
|
|
134
|
-
"Could not convert value to data time unit"
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
def equals(self, other):
|
|
138
|
-
|
|
139
|
-
if other is None:
|
|
140
|
-
return False
|
|
141
|
-
|
|
142
|
-
if isinstance(other, Enum):
|
|
143
|
-
return self.value == other.value
|
|
144
|
-
|
|
145
|
-
else:
|
|
146
|
-
return TradingTimeFrame.from_string(other) == self
|
|
147
|
-
|
|
148
|
-
def create_start_date(self, limit=50):
|
|
149
|
-
|
|
150
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
151
|
-
return datetime.now() - timedelta(minutes=limit)
|
|
152
|
-
|
|
153
|
-
if TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
154
|
-
return datetime.now() - timedelta(minutes=(limit * 15))
|
|
155
|
-
|
|
156
|
-
if TradingTimeFrame.ONE_HOUR.equals(self):
|
|
157
|
-
return datetime.now() - timedelta(hours=limit)
|
|
158
|
-
|
|
159
|
-
if TradingTimeFrame.TWO_HOUR.equals(self):
|
|
160
|
-
return datetime.now() - timedelta(hours=limit * 2)
|
|
161
|
-
|
|
162
|
-
if TradingTimeFrame.ONE_DAY.equals(self):
|
|
163
|
-
return datetime.now() - timedelta(days=limit)
|
|
164
|
-
|
|
165
|
-
if TradingTimeFrame.ONE_MONTH.equals(self):
|
|
166
|
-
return datetime.now() - timedelta(weeks=(4 * limit))
|
|
167
|
-
|
|
168
|
-
if TradingTimeFrame.ONE_YEAR.equals(self):
|
|
169
|
-
return datetime.now() - timedelta(days=(limit * 365))
|
|
170
|
-
|
|
171
|
-
raise OperationalException("Data time unit value is not supported")
|
|
172
|
-
|
|
173
|
-
@property
|
|
174
|
-
def minutes(self):
|
|
175
|
-
|
|
176
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
177
|
-
return 1
|
|
178
|
-
|
|
179
|
-
if TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
180
|
-
return 15
|
|
181
|
-
|
|
182
|
-
if TradingTimeFrame.ONE_HOUR.equals(self):
|
|
183
|
-
return 60
|
|
184
|
-
|
|
185
|
-
if TradingTimeFrame.TWO_HOUR.equals(self):
|
|
186
|
-
return 120
|
|
187
|
-
|
|
188
|
-
if TradingTimeFrame.ONE_DAY.equals(self):
|
|
189
|
-
return 60 * 24
|
|
190
|
-
|
|
191
|
-
if TradingTimeFrame.ONE_MONTH.equals(self):
|
|
192
|
-
return 60 * 24 * 30
|
|
193
|
-
|
|
194
|
-
if TradingTimeFrame.ONE_YEAR.equals(self):
|
|
195
|
-
return 60 * 24 * 365
|
|
196
|
-
|
|
197
|
-
raise OperationalException("Data time frame value is not supported")
|
|
198
|
-
|
|
199
|
-
@property
|
|
200
|
-
def milliseconds(self):
|
|
201
|
-
|
|
202
|
-
if TradingTimeFrame.ONE_MINUTE.equals(self):
|
|
203
|
-
return 60 * 1000
|
|
204
|
-
|
|
205
|
-
if TradingTimeFrame.FIFTEEN_MINUTE.equals(self):
|
|
206
|
-
return 15 * 60 * 1000
|
|
207
|
-
|
|
208
|
-
if TradingTimeFrame.ONE_HOUR.equals(self):
|
|
209
|
-
return 60 * 60 * 1000
|
|
210
|
-
|
|
211
|
-
if TradingTimeFrame.TWO_HOUR.equals(self):
|
|
212
|
-
return 2 * 60 * 60 * 1000
|
|
213
|
-
|
|
214
|
-
if TradingTimeFrame.ONE_DAY.equals(self):
|
|
215
|
-
return 60 * 60 * 24 * 1000
|
|
216
|
-
|
|
217
|
-
if TradingTimeFrame.ONE_MONTH.equals(self):
|
|
218
|
-
return 60 * 60 * 24 * 30 * 1000
|
|
219
|
-
|
|
220
|
-
if TradingTimeFrame.ONE_YEAR.equals(self):
|
|
221
|
-
return 60 * 60 * 24 * 365 * 1000
|
|
222
|
-
|
|
223
|
-
raise OperationalException("Data time frame value is not supported")
|