Files
MidasBot/freqtrade/user_data/strategies/SampleStrategy.py
jerem 633b033f4d MidasBot: bot trading crypto IA + stratégies Ichimoku validées
- Infra: Freqtrade (futures dry-run) + Redis + dashboard + Docker Compose
- Couche IA: ai_analyzer (Claude via abonnement, MCP TradingView, backfill biais)
- Stratégies: SampleStrategy, AiBiasStrategy, IchimokuLS (long/short, validée
  train/test + données vierges + walk-forward), MTFIchimoku, variantes hyperopt
- Arbitrage CEX (dry-run), backtesting, walk-forward, volatility targeting
- IchimokuLS en dry-run live (config_live.json)

Claude-Session: https://claude.ai/code/session_01VHETcFacdnDhQzthLpdYFR
2026-06-23 19:25:49 +02:00

76 lines
2.3 KiB
Python

# pragma pylint: disable=missing-docstring, invalid-name, too-few-public-methods
"""
SampleStrategy — stratégie de base MidasBot (Phase 1).
Croisement de moyennes mobiles exponentielles (EMA) avec filtre RSI.
Sert à valider le pipeline Freqtrade (dry-run, backtesting, FreqUI) avant
d'ajouter la couche IA (cf. AiBiasStrategy, Phase 3).
"""
from __future__ import annotations
import talib.abstract as ta
from pandas import DataFrame
from freqtrade.strategy import IStrategy
class SampleStrategy(IStrategy):
INTERFACE_VERSION = 3
# Timeframe d'analyse
timeframe = "1h"
# Take-profit échelonné (ROI minimal par durée, en minutes)
minimal_roi = {
"0": 0.05,
"120": 0.03,
"360": 0.01,
"720": 0,
}
# Stop-loss dur
stoploss = -0.10
# Trailing stop
trailing_stop = True
trailing_stop_positive = 0.02
trailing_stop_positive_offset = 0.03
trailing_only_offset_is_reached = True
# Nombre de bougies nécessaires avant de produire un signal
startup_candle_count: int = 50
# Ordres
process_only_new_candles = True
use_exit_signal = True
exit_profit_only = False
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe["ema_fast"] = ta.EMA(dataframe, timeperiod=9)
dataframe["ema_slow"] = ta.EMA(dataframe, timeperiod=21)
dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe["ema_fast"] > dataframe["ema_slow"])
& (dataframe["ema_fast"].shift(1) <= dataframe["ema_slow"].shift(1))
& (dataframe["rsi"] < 70)
& (dataframe["volume"] > 0)
),
"enter_long",
] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe["ema_fast"] < dataframe["ema_slow"])
& (dataframe["ema_fast"].shift(1) >= dataframe["ema_slow"].shift(1))
& (dataframe["volume"] > 0)
),
"exit_long",
] = 1
return dataframe