-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (31 loc) · 965 Bytes
/
main.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
import websocket
import json
import talib
import numpy
from datetime import date
# import config
from crypto import Crypto
from strategies import RsiBasic, RsiParabolic
SOCKET = "wss://stream.binance.com:9443/ws/ethusdt@kline_1m"
def main():
crypto = Crypto(60, 40)
def onOpen(ws):
print('opened connection')
def onClose(ws):
print('closed connection')
def onMessage(ws, message):
# print('received message')
jsonMessage = json.loads(message)
candle = jsonMessage['k']
isCandleClosed = candle['x']
close = candle['c']
if isCandleClosed:
crypto.addClose(float(close))
RsiBasic(crypto, float(close))
ws = websocket.WebSocketApp(SOCKET,
on_open=onOpen,
on_close=onClose,
on_message=onMessage)
ws.run_forever()
if __name__ == "__main__":
main()