Skip to content

Commit

Permalink
update urlencode() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Oct 26, 2020
1 parent 120bd82 commit b1510f6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ protected function sort($param)
$u = [];
$sort_rank = [];
foreach ($param as $k => $v) {
if(is_array($v)) $v=json_encode($v);
$u[] = $k . "=" . urlencode($v);
$sort_rank[] = ord($k);
}
Expand Down
75 changes: 63 additions & 12 deletions tests/future/contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

/**
* @author lin <[email protected]>
*
*
* Fill in your key and secret and pass can be directly run
*
*
* Most of them are unfinished and need your help
* https://github.com/zhouaini528/okex-php.git
* */
Expand All @@ -21,9 +21,9 @@
$huobi->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,

//If you are developing locally and need an agent, you can set this
'proxy'=>true,
//'proxy'=>true,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
Expand All @@ -37,16 +37,16 @@
//Place an Order
try {
$result=$huobi->contract()->postOrder([
'symbol'=>'BTC',//string false "BTC","ETH"...
'symbol'=>'EOS',//string false "BTC","ETH"...
'contract_type'=>'quarter',// string false Contract Type ("this_week": "next_week": "quarter":)
'contract_code'=>'BTC190927',// string false BTC180914
'price'=>'2000',// decimal true Price
'contract_code'=>'EOS201225',// string false BTC180914
'price'=>'1',// decimal true Price
'volume'=>'1',// long true Numbers of orders (amount)
'direction'=>'buy',// string true Transaction direction
'offset'=>'open',// string true "open", "close"
'order_price_type'=>'limit',//"limit", "opponent"
'lever_rate'=>20,//int true Leverage rate [if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate

//'client_order_id'=>'',//long false Clients fill and maintain themselves, and this time must be greater than last time
]);
print_r($result);
Expand All @@ -59,7 +59,7 @@
$result=$huobi->contract()->postOrderInfo([
'order_id'=>$result['data']['order_id'],//You can also 'xxxx,xxxx,xxxx' multiple ID
//'client_order_id'=>'xxxx',
'symbol'=>'BTC'
'symbol'=>'EOS'
]);
print_r($result);
}catch (\Exception $e){
Expand All @@ -71,13 +71,13 @@
$result=$huobi->contract()->postCancel([
'order_id'=>$result['data'][0]['order_id'],//You can also 'xxxx,xxxx,xxxx' multiple ID
//'client_order_id'=>'xxxx',
'symbol'=>'BTC'
'symbol'=>'EOS'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
die;

//User`s position Information
try {
$result=$huobi->contract()->postPositionInfo();
Expand All @@ -100,4 +100,55 @@
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
}


/*try {
$result=$huobi->contract()->postOpenOrders([
'symbol'=>'EOS'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$huobi->contract()->postCancelAll([
'symbol'=>'EOS'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$huobi->contract()->postBatchOrder([
'orders_data'=>[
[
'symbol'=>'EOS',
'contract_type'=>'quarter',
'contract_code'=>'EOS201225',
'price'=>'1',
'volume'=>'1',
'direction'=>'buy',
'offset'=>'open',
'order_price_type'=>'limit',
'lever_rate'=>20,
],
[
'symbol'=>'EOS',
'contract_type'=>'quarter',
'contract_code'=>'EOS201225',
'price'=>'1.1',
'volume'=>'1',
'direction'=>'buy',
'offset'=>'open',
'order_price_type'=>'limit',
'lever_rate'=>20,
],
],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}*/

0 comments on commit b1510f6

Please sign in to comment.