-
Notifications
You must be signed in to change notification settings - Fork 62
/
app.py
73 lines (55 loc) · 1.86 KB
/
app.py
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
import logbot
import json, os, config
from flask import Flask, request
from orderapi import order
app = Flask(__name__)
@app.route("/")
def hello_trader():
return "<p>Hello young trader!</p>"
@app.route("/tradingview-to-webhook-order", methods=['POST'])
def tradingview_webhook():
logbot.logs("========= STRATEGY =========")
data = json.loads(request.data)
webhook_passphrase = os.environ.get('WEBHOOK_PASSPHRASE', config.WEBHOOK_PASSPHRASE)
if 'passphrase' not in data.keys():
logbot.logs(">>> /!\ No passphrase entered", True)
return {
"success": False,
"message": "no passphrase entered"
}
if data['passphrase'] != webhook_passphrase:
logbot.logs(">>> /!\ Invalid passphrase", True)
return {
"success": False,
"message": "invalid passphrase"
}
orders = order(data)
print(orders)
return orders
@app.route("/tradingview-to-discord-study", methods=['POST'])
def discord_study_tv():
logbot.logs("========== STUDY ==========")
data = json.loads(request.data)
webhook_passphrase = os.environ.get('WEBHOOK_PASSPHRASE', config.WEBHOOK_PASSPHRASE)
if 'passphrase' not in data.keys():
logbot.logs(">>> /!\ No passphrase entered", True)
return {
"success": False,
"message": "no passphrase entered"
}
if data['passphrase'] != webhook_passphrase:
logbot.logs(">>> /!\ Invalid passphrase", True)
return {
"success": False,
"message": "invalid passphrase"
}
del data["passphrase"]
try:
chart_url = data["chart_url"]
del data["chart_url"]
except KeyError:
logbot.logs(">>> /!\ Key 'chart_url' not found", True)
logbot.study_alert(json.dumps(data), chart_url)
return {
"success": True
}