investing-algorithm-framework 7.16.5__py3-none-any.whl → 7.16.6__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/services/metrics/trades.py +27 -13
- {investing_algorithm_framework-7.16.5.dist-info → investing_algorithm_framework-7.16.6.dist-info}/METADATA +1 -1
- {investing_algorithm_framework-7.16.5.dist-info → investing_algorithm_framework-7.16.6.dist-info}/RECORD +6 -6
- {investing_algorithm_framework-7.16.5.dist-info → investing_algorithm_framework-7.16.6.dist-info}/LICENSE +0 -0
- {investing_algorithm_framework-7.16.5.dist-info → investing_algorithm_framework-7.16.6.dist-info}/WHEEL +0 -0
- {investing_algorithm_framework-7.16.5.dist-info → investing_algorithm_framework-7.16.6.dist-info}/entry_points.txt +0 -0
|
@@ -298,8 +298,7 @@ def get_average_trade_gain(trades: List[Trade]) -> Tuple[float, float]:
|
|
|
298
298
|
trades (List[Trade]): List of trades.
|
|
299
299
|
|
|
300
300
|
Returns:
|
|
301
|
-
Tuple[float, float]: The average gain
|
|
302
|
-
percentage of the average loss
|
|
301
|
+
Tuple[float, float]: The average gain and average gain percentage
|
|
303
302
|
"""
|
|
304
303
|
if trades is None or len(trades) == 0:
|
|
305
304
|
raise OperationalException(
|
|
@@ -307,19 +306,26 @@ def get_average_trade_gain(trades: List[Trade]) -> Tuple[float, float]:
|
|
|
307
306
|
)
|
|
308
307
|
|
|
309
308
|
gains = [t.net_gain_absolute for t in trades if t.net_gain_absolute > 0]
|
|
310
|
-
cost = sum(t.cost for t in trades if t.net_gain_absolute > 0)
|
|
311
309
|
|
|
312
310
|
if not gains:
|
|
313
311
|
return 0.0, 0.0
|
|
314
312
|
|
|
315
313
|
average_gain = sum(gains) / len(gains)
|
|
316
|
-
percentage = (average_gain / cost) if cost > 0 else 0.0
|
|
317
|
-
return average_gain, percentage
|
|
318
314
|
|
|
315
|
+
# Updated percentage calculation to match other functions
|
|
316
|
+
percentage_returns = [
|
|
317
|
+
(t.net_gain_absolute / t.cost) for t in trades
|
|
318
|
+
if t.net_gain_absolute > 0 and t.cost > 0
|
|
319
|
+
]
|
|
320
|
+
average_gain_percentage = (
|
|
321
|
+
sum(percentage_returns) / len(percentage_returns)
|
|
322
|
+
if percentage_returns else 0.0
|
|
323
|
+
)
|
|
319
324
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
325
|
+
return average_gain, average_gain_percentage
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def get_current_average_trade_gain(trades: List[Trade]) -> Tuple[float, float]:
|
|
323
329
|
"""
|
|
324
330
|
Calculate the average gain from a list of trades,
|
|
325
331
|
including both closed and open trades.
|
|
@@ -329,8 +335,7 @@ def get_current_average_trade_gain(
|
|
|
329
335
|
Args:
|
|
330
336
|
trades (List[Trade]): List of trades.
|
|
331
337
|
Returns:
|
|
332
|
-
Tuple[float, float]: The average gain
|
|
333
|
-
percentage of the average loss
|
|
338
|
+
Tuple[float, float]: The average gain and average gain percentage
|
|
334
339
|
"""
|
|
335
340
|
if trades is None or len(trades) == 0:
|
|
336
341
|
raise OperationalException(
|
|
@@ -338,14 +343,23 @@ def get_current_average_trade_gain(
|
|
|
338
343
|
)
|
|
339
344
|
|
|
340
345
|
gains = [t.net_gain_absolute for t in trades if t.net_gain_absolute > 0]
|
|
341
|
-
cost = sum(t.cost for t in trades if t.net_gain_absolute > 0)
|
|
342
346
|
|
|
343
347
|
if not gains:
|
|
344
348
|
return 0.0, 0.0
|
|
345
349
|
|
|
346
350
|
average_gain = sum(gains) / len(gains)
|
|
347
|
-
|
|
348
|
-
|
|
351
|
+
|
|
352
|
+
# Updated percentage calculation to match other functions
|
|
353
|
+
percentage_returns = [
|
|
354
|
+
(t.net_gain_absolute / t.cost) for t in trades
|
|
355
|
+
if t.net_gain_absolute > 0 and t.cost > 0
|
|
356
|
+
]
|
|
357
|
+
average_gain_percentage = (
|
|
358
|
+
sum(percentage_returns) / len(percentage_returns)
|
|
359
|
+
if percentage_returns else 0.0
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
return average_gain, average_gain_percentage
|
|
349
363
|
|
|
350
364
|
|
|
351
365
|
def get_average_trade_loss(trades: List[Trade]) -> Tuple[float, float]:
|
|
@@ -225,7 +225,7 @@ investing_algorithm_framework/services/metrics/risk_free_rate.py,sha256=bATheWxy
|
|
|
225
225
|
investing_algorithm_framework/services/metrics/sharpe_ratio.py,sha256=XDEiTUBoK-qpoeqmbhrcy1v-AuNagWhTWx_Myn0g8-A,5497
|
|
226
226
|
investing_algorithm_framework/services/metrics/sortino_ratio.py,sha256=WA8uTkyk8RMG6uMplCvV8okAlKG_aeTP4ZAX2VyNkpA,2993
|
|
227
227
|
investing_algorithm_framework/services/metrics/standard_deviation.py,sha256=oObshTljORuE3x1cS0wej8QCqmDzAwHQgOA5u_HdfbU,4533
|
|
228
|
-
investing_algorithm_framework/services/metrics/trades.py,sha256=
|
|
228
|
+
investing_algorithm_framework/services/metrics/trades.py,sha256=SFp3Zc71xzjux06dNUm9H352OGO2XBXk8W_WrQ8-kd4,14052
|
|
229
229
|
investing_algorithm_framework/services/metrics/treynor_ratio.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
230
230
|
investing_algorithm_framework/services/metrics/ulcer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
231
231
|
investing_algorithm_framework/services/metrics/value_at_risk.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -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.6.dist-info/LICENSE,sha256=wbVEDvoZiMPHufRY3sLEffvAr7GH5hOIngHF8y4HFQg,11343
|
|
256
|
+
investing_algorithm_framework-7.16.6.dist-info/METADATA,sha256=w6BMuWR2lWxlgiUwyzAmdYUdOlAQUke8pdO46Dp7uWY,19635
|
|
257
|
+
investing_algorithm_framework-7.16.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
258
|
+
investing_algorithm_framework-7.16.6.dist-info/entry_points.txt,sha256=jrPF0YksDs27vYzEvj3tXLe3OGWU24EJA05z5xHqmq8,91
|
|
259
|
+
investing_algorithm_framework-7.16.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|