Browse Source

FIX: NaN in diffs

master
Barthélemy Paléologue 7 months ago
parent
commit
84091ddeba
  1. 2
      auto_trading/indicators/slopy.py
  2. 15
      auto_trading/indicators/sma2.py

2
auto_trading/indicators/slopy.py

@ -29,7 +29,7 @@ class Slopy(Indicator):
# select high prices for each action
highData = data2["close"]
coeffs = highData.diff()
coeffs = highData.diff().fillna(0)
res = {}
for column in coeffs.columns:

15
auto_trading/indicators/sma2.py

@ -3,6 +3,7 @@ import pandas as pd # type: ignore
from ..interfaces import Indicator
import logging
class SMA(Indicator):
"""Replay the value."""
@ -32,17 +33,9 @@ class SMA(Indicator):
sma = data3.rolling(window=self.windowSize).mean().fillna(0)
# computes slope at each point of the sma
smaDiff = sma.diff()
smaDiff = sma.diff().fillna(0)
res = {}
for column in sma.columns:
# pour chaque type d'action
coeff = smaDiff[column].get(sma.index[-1])
# TODO: ne pas hardcoder
normalization_factor = 0.2
trust = coeff * normalization_factor
res[column] = trust
res = smaDiff.iloc[-1]
logging.info(res)
return pd.Series(res)

Loading…
Cancel
Save