Spaces:
Runtime error
Runtime error
Update pattern_analyzer.py
Browse files- pattern_analyzer.py +6 -10
pattern_analyzer.py
CHANGED
|
@@ -9,13 +9,12 @@ from pattern_logic import PatternLogic
|
|
| 9 |
class PatternAnalyzer:
|
| 10 |
def __init__(self):
|
| 11 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 12 |
-
"
|
| 13 |
-
load_in_8bit=True,
|
| 14 |
-
device_map="auto",
|
| 15 |
-
torch_dtype="auto"
|
| 16 |
)
|
| 17 |
-
self.tokenizer = AutoTokenizer.from_pretrained("
|
| 18 |
-
|
| 19 |
self.basic_patterns = {
|
| 20 |
'channel': {'min_points': 4, 'confidence_threshold': 0.7},
|
| 21 |
'triangle': {'min_points': 3, 'confidence_threshold': 0.75},
|
|
@@ -27,7 +26,7 @@ class PatternAnalyzer:
|
|
| 27 |
self.pattern_logic = PatternLogic()
|
| 28 |
|
| 29 |
def analyze_data(self, ohlcv_data):
|
| 30 |
-
data_prompt = f"""TASK: Identify high-confidence technical patterns only.
|
| 31 |
Minimum confidence threshold: 0.8
|
| 32 |
Required pattern criteria:
|
| 33 |
1. Channel: Must have at least 3 touching points
|
|
@@ -57,7 +56,6 @@ class PatternAnalyzer:
|
|
| 57 |
|
| 58 |
for pattern in analysis_data.get('patterns', []):
|
| 59 |
pattern_type = pattern.get('type')
|
| 60 |
-
|
| 61 |
if pattern_type in self.basic_patterns:
|
| 62 |
threshold = self.basic_patterns[pattern_type]['confidence_threshold']
|
| 63 |
if pattern.get('confidence', 0) >= threshold:
|
|
@@ -70,8 +68,6 @@ class PatternAnalyzer:
|
|
| 70 |
'timestamp': pd.Timestamp.now().isoformat()
|
| 71 |
}
|
| 72 |
})
|
| 73 |
-
|
| 74 |
return patterns
|
| 75 |
-
|
| 76 |
except json.JSONDecodeError:
|
| 77 |
return []
|
|
|
|
| 9 |
class PatternAnalyzer:
|
| 10 |
def __init__(self):
|
| 11 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 12 |
+
"http://localhost:5000/codellama-chart-model",
|
| 13 |
+
load_in_8bit=True,
|
| 14 |
+
device_map="auto",
|
| 15 |
+
torch_dtype="auto"
|
| 16 |
)
|
| 17 |
+
self.tokenizer = AutoTokenizer.from_pretrained("http://localhost:5000/codellama-chart-model")
|
|
|
|
| 18 |
self.basic_patterns = {
|
| 19 |
'channel': {'min_points': 4, 'confidence_threshold': 0.7},
|
| 20 |
'triangle': {'min_points': 3, 'confidence_threshold': 0.75},
|
|
|
|
| 26 |
self.pattern_logic = PatternLogic()
|
| 27 |
|
| 28 |
def analyze_data(self, ohlcv_data):
|
| 29 |
+
data_prompt = f"""TASK: Identify high-confidence technical patterns only.
|
| 30 |
Minimum confidence threshold: 0.8
|
| 31 |
Required pattern criteria:
|
| 32 |
1. Channel: Must have at least 3 touching points
|
|
|
|
| 56 |
|
| 57 |
for pattern in analysis_data.get('patterns', []):
|
| 58 |
pattern_type = pattern.get('type')
|
|
|
|
| 59 |
if pattern_type in self.basic_patterns:
|
| 60 |
threshold = self.basic_patterns[pattern_type]['confidence_threshold']
|
| 61 |
if pattern.get('confidence', 0) >= threshold:
|
|
|
|
| 68 |
'timestamp': pd.Timestamp.now().isoformat()
|
| 69 |
}
|
| 70 |
})
|
|
|
|
| 71 |
return patterns
|
|
|
|
| 72 |
except json.JSONDecodeError:
|
| 73 |
return []
|