|
@@ -102,4 +102,40 @@ class Order |
|
@@ -102,4 +102,40 @@ class Order |
|
102
|
}
|
102
|
}
|
|
103
|
return $order;
|
103
|
return $order;
|
|
104
|
}
|
104
|
}
|
|
|
|
105
|
+ function toBybitOrder(array $symbolInfos, callable $toSymbolOri)
|
|
|
|
106
|
+ {
|
|
|
|
107
|
+ $symbol = call_user_func($toSymbolOri, $this->symbol);
|
|
|
|
108
|
+ /** @var SymbolInfo $symbolInfo */
|
|
|
|
109
|
+ $symbolInfo = $symbolInfos[$this->symbol];
|
|
|
|
110
|
+ $order = [
|
|
|
|
111
|
+ 'symbol' => $symbol,
|
|
|
|
112
|
+ 'qty' => round($this->qty, $symbolInfo->qtyPrec),
|
|
|
|
113
|
+ 'price' => round($this->price, $symbolInfo->pricePrec),
|
|
|
|
114
|
+ 'orderLinkId' => $this->cliOrdId,
|
|
|
|
115
|
+ ];
|
|
|
|
116
|
+ if ($this->ordType == "MARKET") {
|
|
|
|
117
|
+ $order['orderType'] = "Market";
|
|
|
|
118
|
+ unset($order['price']);
|
|
|
|
119
|
+ }
|
|
|
|
120
|
+ if ($this->ordType == "LIMIT") {
|
|
|
|
121
|
+ $order['timeInForce'] = "GTC";
|
|
|
|
122
|
+ }
|
|
|
|
123
|
+ if ($this->ordType == "IOC") {
|
|
|
|
124
|
+ $order['timeInForce'] = "IOC";
|
|
|
|
125
|
+ $order['orderType'] = "Limit";
|
|
|
|
126
|
+ }
|
|
|
|
127
|
+ if ($this->side == "BUY") {
|
|
|
|
128
|
+ $order['side'] = "Buy";
|
|
|
|
129
|
+ } else {
|
|
|
|
130
|
+ $order['side'] = "Sell";
|
|
|
|
131
|
+ }
|
|
|
|
132
|
+ if ($this->posSide == "LONG") {
|
|
|
|
133
|
+ $order['positionIdx'] = "1";
|
|
|
|
134
|
+ } else if ($this->posSide == "SHORT") {
|
|
|
|
135
|
+ $order['positionIdx'] = "2";
|
|
|
|
136
|
+ } else {
|
|
|
|
137
|
+ $order['positionIdx'] = "0";
|
|
|
|
138
|
+ }
|
|
|
|
139
|
+ return $order;
|
|
|
|
140
|
+ }
|
|
105
|
} |
141
|
} |