This commit is contained in:
ddrwode
2026-02-20 21:37:52 +08:00
parent 45a56e0aef
commit 29c1b3ffd1
5 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1 @@
["macd", "macd_signal", "macd_hist", "adx", "di_plus", "di_minus", "trix", "aroon_up", "aroon_down", "cci", "dpo", "kst", "vortex_pos", "vortex_neg", "rsi", "stoch_k", "stoch_d", "williams_r", "roc", "tsi", "uo", "ao", "ppo", "stoch_rsi_k", "stoch_rsi_d", "bb_width", "bb_pband", "atr", "price_change_pct", "high_low_range", "body_ratio", "upper_shadow", "lower_shadow", "volatility_ratio", "close_sma20_ratio", "close_ema12_ratio", "macd_lag1", "macd_signal_lag1", "macd_hist_lag1", "adx_lag1", "di_plus_lag1", "di_minus_lag1", "trix_lag1", "aroon_up_lag1", "aroon_down_lag1", "cci_lag1", "dpo_lag1", "kst_lag1", "vortex_pos_lag1", "vortex_neg_lag1", "rsi_lag1", "stoch_k_lag1", "stoch_d_lag1", "williams_r_lag1", "roc_lag1", "tsi_lag1", "uo_lag1", "ao_lag1", "ppo_lag1", "stoch_rsi_k_lag1", "stoch_rsi_d_lag1", "bb_width_lag1", "bb_pband_lag1", "atr_lag1", "price_change_pct_lag1", "high_low_range_lag1", "body_ratio_lag1", "upper_shadow_lag1", "lower_shadow_lag1", "volatility_ratio_lag1", "close_sma20_ratio_lag1", "close_ema12_ratio_lag1", "macd_lag3", "macd_signal_lag3", "macd_hist_lag3", "adx_lag3", "di_plus_lag3", "di_minus_lag3", "trix_lag3", "aroon_up_lag3", "aroon_down_lag3", "cci_lag3", "dpo_lag3", "kst_lag3", "vortex_pos_lag3", "vortex_neg_lag3", "rsi_lag3", "stoch_k_lag3", "stoch_d_lag3", "williams_r_lag3", "roc_lag3", "tsi_lag3", "uo_lag3", "ao_lag3", "ppo_lag3", "stoch_rsi_k_lag3", "stoch_rsi_d_lag3", "bb_width_lag3", "bb_pband_lag3", "atr_lag3", "price_change_pct_lag3", "high_low_range_lag3", "body_ratio_lag3", "upper_shadow_lag3", "lower_shadow_lag3", "volatility_ratio_lag3", "close_sma20_ratio_lag3", "close_ema12_ratio_lag3", "macd_lag5", "macd_signal_lag5", "macd_hist_lag5", "adx_lag5", "di_plus_lag5", "di_minus_lag5", "trix_lag5", "aroon_up_lag5", "aroon_down_lag5", "cci_lag5", "dpo_lag5", "kst_lag5", "vortex_pos_lag5", "vortex_neg_lag5", "rsi_lag5", "stoch_k_lag5", "stoch_d_lag5", "williams_r_lag5", "roc_lag5", "tsi_lag5", "uo_lag5", "ao_lag5", "ppo_lag5", "stoch_rsi_k_lag5", "stoch_rsi_d_lag5", "bb_width_lag5", "bb_pband_lag5", "atr_lag5", "price_change_pct_lag5", "high_low_range_lag5", "body_ratio_lag5", "upper_shadow_lag5", "lower_shadow_lag5", "volatility_ratio_lag5", "close_sma20_ratio_lag5", "close_ema12_ratio_lag5", "rsi_5m", "macd_5m", "adx_5m", "bb_pband_5m", "atr_5m", "cci_5m", "rsi_60m", "macd_60m", "adx_60m", "bb_pband_60m", "atr_60m", "cci_60m"]

Binary file not shown.

Binary file not shown.

21
run_scheme_b_train.py Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""
仅运行方案BLightGBM训练并保存模型供实盘脚本 get_live_signal 使用。
需先保证 models/database.db 中有 15m/5m/1h K 线(例如运行 抓取多周期K线.py
"""
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from strategy.ai_strategy import run_ai_strategy
if __name__ == '__main__':
p = argparse.ArgumentParser(description='方案B 训练并保存模型(实盘用)')
p.add_argument('--period', type=int, default=15, help='主周期分钟,默认 15')
p.add_argument('--start', type=str, default=None, help='回测开始日期,如 2024-01-01')
p.add_argument('--end', type=str, default=None, help='回测结束日期,如 2024-12-31')
args = p.parse_args()
run_ai_strategy(model_type='lightgbm', period=args.period,
start_date=args.start, end_date=args.end)

View File

@@ -210,5 +210,6 @@ def get_live_signal(period: int = None, model_type: str = 'lightgbm',
if X_last.empty:
return 0
X_scaled = scaler.transform(X_last)
pred = model.predict(X_scaled)
X_scaled_df = pd.DataFrame(X_scaled, columns=feature_cols, index=X_last.index)
pred = model.predict(X_scaled_df)
return int(pred[0])