File tree Expand file tree Collapse file tree 1 file changed +34
-2
lines changed
src/ExchangeSharp/API/Exchanges/GateIo Expand file tree Collapse file tree 1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -343,11 +343,43 @@ ExchangeOrderRequest order
343343 var payload = await GetNoncePayloadAsync ( ) ;
344344 AddOrderToPayload ( order , payload ) ;
345345
346- JToken responseToken = await MakeJsonRequestAsync < JToken > (
346+ JToken responseToken ;
347+ try
348+ {
349+ responseToken = await MakeJsonRequestAsync < JToken > (
347350 "/spot/orders" ,
348351 payload : payload ,
349352 requestMethod : "POST"
350- ) ;
353+ ) ;
354+ }
355+ catch ( Exception e )
356+ {
357+ // Gate.io returns HTTP status code 400 when an order can't be filled.
358+ if ( string . Equals (
359+ e . Message ,
360+ "{\" label\" :\" FOK_NOT_FILL\" ,\" message\" :\" Order cannot be filled completely\" }" ,
361+ StringComparison . OrdinalIgnoreCase ) )
362+ {
363+ var result = new ExchangeOrderResult
364+ {
365+ Amount = order . Amount ,
366+ AmountFilled = 0 ,
367+ Price = order . Price ,
368+ AveragePrice = 0 ,
369+ Message = string . Empty ,
370+ OrderId = string . Empty ,
371+ OrderDate = DateTime . UtcNow ,
372+ MarketSymbol = order . MarketSymbol ,
373+ IsBuy = order . IsBuy ,
374+ ClientOrderId = order . ClientOrderId ,
375+ Result = ExchangeAPIOrderResult . Canceled
376+ } ;
377+
378+ return result ;
379+ }
380+
381+ throw ;
382+ }
351383
352384 return ParseOrder ( responseToken ) ;
353385 }
You can’t perform that action at this time.
0 commit comments