@@ -244,11 +244,24 @@ protected override async Task<ExchangeOrderResult> OnGetOrderDetailsAsync(string
244
244
payload [ "id" ] = orderId ;
245
245
JObject result = await MakeJsonRequestAsync < JObject > ( url , null , payload , "POST" ) ;
246
246
247
- // status can be 'In Queue', 'Open' or 'Finished'
248
- JArray transactions = result [ "transactions" ] as JArray ;
247
+ var transactions = result [ "transactions" ] as JArray ;
248
+ var anyTransaction = transactions . Any ( ) ;
249
+
250
+ // status can be 'Canceled', 'Open' or 'Finished'
251
+ var statusCode = result . Value < string > ( "status" ) ;
252
+ var status = GetOrderResultFromStatus ( statusCode , anyTransaction ) ;
253
+
249
254
// empty transaction array means that order is InQueue or Open and AmountFilled == 0
250
255
// return empty order in this case. no any additional info available at this point
251
- if ( ! transactions . Any ( ) ) { return new ExchangeOrderResult ( ) { OrderId = orderId } ; }
256
+ if ( ! anyTransaction )
257
+ {
258
+ return new ExchangeOrderResult
259
+ {
260
+ OrderId = orderId ,
261
+ Result = status ,
262
+ ResultCode = statusCode
263
+ } ;
264
+ }
252
265
JObject first = transactions . First ( ) as JObject ;
253
266
List < string > excludeStrings = new List < string > ( ) { "tid" , "price" , "fee" , "datetime" , "type" , "btc" , "usd" , "eur" } ;
254
267
@@ -291,7 +304,9 @@ protected override async Task<ExchangeOrderResult> OnGetOrderDetailsAsync(string
291
304
MarketSymbol = _symbol ,
292
305
AveragePrice = spentQuoteCurrency / amountFilled ,
293
306
Price = price ,
294
- } ;
307
+ Result = status ,
308
+ ResultCode = statusCode
309
+ } ;
295
310
}
296
311
297
312
protected override async Task < IEnumerable < ExchangeOrderResult > > OnGetOpenOrderDetailsAsync ( string marketSymbol = null )
@@ -322,7 +337,20 @@ protected override async Task<IEnumerable<ExchangeOrderResult>> OnGetOpenOrderDe
322
337
return orders ;
323
338
}
324
339
325
- public class BitstampTransaction
340
+ private ExchangeAPIOrderResult GetOrderResultFromStatus ( string status , bool anyTransactions )
341
+ {
342
+ switch ( status ? . ToLower ( ) )
343
+ {
344
+ case "finished" : return ExchangeAPIOrderResult . Filled ;
345
+ case "open" : return anyTransactions
346
+ ? ExchangeAPIOrderResult . FilledPartially
347
+ : ExchangeAPIOrderResult . Pending ;
348
+ case "canceled" : return ExchangeAPIOrderResult . Canceled ;
349
+ default : return ExchangeAPIOrderResult . Unknown ;
350
+ }
351
+ }
352
+
353
+ public class BitstampTransaction
326
354
{
327
355
public BitstampTransaction ( string id , DateTime dateTime , int type , string symbol , decimal fees , string orderId , decimal quantity , decimal price , bool isBuy )
328
356
{
0 commit comments