forked from cyclic-software/starter-micro-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (34 loc) · 1.15 KB
/
app.py
File metadata and controls
45 lines (34 loc) · 1.15 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
from flask import Flask, request
import json
import telebot
from binance.spot import Spot as Client
app = Flask(__name__)
@app.route("/webhook", methods=['POST'])
def webhook():
try:
data = json.loads(request.data)
ticker = data['ticker']
exchange = data['exchange']
price = data['price']
side = data['side']
quantity = data['quantity']
leverage = data['leverage']
telegramBotApi = data['telegramBotApi']
telegramUserId = data['telegramUserId']
binanceApiKey = data['binanceApiKey']
binanceSecretKey = data['binanceSecretKey']
params = {
"symbol": ticker,
"side": side,
"type": "MARKET",
"quantity": quantity,
"leverage": leverage,
}
Client(binanceApiKey, binanceSecretKey).new_order(**params)
telebot.TeleBot(telegramBotApi).send_message(telegramUserId,
f"{ticker} {side}ING on {exchange} \nQuantity : {quantity} ")
except:
pass
return {
"code": "success",
}