作者 karlet

feat:优化开平仓参数

@@ -146,8 +146,14 @@ class Order @@ -146,8 +146,14 @@ class Order
146 /** @var SymbolInfo $symbolInfo */ 146 /** @var SymbolInfo $symbolInfo */
147 $symbolInfo = $symbolInfos[$this->symbol]; 147 $symbolInfo = $symbolInfos[$this->symbol];
148 $tradeSide = "open"; 148 $tradeSide = "open";
149 - if (($this->posSide == "SHORT" && $this->side == "BUY") || ($this->posSide == "LONG" && $this->side == "SELL")) { 149 + $side = $this->side;
  150 + if ($this->posSide == "SHORT" && $this->side == "BUY") {
150 $tradeSide = "close"; 151 $tradeSide = "close";
  152 + $side = "SELL";
  153 + }
  154 + if ($this->posSide == "LONG" && $this->side == "SELL") {
  155 + $tradeSide = "close";
  156 + $side = "BUY";
151 } 157 }
152 $timeInForce = "GTC"; 158 $timeInForce = "GTC";
153 if ($this->ordType == "IOC") { 159 if ($this->ordType == "IOC") {
@@ -163,7 +169,7 @@ class Order @@ -163,7 +169,7 @@ class Order
163 'marginMode' => 'crossed', 169 'marginMode' => 'crossed',
164 'marginCoin' => 'USDT', 170 'marginCoin' => 'USDT',
165 'symbol' => $symbol, 171 'symbol' => $symbol,
166 - 'side' => strtolower($this->side), 172 + 'side' => strtolower($side),
167 'orderType' => strtolower($this->ordType), 173 'orderType' => strtolower($this->ordType),
168 'price' => (string)round($this->price, $symbolInfo->pricePrec), 174 'price' => (string)round($this->price, $symbolInfo->pricePrec),
169 'size' => (string)round($this->qty, $symbolInfo->qtyPrec), 175 'size' => (string)round($this->qty, $symbolInfo->qtyPrec),