mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-29 03:37:45 +00:00
78737b6835
- Update `.gitignore` to include `lab/` for backtesting and raw data. - Refactor `app.py` to improve error handling and logging. - Remove deprecated files: `core/bot_logic.py`, `core/bots/base_bot.py`, `core/bots/manager.py`, `core/db/database.py`, `core/routes/api_analysis.py`, `core/routes/api_bots_analysis.py`, `core/strategies/logic_ma.py`, `core/strategies/logic_rsi.py`. - Modify multiple files to enhance bot management, routing, and strategy handling. - Update JavaScript and HTML templates for better UI and functionality.
18 lines
717 B
Python
18 lines
717 B
Python
import pandas_ta as ta
|
|
from core.bots.base_bot import BaseStrategy
|
|
|
|
class MACrossoverStrategy(BaseStrategy):
|
|
def analyze(self):
|
|
df = self.bot.fetch_data()
|
|
if df is None or len(df) < 50:
|
|
return
|
|
|
|
df['SMA_fast'] = ta.sma(df['close'], length=20)
|
|
df['SMA_slow'] = ta.sma(df['close'], length=50)
|
|
last, prev = df.iloc[-1], df.iloc[-2]
|
|
|
|
if prev['SMA_fast'] <= prev['SMA_slow'] and last['SMA_fast'] > last['SMA_slow']:
|
|
self.bot.send_signal('BUY', reason="Golden Cross MA detected.")
|
|
elif prev['SMA_fast'] >= prev['SMA_slow'] and last['SMA_fast'] < last['SMA_slow']:
|
|
self.bot.send_signal('SELL', reason="Death Cross MA detected.")
|