crypto_quant/orb_trade_main.py

35 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from core.trade.orb_trade import ORBStrategy
from config import US_STOCK_MONITOR_CONFIG
import core.logger as logging
logger = logging.logger
def main():
symbols = US_STOCK_MONITOR_CONFIG.get("volume_monitor", {}).get("symbols", ["QQQ"])
for symbol in symbols:
logger.info(f"开始回测 {symbol}")
# 初始化ORB策略
orb_strategy = ORBStrategy(
initial_capital=25000,
max_leverage=4,
risk_per_trade=0.01,
commission_per_share=0.0005,
is_us_stock=True,
)
# 1. 获取QQQ的5分钟日内数据2024-2025注意yfinance免费版可能限制历史日内数据建议用专业数据源
orb_strategy.fetch_intraday_data(
symbol=symbol, start_date="2024-11-30", end_date="2025-08-30", interval="5m"
)
# 2. 生成ORB策略信号
orb_strategy.generate_orb_signals()
# 3. 回测策略盈利目标10R
orb_strategy.backtest(profit_target_multiple=10)
# 4. 绘制净值曲线
orb_strategy.plot_equity_curve()
if __name__ == "__main__":
main()