forked from suixinio/okexAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.py
More file actions
103 lines (68 loc) · 3.06 KB
/
Client.py
File metadata and controls
103 lines (68 loc) · 3.06 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
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# encoding: utf-8
#客户端调用,用于查看API返回结果
from OkcoinSpotAPI import OKCoinSpot
from OkcoinFutureAPI import OKCoinFuture
#初始化apikey,secretkey,url
apikey = 'X'
secretkey = 'X'
okcoinRESTURL = 'www.okex.com' #请求注意:国内账号需要 修改为 www.okex.cn
#现货API
okcoinSpot = OKCoinSpot(okcoinRESTURL,apikey,secretkey)
#期货API
okcoinFuture = OKCoinFuture(okcoinRESTURL,apikey,secretkey)
#print (u' 现货行情 ')
#print (okcoinSpot.ticker('ltc_btc'))
#print (u' 现货深度 ')
#print (okcoinSpot.depth('btc_usd'))
#print (u' 现货历史交易信息 ')
#print (okcoinSpot.trades())
#print (u' 用户现货账户信息 ')
#print (okcoinSpot.userinfo())
#print (u' 现货下单 ')
#print (okcoinSpot.trade('ltc_usd','buy','0.1','0.2'))
#print (u' 现货批量下单 ')
#print (okcoinSpot.batchTrade('ltc_usd','buy','[{price:0.1,amount:0.2},{price:0.1,amount:0.2}]'))
#print (u' 现货取消订单 ')
#print (okcoinSpot.cancelOrder('ltc_usd','18243073'))
#print (u' 现货订单信息查询 ')
#print (okcoinSpot.orderinfo('ltc_usd','18243644'))
#print (u' 现货批量订单信息查询 ')
#print (okcoinSpot.ordersinfo('ltc_usd','18243800,18243801,18243644','0'))
#print (u' 现货历史订单信息查询 ')
#print (okcoinSpot.orderHistory('ltc_usd','0','1','2'))
print (u' 期货行情信息')
print (okcoinFuture.future_ticker('ltc_usd','this_week'))
#print (u' 期货市场深度信息')
#print (okcoinFuture.future_depth('btc_usd','this_week','6'))
#print (u'期货交易记录信息')
#print (okcoinFuture.future_trades('ltc_usd','this_week'))
#print (u'期货指数信息')
#print (okcoinFuture.future_index('ltc_usd'))
#print (u'美元人民币汇率')
#print (okcoinFuture.exchange_rate())
#print (u'获取预估交割价')
#print (okcoinFuture.future_estimated_price('ltc_usd'))
print(u'获取虚拟合约的K线信息')
print(okcoinFuture.future_kline('ltc_usd','this_week','1min','50'))
print(u'获取当前可用合约总持仓量')
print(okcoinFuture.future_hold_amount('ltc_usd','this_week'))
print(u'获取合约坐高买价和最低卖价格')
print(okcoinFuture.future_price_limit('ltc_usd','this_week'))
#print (u'获取全仓账户信息')
#print (okcoinFuture.future_userinfo())
#print (u'获取全仓持仓信息')
#print (okcoinFuture.future_position('ltc_usd','this_week'))
#print (u'期货下单')
#print (okcoinFuture.future_trade('ltc_usd','this_week','0.1','1','1','0','20'))
#print (u'期货批量下单')
#print (okcoinFuture.future_batchTrade('ltc_usd','this_week','[{price:0.1,amount:1,type:1,match_price:0},{price:0.1,amount:3,type:1,match_price:0}]','20'))
#print (u'期货取消订单')
#print (okcoinFuture.future_cancel('ltc_usd','this_week','47231499'))
#print (u'期货获取订单信息')
#print (okcoinFuture.future_orderinfo('ltc_usd','this_week','47231812','0','1','2'))
#print (u'期货逐仓账户信息')
#print (okcoinFuture.future_userinfo_4fix())
#print (u'期货逐仓持仓信息')
#print (okcoinFuture.future_position_4fix('ltc_usd','this_week',1))