Spaces:
Running
Running
Update r2.py
Browse files
r2.py
CHANGED
|
@@ -63,6 +63,48 @@ class R2Service:
|
|
| 63 |
except Exception as e:
|
| 64 |
print(f"โ Failed to release lock: {e}")
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
async def save_llm_prompts_async(self, symbol, prompt_type, prompt_content, analysis_data=None):
|
| 67 |
"""ุญูุธ ุงูู Prompts ุงูู
ุฑุณูุฉ ุฅูู ุงููู
ูุฐุฌ ุงูุถุฎู
"""
|
| 68 |
try:
|
|
@@ -292,4 +334,4 @@ class R2Service:
|
|
| 292 |
print(f"โ Failed to get monitored trades: {e}")
|
| 293 |
return []
|
| 294 |
|
| 295 |
-
print("โ
Enhanced R2 Service Loaded - Comprehensive Logging System")
|
|
|
|
| 63 |
except Exception as e:
|
| 64 |
print(f"โ Failed to release lock: {e}")
|
| 65 |
|
| 66 |
+
async def save_candidates_async(self, candidates):
|
| 67 |
+
"""ุญูุธ ุจูุงูุงุช ุงูู
ุฑุดุญูู ุงูุนุดุฑุฉ ูู ู
ูู ู
ููุตู ูู R2"""
|
| 68 |
+
try:
|
| 69 |
+
key = "Candidates.json"
|
| 70 |
+
data = {
|
| 71 |
+
"timestamp": datetime.now().isoformat(),
|
| 72 |
+
"total_candidates": len(candidates),
|
| 73 |
+
"candidates": candidates
|
| 74 |
+
}
|
| 75 |
+
data_json = json.dumps(data, indent=2, ensure_ascii=False).encode('utf-8')
|
| 76 |
+
self.s3_client.put_object(
|
| 77 |
+
Bucket=BUCKET_NAME, Key=key, Body=data_json, ContentType="application/json"
|
| 78 |
+
)
|
| 79 |
+
print(f"โ
ุชู
ุญูุธ {len(candidates)} ู
ุฑุดุญ ูู ู
ูู Candidates ูู R2")
|
| 80 |
+
|
| 81 |
+
# ุนุฑุถ ู
ุนููู
ุงุช ุงูู
ุฑุดุญูู ุงูู
ุญููุธูู
|
| 82 |
+
print("๐ ุงูู
ุฑุดุญูู ุงูู
ุญููุธูู:")
|
| 83 |
+
for i, candidate in enumerate(candidates):
|
| 84 |
+
symbol = candidate.get('symbol', 'Unknown')
|
| 85 |
+
score = candidate.get('enhanced_final_score', 0)
|
| 86 |
+
strategy = candidate.get('target_strategy', 'GENERIC')
|
| 87 |
+
print(f" {i+1}. {symbol}: {score:.3f} - {strategy}")
|
| 88 |
+
|
| 89 |
+
except Exception as e:
|
| 90 |
+
print(f"โ ูุดู ุญูุธ ุงูู
ุฑุดุญูู ูู R2: {e}")
|
| 91 |
+
|
| 92 |
+
async def load_candidates_async(self):
|
| 93 |
+
"""ุชุญู
ูู ุจูุงูุงุช ุงูู
ุฑุดุญูู ู
ู R2"""
|
| 94 |
+
try:
|
| 95 |
+
key = "Candidates.json"
|
| 96 |
+
response = self.s3_client.get_object(Bucket=BUCKET_NAME, Key=key)
|
| 97 |
+
data = json.loads(response['Body'].read())
|
| 98 |
+
candidates = data.get('candidates', [])
|
| 99 |
+
print(f"โ
ุชู
ุชุญู
ูู {len(candidates)} ู
ุฑุดุญ ู
ู R2")
|
| 100 |
+
return candidates
|
| 101 |
+
except ClientError as e:
|
| 102 |
+
if e.response['Error']['Code'] == 'NoSuchKey':
|
| 103 |
+
print("โ ๏ธ ูุง ููุฌุฏ ู
ูู ู
ุฑุดุญูู ุณุงุจู")
|
| 104 |
+
return []
|
| 105 |
+
else:
|
| 106 |
+
raise
|
| 107 |
+
|
| 108 |
async def save_llm_prompts_async(self, symbol, prompt_type, prompt_content, analysis_data=None):
|
| 109 |
"""ุญูุธ ุงูู Prompts ุงูู
ุฑุณูุฉ ุฅูู ุงููู
ูุฐุฌ ุงูุถุฎู
"""
|
| 110 |
try:
|
|
|
|
| 334 |
print(f"โ Failed to get monitored trades: {e}")
|
| 335 |
return []
|
| 336 |
|
| 337 |
+
print("โ
Enhanced R2 Service Loaded - Comprehensive Logging System with Candidates Support")
|