Spaces:
No application file
No application file
| import ollama | |
| from lightweight_charts import Chart | |
| class IndicatorGenerator: | |
| def __init__(self): | |
| self.client = ollama.Client() | |
| self.code_model = "codellama:latest" | |
| self.indicators = [ | |
| 'rsi', 'macd', 'bollinger_bands', 'moving_averages', | |
| 'stochastic', 'atr', 'volume_profile' | |
| ] | |
| def generate_all_indicators(self, historical_data): | |
| indicator_charts = [] | |
| for indicator in self.indicators: | |
| # Generate code for indicator using CodeLlama | |
| code_prompt = f"Generate Lightweight Charts code for {indicator} indicator with proper styling and configuration" | |
| code_response = self.client.generate( | |
| model=self.code_model, | |
| prompt=code_prompt | |
| ) | |
| # Create chart using generated code | |
| chart = Chart() | |
| chart.set(code_response) # Applies the generated configuration | |
| chart.add_data(historical_data) | |
| indicator_charts.append(chart) | |
| return indicator_charts | |
| def _create_indicator_chart(self, data, indicator_type): | |
| chart = Chart() | |
| # Specific indicator configurations using Lightweight Charts | |
| chart.add_indicator(indicator_type, data) | |
| return chart | |