Skip to content

Commit

Permalink
add lightning_close_position
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Oct 28, 2019
1 parent e2aa062 commit bd2ccd3
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Api/Futures/Lightning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @author lin <[email protected]>
* */

namespace Lin\Huobi\Api\Futures;



use Lin\Huobi\Request;

class Lightning extends Request
{
/**
* POST api/v1/lightning_close_position
* */
public function postClosePosition(array $data){
$this->type='POST';
$this->path='/api/v1/lightning_close_position';

$this->data=$data;
return $this->exec();
}
}
7 changes: 7 additions & 0 deletions src/HuobiFuture.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Lin\Huobi\Api\Futures\Contract;
use Lin\Huobi\Api\Futures\Market;
use Lin\Huobi\Api\Futures\Lightning;

class HuobiFuture
{
Expand Down Expand Up @@ -57,4 +58,10 @@ public function market(){
return new Market($this->init());
}

/**
*
* */
public function lightning(){
return new Lightning($this->init());
}
}
58 changes: 58 additions & 0 deletions tests/future/lightning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php


/**
* @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
* */
use Lin\Huobi\HuobiFuture;

require __DIR__ .'../../../vendor/autoload.php';

include 'key_secret.php';

$huobi=new HuobiFuture($key,$secret);

//You can set special needs
$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,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
], */
//Close the certificate
//'verify'=>false,
]);

//The Last Trade of a Contract
try {
$result=$huobi->lightning()->postClosePosition([
'symbol'=>'ETC',//string false "BTC","ETH"...
'contract_type'=>'quarter',// string false Contract Type ("this_week": "next_week": "quarter":)
'contract_code'=>'ETC191227',// string false BTC180914
'volume'=>1,
'direction'=>'sell',
//'client_order_id'=>rand(100000,999999)
/*
symbol false string 品种代码 "BTC","ETH"...
contract_type false string 合约类型 “this_week”:当周,“next_week”:次周,“quarter”:季度
contract_code false string 合约代码 BTC190903
volume true int 委托数量(张)
direction true string “buy”:买,“sell”:卖
client_order_id false int (API)客户自己填写和维护,必须保持唯一
*/
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}

0 comments on commit bd2ccd3

Please sign in to comment.