forked from wxylssy/LSSY
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpcTrade.py
77 lines (67 loc) · 1.81 KB
/
rpcTrade.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
74
75
76
77
from xmlrpc.client import ServerProxy
rpc_url = 'http://192.168.122.122:8081/'
def login():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.login()
return result
except:
return False
def get_ky_balance():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.get_ky_balance()
return result
except:
return '0'
def buy(code, name, price: str, tol: int):
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.buy(code, name, price, tol)
return result
except Exception as e:
print(e)
return False
def sell(code, name, price: str, tol: int):
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.sell(code, name, price, tol)
return result
except Exception as e:
print(e)
return False
def get_chicang():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.get_chicang()
return result
except:
return None
def get_chengjiao(ht_bh):
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.get_chengjiao(ht_bh)
return result
except:
return {}
def get_weituo():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.get_weituo()
return result
except:
return {}
def cancel_oder_all():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.cancel_oder_all()
return result
except:
return False
def kill():
with ServerProxy(rpc_url) as proxy:
try:
result = proxy.kill()
return result
except:
return False