File size: 1,158 Bytes
d5b7ee9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pandas as pd
import torch
import logging
from trading_cli.strategy.adapters.ai_fusion import AIFusionStrategy
from trading_cli.data.market import fetch_ohlcv_yfinance

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def test_ai_fusion():
    symbol = "AAPL"
    logger.info(f"Testing AI Fusion Strategy for {symbol}...")
    
    # 1. Fetch data
    df = fetch_ohlcv_yfinance(symbol, days=250)
    if df.empty:
        logger.error("Failed to fetch data")
        return
    
    # 2. Instantiate strategy
    strategy = AIFusionStrategy()
    
    # 3. Generate signal
    # Note: sentiment_score is optional, defaults to 0.0
    result = strategy.generate_signal(symbol, df, sentiment_score=0.1)
    
    # 4. Print result
    logger.info("Signal Result:")
    logger.info(f"  Symbol:     {result.symbol}")
    logger.info(f"  Action:     {result.action}")
    logger.info(f"  Confidence: {result.confidence:.2%}")
    logger.info(f"  Reason:     {result.reason}")
    
    if result.metadata:
        logger.info(f"  Metadata:   {result.metadata}")

if __name__ == "__main__":
    test_ai_fusion()