Skip to content

Commit

Permalink
update directory path
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Mar 17, 2021
1 parent e9e4448 commit 71ee60e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Api/System.php → src/Api/Spot/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author lin <[email protected]>
* */

namespace Lin\Binance\Api;
namespace Lin\Binance\Api\Spot;

use Lin\Binance\Request;

Expand Down
3 changes: 2 additions & 1 deletion src/Api/Trade.php → src/Api/Spot/Trade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author lin <[email protected]>
* */

namespace Lin\Binance\Api;
namespace Lin\Binance\Api\Spot;

use Lin\Binance\Request;

Expand Down Expand Up @@ -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();
}
Expand Down
13 changes: 11 additions & 2 deletions src/Api/User.php → src/Api/Spot/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author lin <[email protected]>
* */

namespace Lin\Binance\Api;
namespace Lin\Binance\Api\Spot;

use Lin\Binance\Request;

Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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
*/
Expand Down
28 changes: 14 additions & 14 deletions src/Binance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
*
* */
Expand All @@ -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());
}
}
}
14 changes: 7 additions & 7 deletions tests/spot/trade.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/huobi-php.git
* */
Expand All @@ -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
Expand Down Expand Up @@ -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){
Expand All @@ -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){
Expand Down

0 comments on commit 71ee60e

Please sign in to comment.