-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_make_integration.py
More file actions
190 lines (160 loc) Β· 6.13 KB
/
setup_make_integration.py
File metadata and controls
190 lines (160 loc) Β· 6.13 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/usr/bin/env python3
"""
Make.com Integration Setup Helper
This script helps you test and set up the TA Worker integration with Make.com
"""
import requests
import json
import time
from datetime import datetime
# Configuration
TA_WORKER_URL = "https://ta-worker-ta-worker-ai.up.railway.app"
SYMBOL = "HYPEUSDT"
TIMEFRAMES = "15m,1h,4h,1d"
LOOKBACK = 300
CATEGORY = "linear"
def test_ta_worker():
"""Test TA Worker API"""
print("π Testing TA Worker API...")
url = f"{TA_WORKER_URL}/v1/run"
params = {
"symbol": SYMBOL,
"tfs": TIMEFRAMES,
"lookback": LOOKBACK,
"category": CATEGORY
}
try:
response = requests.get(url, params=params, timeout=30)
if response.status_code == 200:
data = response.json()
print("β
TA Worker API is working!")
print(f"π Symbol: {data['symbol']}")
print(f"π Timestamp: {data['now']}")
print(f"π Timeframes: {list(data['features'].keys())}")
# Show sample data
first_tf = list(data['features'].keys())[0]
sample = data['features'][first_tf]
print(f"\nπ Sample data for {first_tf}:")
print(f" Price: ${sample.get('price', 'N/A')}")
print(f" RSI: {sample.get('rsi14', 'N/A')}")
print(f" Support Levels: {sample.get('support_resistance', {}).get('support', [])[:3]}")
print(f" Resistance Levels: {sample.get('support_resistance', {}).get('resistance', [])[:3]}")
return data
else:
print(f"β TA Worker API failed: {response.status_code}")
print(f"Error: {response.text}")
return None
except Exception as e:
print(f"β Error testing TA Worker: {e}")
return None
def generate_chatgpt_prompt(data):
"""Generate ChatGPT prompt for the data"""
print("\nπ€ Generating ChatGPT prompt...")
if not data:
return None
# Extract key data
symbol = data['symbol']
features = data['features']
# Get 15m data for analysis
tf_15m = features.get('15m', {})
prompt = f"""
You are an expert cryptocurrency trading analyst. Analyze the following technical data for {symbol} and provide a comprehensive trading recommendation.
Technical Analysis Data:
- Price: ${tf_15m.get('price', 'N/A')}
- RSI (14): {tf_15m.get('rsi14', 'N/A')}
- MACD: {tf_15m.get('macd', {}).get('val', 'N/A')} (Signal: {tf_15m.get('macd', {}).get('signal', 'N/A')})
- Support Levels: {tf_15m.get('support_resistance', {}).get('support', [])[:3]}
- Resistance Levels: {tf_15m.get('support_resistance', {}).get('resistance', [])[:3]}
- Fibonacci Retracements: {tf_15m.get('fibonacci', {}).get('retracements', {})}
- Elliott Wave Pattern: {tf_15m.get('elliott_waves', {}).get('pattern', 'N/A')} (Confidence: {tf_15m.get('elliott_waves', {}).get('confidence', 'N/A')})
- Order Blocks: {len(tf_15m.get('order_blocks', {}).get('bullish', []))} bullish, {len(tf_15m.get('order_blocks', {}).get('bearish', []))} bearish
Please provide your analysis in the following JSON format:
{{
"sentiment": "Bullish/Bearish/Neutral",
"confidence_score": 1-10,
"risk_level": "Low/Medium/High",
"entry_price": "price",
"stop_loss": "price",
"take_profit_1": "price",
"take_profit_2": "price",
"support_level": "price",
"resistance_level": "price",
"reasoning": "brief explanation"
}}
"""
print("β
ChatGPT prompt generated!")
return prompt
def create_make_scenario_config():
"""Create Make.com scenario configuration"""
print("\nπ§ Creating Make.com scenario configuration...")
config = {
"scenario_name": "TA Worker + ChatGPT Trading Bot",
"ta_worker_url": TA_WORKER_URL,
"symbol": SYMBOL,
"timeframes": TIMEFRAMES,
"lookback": LOOKBACK,
"category": CATEGORY,
"schedule": "every_15_minutes",
"modules": [
{
"name": "Get TA Worker Data",
"type": "http",
"url": f"{TA_WORKER_URL}/v1/run",
"method": "GET",
"parameters": {
"symbol": SYMBOL,
"tfs": TIMEFRAMES,
"lookback": LOOKBACK,
"category": CATEGORY
}
},
{
"name": "ChatGPT Analysis",
"type": "chatgpt",
"model": "gpt-4",
"temperature": 0.1,
"max_tokens": 2000
},
{
"name": "Telegram Notification",
"type": "telegram",
"chat_id": "YOUR_CHAT_ID"
}
]
}
# Save configuration
with open("make_scenario_config.json", "w") as f:
json.dump(config, f, indent=2)
print("β
Make.com scenario configuration saved to 'make_scenario_config.json'")
return config
def main():
"""Main setup function"""
print("π TA Worker + Make.com Integration Setup")
print("=" * 50)
# Test TA Worker
data = test_ta_worker()
if data:
# Generate ChatGPT prompt
prompt = generate_chatgpt_prompt(data)
# Create Make.com config
config = create_make_scenario_config()
print("\nπ― Next Steps:")
print("1. Copy the TA Worker URL to Make.com")
print("2. Use the generated ChatGPT prompt")
print("3. Set up your Telegram bot and get chat ID")
print("4. Configure the Make.com scenario")
print("5. Test with a manual run")
print(f"\nπ Key Information:")
print(f"TA Worker URL: {TA_WORKER_URL}")
print(f"Symbol: {SYMBOL}")
print(f"Category: {CATEGORY} (futures)")
print(f"Timeframes: {TIMEFRAMES}")
if prompt:
print(f"\nπ€ ChatGPT Prompt (copy this to Make.com):")
print("-" * 40)
print(prompt)
print("-" * 40)
else:
print("\nβ Setup failed. Please check your TA Worker deployment.")
if __name__ == "__main__":
main()