Spaces:
No application file
No application file
File size: 1,221 Bytes
e42e5e9 |
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 |
import ollama
from lightweight_charts import Chart
class PatternGenerator:
def __init__(self):
self.client = ollama.Client()
self.code_model = "codellama:latest"
self.patterns = [
'head_and_shoulders', 'double_top', 'double_bottom',
'triangle', 'channel', 'fibonacci', 'wedge', 'flag',
'pennant', 'cup_and_handle', 'rounding_bottom'
# Will expand to 300+ patterns
]
def generate_all_patterns(self, chart_image, historical_data):
pattern_charts = []
for pattern in self.patterns:
# Generate pattern drawing code using CodeLlama
code_prompt = f"Generate Lightweight Charts code to draw {pattern} pattern with proper styling and technical analysis markers"
code_response = self.client.generate(
model=self.code_model,
prompt=code_prompt
)
# Create chart with pattern overlay
chart = Chart()
chart.set(code_response)
chart.add_data(historical_data)
pattern_charts.append(chart)
return pattern_charts
|