-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuobi-futures.php
49 lines (38 loc) · 1.3 KB
/
huobi-futures.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
<?php
$root = dirname(dirname(dirname(__FILE__)));
include $root . '/ccxt.php';
date_default_timezone_set('UTC');
$exchange = new \ccxt\huobipro(array(
'apiKey' => 'YOUR_API_KEY', // ←------------ replace with your keys
'secret' => 'YOUR_SECRET_KEY',
'options' => array(
'defaultType' => 'future',
)
// 'verbose' => true, // uncomment if debug output is needed
));
try {
$markets = $exchange->load_markets ();
// creating and canceling a linear swap (limit) order
$symbol = 'ADA/USD:ADA-220121'; // the last segment is the date of expiration (can be next week, next quarter, ...) adjust it accordingly
$order_type = 'limit';
$side = 'buy';
$offset = 'open';
$leverage = 1;
$amount = 1;
$price = 1;
$params = array (
'offset' => $offset,
'lever_rate' => $leverage,
);
$order = $exchange->create_order ($symbol, $order_type, $side, $amount, $price, $params);
var_dump ($order);
$cancel = $exchange->cancel_order ($order['id'], $symbol);
var_dump ($cancel);
} catch (\ccxt\NetworkError $e) {
echo '[Network Error] ' . $e->getMessage() . "\n";
} catch (\ccxt\ExchangeError $e) {
echo '[Exchange Error] ' . $e->getMessage() . "\n";
} catch (Exception $e) {
echo '[Error] ' . $e->getMessage() . "\n";
}
?>