investing-algorithm-framework 7.16.11__py3-none-any.whl → 7.16.13__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 +2 -1
- investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +14 -13
- investing_algorithm_framework/domain/models/trade/trade.py +3 -3
- investing_algorithm_framework/services/backtesting/backtest_service.py +14 -3
- {investing_algorithm_framework-7.16.11.dist-info → investing_algorithm_framework-7.16.13.dist-info}/METADATA +1 -1
- {investing_algorithm_framework-7.16.11.dist-info → investing_algorithm_framework-7.16.13.dist-info}/RECORD +9 -9
- {investing_algorithm_framework-7.16.11.dist-info → investing_algorithm_framework-7.16.13.dist-info}/LICENSE +0 -0
- {investing_algorithm_framework-7.16.11.dist-info → investing_algorithm_framework-7.16.13.dist-info}/WHEEL +0 -0
- {investing_algorithm_framework-7.16.11.dist-info → investing_algorithm_framework-7.16.13.dist-info}/entry_points.txt +0 -0
|
@@ -14,7 +14,7 @@ from .domain import ApiException, combine_backtests, PositionSize, \
|
|
|
14
14
|
Position, TimeFrame, INDEX_DATETIME, MarketCredential, \
|
|
15
15
|
PortfolioConfiguration, RESOURCE_DIRECTORY, AWS_LAMBDA_LOGGING_CONFIG, \
|
|
16
16
|
Trade, SYMBOLS, RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
|
|
17
|
-
BacktestDateRange, convert_polars_to_pandas, \
|
|
17
|
+
BacktestDateRange, convert_polars_to_pandas, BacktestRun, \
|
|
18
18
|
DEFAULT_LOGGING_CONFIG, DataType, DataProvider, \
|
|
19
19
|
TradeStatus, TradeRiskType, generate_backtest_summary_metrics, \
|
|
20
20
|
APPLICATION_DIRECTORY, DataSource, OrderExecutor, PortfolioProvider, \
|
|
@@ -189,4 +189,5 @@ __all__ = [
|
|
|
189
189
|
"get_negative_trades",
|
|
190
190
|
"get_positive_trades",
|
|
191
191
|
"get_number_of_trades",
|
|
192
|
+
"BacktestRun"
|
|
192
193
|
]
|
|
@@ -150,23 +150,24 @@ class PortfolioSnapshot(BaseModel):
|
|
|
150
150
|
if datetime_format is not None:
|
|
151
151
|
created_at = self.created_at.strftime(datetime_format) \
|
|
152
152
|
if self.created_at else None
|
|
153
|
-
|
|
154
153
|
else:
|
|
155
154
|
created_at = self.created_at.strftime(DEFAULT_DATETIME_FORMAT)
|
|
156
155
|
|
|
157
156
|
return {
|
|
158
|
-
"metadata": self.metadata,
|
|
159
|
-
"portfolio_id": self.portfolio_id,
|
|
160
|
-
"trading_symbol": self.trading_symbol
|
|
161
|
-
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
157
|
+
"metadata": self.metadata if self.metadata else {},
|
|
158
|
+
"portfolio_id": self.portfolio_id if self.portfolio_id else "",
|
|
159
|
+
"trading_symbol": self.trading_symbol
|
|
160
|
+
if self.trading_symbol else "",
|
|
161
|
+
"pending_value": self.pending_value if self.pending_value else 0.0,
|
|
162
|
+
"unallocated": self.unallocated if self.unallocated else 0.0,
|
|
163
|
+
"total_net_gain": self.total_net_gain
|
|
164
|
+
if self.total_net_gain else 0.0,
|
|
165
|
+
"total_revenue": self.total_revenue if self.total_revenue else 0.0,
|
|
166
|
+
"total_cost": self.total_cost if self.total_cost else 0.0,
|
|
167
|
+
"cash_flow": self.cash_flow if self.cash_flow else 0.0,
|
|
168
|
+
"net_size": self.net_size if self.net_size else 0.0,
|
|
169
|
+
"created_at": created_at if created_at else "",
|
|
170
|
+
"total_value": self.total_value if self.total_value else 0.0,
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
@staticmethod
|
|
@@ -283,14 +283,14 @@ class Trade(BaseModel):
|
|
|
283
283
|
"trading_symbol": self.trading_symbol,
|
|
284
284
|
"status": self.status,
|
|
285
285
|
"amount": self.amount,
|
|
286
|
-
"remaining": self.remaining,
|
|
286
|
+
"remaining": self.remaining if self.remaining is not None else 0,
|
|
287
287
|
"open_price": self.open_price,
|
|
288
288
|
"last_reported_price": self.last_reported_price,
|
|
289
289
|
"opened_at": opened_at,
|
|
290
290
|
"closed_at": closed_at,
|
|
291
291
|
"updated_at": updated_at,
|
|
292
|
-
"net_gain": self.net_gain,
|
|
293
|
-
"cost": self.cost,
|
|
292
|
+
"net_gain": self.net_gain if self.net_gain is not None else 0,
|
|
293
|
+
"cost": self.cost if self.cost is not None else 0,
|
|
294
294
|
"stop_losses": [
|
|
295
295
|
stop_loss.to_dict(datetime_format=datetime_format)
|
|
296
296
|
for stop_loss in self.stop_losses
|
|
@@ -165,13 +165,19 @@ class BacktestService:
|
|
|
165
165
|
portfolio_configurations = []
|
|
166
166
|
portfolio_configurations.append(
|
|
167
167
|
PortfolioConfiguration(
|
|
168
|
+
identifier="vector_backtest",
|
|
168
169
|
market=market,
|
|
169
170
|
trading_symbol=trading_symbol,
|
|
170
171
|
initial_balance=initial_amount
|
|
171
172
|
)
|
|
172
173
|
)
|
|
173
174
|
|
|
175
|
+
portfolio_configuration = portfolio_configurations[0]
|
|
176
|
+
|
|
174
177
|
trading_symbol = portfolio_configurations[0].trading_symbol
|
|
178
|
+
portfolio = Portfolio.from_portfolio_configuration(
|
|
179
|
+
portfolio_configuration
|
|
180
|
+
)
|
|
175
181
|
|
|
176
182
|
# Load vectorized backtest data
|
|
177
183
|
data = self._data_provider_service.get_vectorized_backtest_data(
|
|
@@ -188,7 +194,9 @@ class BacktestService:
|
|
|
188
194
|
index = pd.Index([])
|
|
189
195
|
|
|
190
196
|
most_granular_ohlcv_data_source = \
|
|
191
|
-
|
|
197
|
+
BacktestService.get_most_granular_ohlcv_data_source(
|
|
198
|
+
strategy.data_sources
|
|
199
|
+
)
|
|
192
200
|
most_granular_ohlcv_data = self._data_provider_service.get_ohlcv_data(
|
|
193
201
|
symbol=most_granular_ohlcv_data_source.symbol,
|
|
194
202
|
start_date=backtest_date_range.start_date,
|
|
@@ -212,6 +220,8 @@ class BacktestService:
|
|
|
212
220
|
granular_ohlcv_data_order_by_symbol = {}
|
|
213
221
|
snapshots = [
|
|
214
222
|
PortfolioSnapshot(
|
|
223
|
+
trading_symbol=trading_symbol,
|
|
224
|
+
portfolio_id=portfolio.identifier,
|
|
215
225
|
created_at=backtest_date_range.start_date,
|
|
216
226
|
unallocated=initial_amount,
|
|
217
227
|
total_value=initial_amount,
|
|
@@ -346,7 +356,7 @@ class BacktestService:
|
|
|
346
356
|
{
|
|
347
357
|
"orders": trade_orders,
|
|
348
358
|
"closed_at": current_date,
|
|
349
|
-
"
|
|
359
|
+
"status": TradeStatus.CLOSED,
|
|
350
360
|
"updated_at": current_date,
|
|
351
361
|
"net_gain": net_gain_val
|
|
352
362
|
}
|
|
@@ -392,6 +402,7 @@ class BacktestService:
|
|
|
392
402
|
# total_net_gain = total_value - initial_amount
|
|
393
403
|
snapshots.append(
|
|
394
404
|
PortfolioSnapshot(
|
|
405
|
+
portfolio_id=portfolio.identifier,
|
|
395
406
|
created_at=interval_datetime,
|
|
396
407
|
unallocated=unallocated,
|
|
397
408
|
total_value=unallocated + allocated,
|
|
@@ -580,7 +591,7 @@ class BacktestService:
|
|
|
580
591
|
)
|
|
581
592
|
|
|
582
593
|
@staticmethod
|
|
583
|
-
def
|
|
594
|
+
def get_most_granular_ohlcv_data_source(data_sources):
|
|
584
595
|
"""
|
|
585
596
|
Get the most granular data source from a list of data sources.
|
|
586
597
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
investing_algorithm_framework/__init__.py,sha256=
|
|
1
|
+
investing_algorithm_framework/__init__.py,sha256=rYv3eJDD0QbOPXCvK-Ye8oml63MYM_QLqXrt6vFpHk8,6857
|
|
2
2
|
investing_algorithm_framework/app/__init__.py,sha256=x683g8hvp5yERywt0CFWLavMcTDnCwVVUW_g3o5kyOc,1539
|
|
3
3
|
investing_algorithm_framework/app/algorithm/__init__.py,sha256=-a9o9bTfAhW9qSW-bKvlLQuMCf-YXxIztudo2TxMjCI,136
|
|
4
4
|
investing_algorithm_framework/app/algorithm/algorithm.py,sha256=v8AZZ7hr5ZKJbavk242xCUpGHv3mKZ4sqfGV7BwPgdU,6854
|
|
@@ -115,7 +115,7 @@ investing_algorithm_framework/domain/models/order/order_type.py,sha256=d0TkR5hjZ
|
|
|
115
115
|
investing_algorithm_framework/domain/models/portfolio/__init__.py,sha256=gMMZG6Owvbsq7jL9PhhRbqV8tM9oebGUY8Yc6zedHj4,230
|
|
116
116
|
investing_algorithm_framework/domain/models/portfolio/portfolio.py,sha256=xUUk9mEwuJLhDPpA6nVmY6AZtFjA1bHrye0mTbAmgUs,5503
|
|
117
117
|
investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py,sha256=EX3RXeAEGqwZj5oXVCsaYSP7TysRTqLL_9iu5ViW8gE,2737
|
|
118
|
-
investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py,sha256=
|
|
118
|
+
investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py,sha256=w8-nyhGC4ZZzvNv31MkuGGcRQhVsKD2uSknGxVpNSP0,6901
|
|
119
119
|
investing_algorithm_framework/domain/models/position/__init__.py,sha256=Iv4-DUwgwf521P5qCu6R3WSVZxPeEtGoHP8WsS3qNUU,123
|
|
120
120
|
investing_algorithm_framework/domain/models/position/position.py,sha256=MSE1hHowJEUF9ljjSeUnvMLU0eLy1gdL6P7cwExzwZM,1575
|
|
121
121
|
investing_algorithm_framework/domain/models/position/position_snapshot.py,sha256=BpMhUTn--oUVXQHi62uOb4Ac7yuBwHW3iUCFpBPOtW0,1131
|
|
@@ -127,7 +127,7 @@ investing_algorithm_framework/domain/models/time_unit.py,sha256=dCi1lcVK-QGlOt6y
|
|
|
127
127
|
investing_algorithm_framework/domain/models/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
128
128
|
investing_algorithm_framework/domain/models/tracing/trace.py,sha256=iAVEN102-y_7Wj9Qg7kdti8-2I63Y8UG0SF3V2pkHj8,699
|
|
129
129
|
investing_algorithm_framework/domain/models/trade/__init__.py,sha256=2hX5zmAodsEuFeFghsQhinNobXVuc4oYcMeczY2sbsc,308
|
|
130
|
-
investing_algorithm_framework/domain/models/trade/trade.py,sha256=
|
|
130
|
+
investing_algorithm_framework/domain/models/trade/trade.py,sha256=CAOhDEdX6Ot3PlpFWm8kJP47G4t1ceY9hNWhZK-s1D0,12960
|
|
131
131
|
investing_algorithm_framework/domain/models/trade/trade_risk_type.py,sha256=f-1bOc2GkdphPL3ewPzgsZ5OLX2_fc2e1DVARDl1RRc,839
|
|
132
132
|
investing_algorithm_framework/domain/models/trade/trade_status.py,sha256=9b5QDwg8vsu_iRtGWatJ1rJFubjIWslKHTG3cK0zVQ4,1004
|
|
133
133
|
investing_algorithm_framework/domain/models/trade/trade_stop_loss.py,sha256=B9mBALaqOu2VI9v_PTv6C2ZrP6afTEi7seBD8kZi7bw,10366
|
|
@@ -202,7 +202,7 @@ investing_algorithm_framework/infrastructure/services/azure/__init__.py,sha256=P
|
|
|
202
202
|
investing_algorithm_framework/infrastructure/services/azure/state_handler.py,sha256=EUk4PdVl6RQ19DuWdrC4DzgOhGcL3qiZKWgWh_obT4E,5240
|
|
203
203
|
investing_algorithm_framework/services/__init__.py,sha256=9p0Y2enp6UMOlU4qJgVoojHBRARLGefNzbPxgSCN0wI,4999
|
|
204
204
|
investing_algorithm_framework/services/backtesting/__init__.py,sha256=sD6JMQVuUT8NRKV77VC9jyGnHcGox0W2n9eA-4ydeHY,84
|
|
205
|
-
investing_algorithm_framework/services/backtesting/backtest_service.py,sha256=
|
|
205
|
+
investing_algorithm_framework/services/backtesting/backtest_service.py,sha256=cH_LOvDxkPI9rp8ic1eqGqtWYo7EW60nZEfBYwJ50jI,24112
|
|
206
206
|
investing_algorithm_framework/services/configuration_service.py,sha256=BCgiBlrLjMjfU4afmjYaHu9gOWNmgaxhf6RBN2XJkw0,2853
|
|
207
207
|
investing_algorithm_framework/services/data_providers/__init__.py,sha256=OHVccpIYGc-1B2AkCI_2Nhsb9KMaAUrng4DHhIbFD8Y,96
|
|
208
208
|
investing_algorithm_framework/services/data_providers/data_provider_service.py,sha256=Tv5W38rshK7sG7XEhp7L-McdiNWAAlvU_1ScSdt1NCE,28420
|
|
@@ -252,8 +252,8 @@ investing_algorithm_framework/services/trade_order_evaluator/default_trade_order
|
|
|
252
252
|
investing_algorithm_framework/services/trade_order_evaluator/trade_order_evaluator.py,sha256=pNnmgaKMR9RY6Kxq7xS0nURKoaQDe2ehrP5GfElkkcI,1328
|
|
253
253
|
investing_algorithm_framework/services/trade_service/__init__.py,sha256=AcwPyJjDRdiREnl_MWMkDSc-V-ZjXtvpHD6eQT9mc1o,68
|
|
254
254
|
investing_algorithm_framework/services/trade_service/trade_service.py,sha256=OtzIS5EebByGcqDvV2AFeBjXSarvrgubMXDaVKg6Rbw,41193
|
|
255
|
-
investing_algorithm_framework-7.16.
|
|
256
|
-
investing_algorithm_framework-7.16.
|
|
257
|
-
investing_algorithm_framework-7.16.
|
|
258
|
-
investing_algorithm_framework-7.16.
|
|
259
|
-
investing_algorithm_framework-7.16.
|
|
255
|
+
investing_algorithm_framework-7.16.13.dist-info/LICENSE,sha256=wbVEDvoZiMPHufRY3sLEffvAr7GH5hOIngHF8y4HFQg,11343
|
|
256
|
+
investing_algorithm_framework-7.16.13.dist-info/METADATA,sha256=z5XVhd9gCbPlf5UC7xXtwybpMRh6o_hM7dOHw4_q2o8,19636
|
|
257
|
+
investing_algorithm_framework-7.16.13.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
258
|
+
investing_algorithm_framework-7.16.13.dist-info/entry_points.txt,sha256=jrPF0YksDs27vYzEvj3tXLe3OGWU24EJA05z5xHqmq8,91
|
|
259
|
+
investing_algorithm_framework-7.16.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|