Skip to content

Commit

Permalink
binance map
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Jun 8, 2023
1 parent 37945dd commit db35f56
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/Map/RequestTraderMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ function buy(array $data){

//市价单与限价单的参数映射
if(isset($data['_number']) && isset($data['_price'])){
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
$map['timeInForce']=$data['timeInForce'] ?? 'GTC';
$map['price']=$data['_price'] ?? ($data['price'] ?? '');
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
$map['price']=$data['_price'] ?? ($data['quoteOrderQty'] ?? '');
$map['type']='LIMIT';
}else{
//quantity 的市价单
Expand All @@ -225,9 +225,16 @@ function buy(array $data){
//下买单的时候, 订单会尽可能的买进价值100USDT的BTC.下卖单的时候, 订单会尽可能的卖出价值100USDT的BTC.

//可以理解为以BTCUSDT quantity处理BTC(交易币) quoteOrderQty处理USDT(计价币)
//TODO
switch ($this->checkType()){
case 'spot':{
$map['quoteOrderQty']=$data['_number'] ?? ($data['quoteOrderQty'] ?? '');
if(isset($data['_price'])){
$map['quoteOrderQty']=$data['_price'] ?? ($data['quoteOrderQty'] ?? '');
}

if(isset($data['_number'])){
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
}
break;
}
default:{
Expand Down Expand Up @@ -488,17 +495,33 @@ function sell(array $data){
case 'binance':{
$map['symbol']=$data['_symbol'] ?? $data['symbol'];
$map['newClientOrderId']=$data['_client_id'] ?? ($data['newClientOrderId'] ?? '');
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
$map['side']='SELL';

if(empty($map['newClientOrderId'])) unset($map['newClientOrderId']);

//市价单与限价单的参数映射
if(isset($data['_number']) && isset($data['_price'])){
$map['timeInForce']=$data['timeInForce'] ?? 'GTC';
$map['price']=$data['_price'] ?? ($data['price'] ?? '');
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
$map['price']=$data['_price'] ?? ($data['quoteOrderQty'] ?? '');
$map['type']='LIMIT';
}else{
switch ($this->checkType()){
case 'spot':{
if(isset($data['_price'])){
$map['quoteOrderQty']=$data['_price'] ?? ($data['quoteOrderQty'] ?? '');
}

if(isset($data['_number'])){
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
}
$map['newOrderRespType']=$data['newOrderRespType'] ?? 'ACK';
break;
}
default:{
$map['quantity']=$data['_number'] ?? ($data['quantity'] ?? '');
}
}
$map['type']='MARKET';
}

Expand Down

0 comments on commit db35f56

Please sign in to comment.