From 71ee60e69f862265d646dd3caadcd0b7c90c33bd Mon Sep 17 00:00:00 2001 From: lin <465382251@qq.com> Date: Wed, 17 Mar 2021 15:09:49 +0800 Subject: [PATCH] update directory path --- src/Api/{ => Spot}/System.php | 2 +- src/Api/{ => Spot}/Trade.php | 3 ++- src/Api/{ => Spot}/User.php | 13 +++++++++++-- src/Binance.php | 28 ++++++++++++++-------------- tests/spot/trade.php | 14 +++++++------- 5 files changed, 35 insertions(+), 25 deletions(-) rename src/Api/{ => Spot}/System.php (99%) rename src/Api/{ => Spot}/Trade.php (97%) rename src/Api/{ => Spot}/User.php (93%) diff --git a/src/Api/System.php b/src/Api/Spot/System.php similarity index 99% rename from src/Api/System.php rename to src/Api/Spot/System.php index 829d2f4..92fb096 100644 --- a/src/Api/System.php +++ b/src/Api/Spot/System.php @@ -3,7 +3,7 @@ * @author lin <465382251@qq.com> * */ -namespace Lin\Binance\Api; +namespace Lin\Binance\Api\Spot; use Lin\Binance\Request; diff --git a/src/Api/Trade.php b/src/Api/Spot/Trade.php similarity index 97% rename from src/Api/Trade.php rename to src/Api/Spot/Trade.php index 11fe54d..e142202 100644 --- a/src/Api/Trade.php +++ b/src/Api/Spot/Trade.php @@ -3,7 +3,7 @@ * @author lin <465382251@qq.com> * */ -namespace Lin\Binance\Api; +namespace Lin\Binance\Api\Spot; use Lin\Binance\Request; @@ -67,6 +67,7 @@ public function postOrder(array $data){ public function postOrderTest(array $data){ $this->type='POST'; $this->path='/api/v3/order/test'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } diff --git a/src/Api/User.php b/src/Api/Spot/User.php similarity index 93% rename from src/Api/User.php rename to src/Api/Spot/User.php index c0bb862..a319888 100644 --- a/src/Api/User.php +++ b/src/Api/Spot/User.php @@ -3,7 +3,7 @@ * @author lin <465382251@qq.com> * */ -namespace Lin\Binance\Api; +namespace Lin\Binance\Api\Spot; use Lin\Binance\Request; @@ -19,6 +19,7 @@ class User extends Request public function getOpenOrders(array $data=[]){ $this->type='GET'; $this->path='/api/v3/openOrders'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -94,6 +95,7 @@ public function getAccount(array $data=[]){ public function getMyTrades(array $data=[]){ $this->type='GET'; $this->path='/api/v3/myTrades'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -105,6 +107,7 @@ public function getMyTrades(array $data=[]){ public function getDepositHistory(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/depositHistory.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -116,6 +119,7 @@ public function getDepositHistory(array $data=[]){ public function getWithdrawHistory(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/withdrawHistory.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -127,6 +131,7 @@ public function getWithdrawHistory(array $data=[]){ public function getDepositAddress(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/depositAddress.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -140,6 +145,7 @@ public function getAccountStatus(array $data=[]){ $this->signature=false; $this->type='GET'; $this->path='/wapi/v3/accountStatus.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -151,6 +157,7 @@ public function getAccountStatus(array $data=[]){ public function getAssetDribbletLog(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/userAssetDribbletLog.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -162,6 +169,7 @@ public function getAssetDribbletLog(array $data=[]){ public function getTradeFee(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/tradeFee.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } @@ -173,13 +181,14 @@ public function getTradeFee(array $data=[]){ public function getAssetDetail(array $data=[]){ $this->type='GET'; $this->path='/wapi/v3/assetDetail.html'; + $data['timestamp']=time().'000'; $this->data=$data; return $this->exec(); } - + //Websocket Account Pull /** * POST /api/v3/userDataStream */ diff --git a/src/Binance.php b/src/Binance.php index ea09094..e81e9c1 100644 --- a/src/Binance.php +++ b/src/Binance.php @@ -6,24 +6,24 @@ namespace Lin\Binance; -use Lin\Binance\Api\User; -use Lin\Binance\Api\System; -use Lin\Binance\Api\Trade; +use Lin\Binance\Api\Spot\User; +use Lin\Binance\Api\Spot\System; +use Lin\Binance\Api\Spot\Trade; class Binance { protected $key; protected $secret; protected $host; - + protected $options=[]; - + function __construct(string $key='',string $secret='',string $host='https://api.binance.com'){ $this->key=$key; $this->secret=$secret; $this->host=$host; } - + /** * * */ @@ -32,36 +32,36 @@ private function init(){ 'key'=>$this->key, 'secret'=>$this->secret, 'host'=>$this->host, - + 'options'=>$this->options, ]; } - + /** - * + * * */ function setOptions(array $options=[]){ $this->options=$options; } - + /** - * + * * */ public function user(){ return new User($this->init()); } - + /** * * */ public function system(){ return new System($this->init()); } - + /** * * */ public function trade(){ return new Trade($this->init()); } -} \ No newline at end of file +} diff --git a/tests/spot/trade.php b/tests/spot/trade.php index 489770b..226ce04 100644 --- a/tests/spot/trade.php +++ b/tests/spot/trade.php @@ -3,9 +3,9 @@ /** * @author lin <465382251@qq.com> - * + * * 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/huobi-php.git * */ @@ -20,7 +20,7 @@ $binance->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 @@ -52,8 +52,8 @@ try { $result=$binance->user()->getOrder([ 'symbol'=>'LTCUSDT', - 'orderId'=>$result['orderId'], - 'origClientOrderId'=>$result['clientOrderId'], + 'orderId'=>'22222', + 'origClientOrderId'=>'22222', ]); print_r($result); }catch (\Exception $e){ @@ -64,8 +64,8 @@ try { $result=$binance->trade()->deleteOrder([ 'symbol'=>'LTCUSDT', - 'orderId'=>$result['orderId'], - 'origClientOrderId'=>$result['clientOrderId'], + 'orderId'=>'111111', + 'origClientOrderId'=>'1111111', ]); print_r($result); }catch (\Exception $e){