作者 karlet

feat:增加下单返佣码

... ... @@ -34,6 +34,7 @@ use trader\struct\WsDataAccount;
use trader\struct\Pos;
use \Exception;
use function jytools\timeFormat;
use function jytools\getMicrotime;
class CmBroker
{
... ... @@ -41,6 +42,8 @@ class CmBroker
const PLAT_BINANCE = 'binance';
const PLAT_BYBIT = 'bybit';
const PLAT_BITGET = 'bitget';
const BN_FEE_KEY = "x-tdk3UjFd";
const OK_FEE_KEY = "059de09b75e8BCDE";
/**
* @var string 当前使用的交易平台
* @see PLAT_OKX
... ... @@ -116,6 +119,7 @@ class CmBroker
return $this->getSymbolSt($symbol);
});
if ($wsDataTrade != null) {
$wsDataTrade->cliOrdId = str_replace(self::BN_FEE_KEY, '', $wsDataTrade->cliOrdId);
$wsData = new WsData($this->plat, 'trade', $trade = $wsDataTrade);
$onData($wsData);
}
... ... @@ -124,6 +128,7 @@ class CmBroker
return $this->getSymbolSt($symbol);
});
if ($wsDataOrder != null) {
$wsDataOrder->cliOrdId = str_replace(self::BN_FEE_KEY, '', $wsDataOrder->cliOrdId);
$wsData = new WsData($this->plat, 'order', $trade = null, $pos = null, $order = $wsDataOrder);
$onData($wsData);
}
... ... @@ -287,6 +292,9 @@ class CmBroker
$orderOri = $order->toOkxOrder($this->symbolInfos, function ($symbol) {
return $this->getSymbolOri($symbol);
});
if (!isset($orderOri['tag'])) {
$orderOri['tag'] = self::OK_FEE_KEY;
}
$this->msg("下单", $orderOri);
if ($orderOri['sz'] == 0) {
$msg = "当前下单数量为{$order->qty},最小下单数量为{$symbolInfo->minQty},不下单";
... ... @@ -301,6 +309,11 @@ class CmBroker
$orderOri = $order->toBinanceOrder($this->symbolInfos, function ($symbol) {
return $this->getSymbolOri($symbol, $this->plat);
});
if (isset($orderOri['newClientOrderId'])) {
$orderOri['newClientOrderId'] = self::BN_FEE_KEY . $orderOri['newClientOrderId'];
} else {
$orderOri['newClientOrderId'] = self::BN_FEE_KEY . getMicrotime();
}
$this->msg("下单", $orderOri);
if ($orderOri['quantity'] == 0) {
$msg = "当前下单数量为{$order->qty},最小下单数量为{$symbolInfo->minQty},不下单";
... ... @@ -309,6 +322,9 @@ class CmBroker
}
$res = $this->exBroker->placeOrder($orderOri);
$this->msg("下单结果", $res);
if ($res && isset($res['clientOrderId'])) {
$res['clientOrderId'] = str_replace(self::BN_FEE_KEY, '', $res['clientOrderId']);
}
return $res;
}
}
... ...