forked from kbai/python-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_trade.py
More file actions
40 lines (34 loc) · 1.23 KB
/
Copy pathtest_trade.py
File metadata and controls
40 lines (34 loc) · 1.23 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
import binance
from binance.client import Client
import pickle
api_key = '94V1LhT5WYbX8c991G5BWufZn0xLaIgA1qovZPScuXbisVNnqSCnV3qvkcscDG4I';
api_secret = 'Rbjo7QGS4Wnt3wFdygLcPaCqlRin3iGwAtxybVNRsb7NJyDZyR4QuAomgCeNddnc';
client = Client(api_key, api_secret,tld = 'us')
#print(client.get_all_tickers())
#print(client.order_limit_buy(symbol='ETHUSD',price=130.0,quantity=0.1, newClientOrderId = 'ADASFDS'))
#print(client.get_open_orders())
#for order in client.get_open_orders():
# print(order['orderId'])
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
# Enable broadcasting mode
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
def parseMsg(msg):
print(msg.split(','))
client.bind(("", 37020))
while True:
# Thanks @seym45 for a fix
data, addr = client.recvfrom(1024)
res = pickle.loads(data)
if res['s'] == 'ETHUSDT':
print(res['p'],res['q'])
# if(res['s'])
# print()
# parseMsg(str(data))
#try:
# print(client.cancel_order(symbol = 'ETHUSD', origClientOrderId = 'ADASFDS'))
#except binance.exceptions.BinanceAPIException as e:
# print(e)
# client.
#client.create_test_order()