-
Notifications
You must be signed in to change notification settings - Fork 18
/
api_exchange.py
175 lines (155 loc) · 4.54 KB
/
api_exchange.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class balance:
@staticmethod
def query(user_id):
return {
"method": "balance.query",
"params": [user_id],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def update(user_id, coin, change, timestamp, business):
return {
"method": "balance.update",
"params": [user_id, coin, business, timestamp, change, {}],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def history(user_id, coin, business, start_time, end_time, offset, limit):
return {
"method": "balance.history",
"params": [user_id, coin, business, start_time, end_time, offset, limit],
"jsonrpc": "2.0",
"id": 0,
}
class order:
@staticmethod
def put_limit(user_id, market, side, amount, price, taker_fee_rate, maker_fee_rate, source):
return {
"method": "order.put_limit",
"params": [user_id, market, side, amount, price, taker_fee_rate, maker_fee_rate, source],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def put_market(user_id, market, side, amount, taker_fee_rate, source):
return {
"method": "order.put_market",
"params": [user_id, market, side, amount, taker_fee_rate, source],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def cancel(user_id, market, order_id):
return {
"method": "order.cancel",
"params": [user_id, market, order_id],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def deals(order_id, offset, limit):
return {
"method": "order.deals",
"params": [order_id, offset, limit],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def book(market, side, offset, limit):
return {
"method": "order.book",
"params": [market, side, offset, limit],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def depth(market, limit, interval):
return {
"method": "order.depth",
"params": [market, limit, interval],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def pending(user_id, market, offset, limit):
return {
"method": "order.pending",
"params": [user_id, market, offset, limit],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def pending_detail(market, order_id):
return {
"method": "order.pending_detail",
"params": [market, order_id],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def finished(user_id, market, start_time, end_time, offset, limit, side):
return {
"method": "order.finished",
"params": [user_id, market, start_time, end_time, offset, limit, side],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def finished_detail(order_id):
return {
"method": "order.finished_detail",
"params": [order_id],
"jsonrpc": "2.0",
"id": 0,
}
class market:
@staticmethod
def last(market):
return {
"method": "market.last",
"params": [market],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def deals(market, limit, last_id):
return {
"method": "market.deals",
"params": [market, limit, last_id],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def user_deals(user_id, market, offset, limit):
return {
"method": "market.user_deals",
"params": [user_id, market, offset, limit],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def kline(market, start_time, end_time, interval):
return {
"method": "market.kline",
"params": [market, start_time, end_time, interval],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def status(market, period):
return {
"method": "market.status",
"params": [market, period],
"jsonrpc": "2.0",
"id": 0,
}
@staticmethod
def status_today(market):
return {
"method": "market.status_today",
"params": [market],
"jsonrpc": "2.0",
"id": 0,
}