|
...
|
...
|
@@ -85,13 +85,13 @@ class WsDataOrder |
|
|
|
$ordType = strtoupper($data['ordType']);
|
|
|
|
$cliOrdId = $data['clOrdId'];
|
|
|
|
$ordId = $data['ordId'];
|
|
|
|
$status = self::getStatus($data['state']);
|
|
|
|
$status = self::getOkStatus($data['state']);
|
|
|
|
if ($data['cancelSource'] != '') {
|
|
|
|
$status = 'CANCELED';
|
|
|
|
}
|
|
|
|
return new WsDataOrder($platform, $posSide, $symbol, $side, $price, $avgPx, $qty, $lot, $pnl, $ts, $uts, $ordType, $cliOrdId, $ordId, $status);
|
|
|
|
}
|
|
|
|
private static function getStatus(string $state)
|
|
|
|
private static function getOkStatus(string $state)
|
|
|
|
{
|
|
|
|
if ($state == 'live') {
|
|
|
|
return 'LIVE';
|
|
...
|
...
|
@@ -107,4 +107,48 @@ class WsDataOrder |
|
|
|
}
|
|
|
|
return 'UNKNOWN';
|
|
|
|
}
|
|
|
|
public static function TransferBinanceOrder($data, $symbolInfos, callable $toSymbolSt): WsDataOrder|null
|
|
|
|
{
|
|
|
|
$order = $data['o'];
|
|
|
|
$symbol = call_user_func($toSymbolSt, $order['s']);
|
|
|
|
/** @var SymbolInfo $symbolInfo */
|
|
|
|
$symbolInfo = $symbolInfos[$symbol] ?? null;
|
|
|
|
if ($symbolInfo == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$platform = 'binance';
|
|
|
|
$posSide = strtoupper($order['S']);
|
|
|
|
$side = strtoupper($order['ps']);
|
|
|
|
$price = (float)$order['p'];
|
|
|
|
$avgPx = (float)$order['ap'];
|
|
|
|
$lot = (float)$order['q'];
|
|
|
|
$qty = $lot;
|
|
|
|
$pnl = 0;
|
|
|
|
$ts = (int)$order['T'];
|
|
|
|
$uts = (int)$order['T'];
|
|
|
|
$ordType = strtoupper($order['o']);
|
|
|
|
$cliOrdId = $order['c'];
|
|
|
|
$ordId = $order['i'];
|
|
|
|
$status = self::getBnStatus($order['X']);
|
|
|
|
return new WsDataOrder($platform, $posSide, $symbol, $side, $price, $avgPx, $qty, $lot, $pnl, $ts, $uts, $ordType, $cliOrdId, $ordId, $status);
|
|
|
|
}
|
|
|
|
private static function getBnStatus(string $state)
|
|
|
|
{
|
|
|
|
if ($state == 'NEW') {
|
|
|
|
return 'LIVE';
|
|
|
|
}
|
|
|
|
if ($state == 'PARTIALLY_FILLED') {
|
|
|
|
return 'PARTIALLY_FILLED';
|
|
|
|
}
|
|
|
|
if ($state == 'FILLED') {
|
|
|
|
return 'FILLED';
|
|
|
|
}
|
|
|
|
if ($state == 'CANCELED') {
|
|
|
|
return 'CANCELED';
|
|
|
|
}
|
|
|
|
if ($state == 'EXPIRED' || $state == "EXPIRED_IN_MATCH") {
|
|
|
|
return 'CANCELED';
|
|
|
|
}
|
|
|
|
return 'UNKNOWN';
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|