-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
180 lines (140 loc) · 5.4 KB
/
example.php
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
176
177
178
<?php
/*
*
##
## OKEX PHP SDK PACKAGE
##
// Copyright (c) 2019 Executium LTD (support@executium.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and/or associated documentation files (the
// "Materials"), to deal in the Materials without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Materials, and to
// permit persons to whom the Materials are furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Materials.
//
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*
*/
##/
require 'okex.class.php';
##/
define("OKEX_KEY","YOUR-KEY");
define("OKEX_SECRET","YOUR-SECRET");
define("OKEX_PASSPHRASE","YOUR-PASSPHRASE");
##/
$okexAPI = new okexAPI(OKEX_KEY,OKEX_SECRET,OKEX_PASSPHRASE);
##/ A list without all of the comments to begin with.
##/ Last Traded, Default 20
$output = $okexAPI->trades('BTC-USDT',20);
print_r($output);
##/ Last traded price, 24hr volume, for all trading volumes
//$output = $okexAPI->ticker('BTC-USDT');
//print_r($output);
##/ Snapshot of market data from OKEX
//$output = $okexAPI->token_pair_details();
//print_r($output);
##/ OKEX ORDERBOOK
//$output = $okexAPI->order_book('BTC-USDT',5,0.2);
//print_r($output);
##/ OKEX BTC DEPOSIT ADDRESS
//$output = $okexAPI->deposit_address_btc();
//print_r($output);
##/ BUY LIMIT on OKEX
//$output = $okexAPI->order_limit('buy','BTC-USDT',9001,0.001,10);
//print_r($output);
##/ BUY MARKET on OKEX
//$output = $okexAPI->order_market('buy','BTC-USDT',0,11);
//print_r($output);
##/ SELL MARKET on OKEX
//$output = $okexAPI->order_market('sell','BTC-USDT',0,11);
//print_r($output);
##/ SELL LIMIT on OKEX
//$output = $okexAPI->order_limit('sell','BTC-USDT',11900,0.001,10);
//print_r($output);
##/ ORDER INFORMATION on OKEX
//$output = $okexAPI->order_information('3390549023331328','BTC-USDT');
//print_r($output);
##/ CANCEL ORDER on OKEX
//$output = $okexAPI->order_cancel(3394063533169664,'BTC-USDT');
//print_r($output);
/*
QUERY ANYTHING - Access any action
https://www.okex.com/docs/en
*/
##/ Query Anything - Consult the documentation and take the path given
##/ Always note if there is parameters to be added or not, if you add parameters when there is no requirement for any your query will fail.
//$output = $okexAPI->query('/api/account/v3/deposit/address?currency=btc',array());
//print_r($output);
/*
We have included some easy functions you may require that are cleaner
This is by no means comprehensive as it is much easier to consult the documentation provided by OKEX and make use of the query() function
*/
##/ We have included some easy functions you may require that are cleaner
//$output = $okexAPI->deposit_address_btc();
//print_r($output);
##/ When you place an order, OKEX will just let you know if the order failed or not, if you want the true status of how it sits with regards to filling, avg price etc you will need to query the order.
##/ As of 23rd August 2019, the minimum order size is 0.001 for BTCUSDT
##/ The notional issue, you will also need to provide the equivilent value for a side
//$output = $okexAPI->order_market('buy','BTC-USDT',0,11);
//print_r($output);
//$output = $okexAPI->order_market('sell','BTC-USDT',0.001,0);
//print_r($output);
/*
##/ IF you get the following error
Array
(
[client_oid] =>
[error_code] => 30024
[error_message] => Parameter value filling error
[order_id] => -1
[result] =>
)
##/ You need to set the notional to the BTC equivilant, for example, if the market price of BTC-USDT is 10,000 then 0.001 BTC is equal to 10 USD, 10,000*0.001=10 this should be set in the notional
*/
##/ BUY LIMIT on OKEX
//$output = $okexAPI->order_limit('buy','BTC-USDT',9001,0.001,10);
//print_r($output);
##/ SELL LIMIT on OKEX
//$output = $okexAPI->order_limit('sell','BTC-USDT',11900,0.001,10);
//print_r($output);
##/ It is important to store your orderID and Instrument used when querying your order
//$output = $okexAPI->order_information('1234567890','BTC-USDT');
//print_r($output);
/*
##/ Example of order information output
Array
(
[client_oid] =>
[created_at] => 2019-08-22T11:01:12.366Z
[filled_notional] => 10.0146
[filled_size] => 0.001
[funds] =>
[instrument_id] => BTC-USDT
[notional] =>
[order_id] => 1234567890
[order_type] => 0
[price] => 10014.6
[price_avg] => 10014.6
[product_id] => BTC-USDT
[side] => buy
[size] => 0.001
[state] => 2
[status] => filled
[timestamp] => 2019-08-22T11:01:12.366Z
[type] => limit
)
*/
##/ CANCEL ORDER on OKEX
//$output = $okexAPI->order_cancel(1234567890,'BTC-USDT');
//print_r($output);