|
@@ -85,13 +85,13 @@ class WsDataOrder |
|
@@ -85,13 +85,13 @@ class WsDataOrder |
|
85
|
$ordType = strtoupper($data['ordType']);
|
85
|
$ordType = strtoupper($data['ordType']);
|
|
86
|
$cliOrdId = $data['clOrdId'];
|
86
|
$cliOrdId = $data['clOrdId'];
|
|
87
|
$ordId = $data['ordId'];
|
87
|
$ordId = $data['ordId'];
|
|
88
|
- $status = self::getStatus($data['state']);
|
88
|
+ $status = self::getOkStatus($data['state']);
|
|
89
|
if ($data['cancelSource'] != '') {
|
89
|
if ($data['cancelSource'] != '') {
|
|
90
|
$status = 'CANCELED';
|
90
|
$status = 'CANCELED';
|
|
91
|
}
|
91
|
}
|
|
92
|
return new WsDataOrder($platform, $posSide, $symbol, $side, $price, $avgPx, $qty, $lot, $pnl, $ts, $uts, $ordType, $cliOrdId, $ordId, $status);
|
92
|
return new WsDataOrder($platform, $posSide, $symbol, $side, $price, $avgPx, $qty, $lot, $pnl, $ts, $uts, $ordType, $cliOrdId, $ordId, $status);
|
|
93
|
}
|
93
|
}
|
|
94
|
- private static function getStatus(string $state)
|
94
|
+ private static function getOkStatus(string $state)
|
|
95
|
{
|
95
|
{
|
|
96
|
if ($state == 'live') {
|
96
|
if ($state == 'live') {
|
|
97
|
return 'LIVE';
|
97
|
return 'LIVE';
|
|
@@ -107,4 +107,48 @@ class WsDataOrder |
|
@@ -107,4 +107,48 @@ class WsDataOrder |
|
107
|
}
|
107
|
}
|
|
108
|
return 'UNKNOWN';
|
108
|
return 'UNKNOWN';
|
|
109
|
}
|
109
|
}
|
|
|
|
110
|
+ public static function TransferBinanceOrder($data, $symbolInfos, callable $toSymbolSt): WsDataOrder|null
|
|
|
|
111
|
+ {
|
|
|
|
112
|
+ $order = $data['o'];
|
|
|
|
113
|
+ $symbol = call_user_func($toSymbolSt, $order['s']);
|
|
|
|
114
|
+ /** @var SymbolInfo $symbolInfo */
|
|
|
|
115
|
+ $symbolInfo = $symbolInfos[$symbol] ?? null;
|
|
|
|
116
|
+ if ($symbolInfo == null) {
|
|
|
|
117
|
+ return null;
|
|
|
|
118
|
+ }
|
|
|
|
119
|
+ $platform = 'binance';
|
|
|
|
120
|
+ $posSide = strtoupper($order['S']);
|
|
|
|
121
|
+ $side = strtoupper($order['ps']);
|
|
|
|
122
|
+ $price = (float)$order['p'];
|
|
|
|
123
|
+ $avgPx = (float)$order['ap'];
|
|
|
|
124
|
+ $lot = (float)$order['q'];
|
|
|
|
125
|
+ $qty = $lot;
|
|
|
|
126
|
+ $pnl = 0;
|
|
|
|
127
|
+ $ts = (int)$order['T'];
|
|
|
|
128
|
+ $uts = (int)$order['T'];
|
|
|
|
129
|
+ $ordType = strtoupper($order['o']);
|
|
|
|
130
|
+ $cliOrdId = $order['c'];
|
|
|
|
131
|
+ $ordId = $order['i'];
|
|
|
|
132
|
+ $status = self::getBnStatus($order['X']);
|
|
|
|
133
|
+ return new WsDataOrder($platform, $posSide, $symbol, $side, $price, $avgPx, $qty, $lot, $pnl, $ts, $uts, $ordType, $cliOrdId, $ordId, $status);
|
|
|
|
134
|
+ }
|
|
|
|
135
|
+ private static function getBnStatus(string $state)
|
|
|
|
136
|
+ {
|
|
|
|
137
|
+ if ($state == 'NEW') {
|
|
|
|
138
|
+ return 'LIVE';
|
|
|
|
139
|
+ }
|
|
|
|
140
|
+ if ($state == 'PARTIALLY_FILLED') {
|
|
|
|
141
|
+ return 'PARTIALLY_FILLED';
|
|
|
|
142
|
+ }
|
|
|
|
143
|
+ if ($state == 'FILLED') {
|
|
|
|
144
|
+ return 'FILLED';
|
|
|
|
145
|
+ }
|
|
|
|
146
|
+ if ($state == 'CANCELED') {
|
|
|
|
147
|
+ return 'CANCELED';
|
|
|
|
148
|
+ }
|
|
|
|
149
|
+ if ($state == 'EXPIRED' || $state == "EXPIRED_IN_MATCH") {
|
|
|
|
150
|
+ return 'CANCELED';
|
|
|
|
151
|
+ }
|
|
|
|
152
|
+ return 'UNKNOWN';
|
|
|
|
153
|
+ }
|
|
110
|
} |
154
|
} |