live market websocket and monitoring wallets

This commit is contained in:
2025-10-20 20:46:48 +02:00
parent 64f7866083
commit 70f3d48336
13 changed files with 996 additions and 183 deletions

View File

@ -0,0 +1,24 @@
import pandas as pd
from strategies.base_strategy import BaseStrategy
import logging
class SingleSmaStrategy(BaseStrategy):
"""
A strategy based on the price crossing a single Simple Moving Average (SMA).
"""
def calculate_signals(self, df: pd.DataFrame) -> pd.DataFrame:
sma_period = self.params.get('sma_period', 0)
if not sma_period or len(df) < sma_period:
logging.warning(f"Not enough data for SMA period {sma_period}. Need {sma_period}, have {len(df)}.")
df['signal'] = 0
return df
df['sma'] = df['close'].rolling(window=sma_period).mean()
# Signal is 1 when price is above SMA, -1 when below
df['signal'] = 0
df.loc[df['close'] > df['sma'], 'signal'] = 1
df.loc[df['close'] < df['sma'], 'signal'] = -1
return df