File size: 745 Bytes
cb1cc81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests

class DeepSeekAI:
    """Class to interact with DeepSeek API for AI-based market analysis"""

    DEEPSEEK_API_URL = "https://api.deepseek.com/v1/analyze"

    def __init__(self, api_key):
        """Initialize DeepSeekAI with API key"""
        self.api_key = api_key

    def analyze_stock(self, data):
        """Send stock data to DeepSeek for analysis and prediction"""
        headers = {"Authorization": f"Bearer {self.api_key}"}
        try:
            response = requests.post(self.DEEPSEEK_API_URL, json={"data": data.to_dict()}, headers=headers)
            response.raise_for_status()
            return response.json()
        except requests.exceptions.RequestException as e:
            return {"error": str(e)}