diff --git a/src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs b/src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs index 2bd32e28..3f87cfd2 100644 --- a/src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/BL3P/ExchangeBL3PAPI.cs @@ -339,7 +339,8 @@ protected override async Task OnGetOrderDetailsAsync(string AmountFilled = result.TotalAmount.Value, AveragePrice = result.AverageCost?.Value, FeesCurrency = result.TotalFee.Currency, - CompletedDate = result.DateClosed ?? DateTime.MinValue, + CompletedDate = result.DateClosed, + TradeDate = result.Date, IsBuy = result.Type == BL3POrderType.Bid, MarketSymbol = marketSymbol, OrderDate = result.Date, diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs index ccb7ab8f..bbcc99b3 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs @@ -930,7 +930,9 @@ private static ExchangeOrderResult ParseTrade(JToken token, string symbol) Price = token["price"].ConvertInvariant(), AveragePrice = token["price"].ConvertInvariant(), IsBuy = token["isBuyer"].ConvertInvariant() == true, - OrderDate = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(token["time"].ConvertInvariant()), + // OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate is not nullable + CompletedDate = null, // order not necessarily fullly filled at this point + TradeDate = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(token["time"].ConvertInvariant()), OrderId = token["orderId"].ToStringInvariant(), TradeId = token["id"].ToStringInvariant(), Fees = token["commission"].ConvertInvariant(), diff --git a/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/UserDataStream.cs b/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/UserDataStream.cs index 58a725ca..c23c19a4 100644 --- a/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/UserDataStream.cs +++ b/src/ExchangeSharp/API/Exchanges/BinanceGroup/Models/UserDataStream.cs @@ -54,7 +54,7 @@ internal class ExecutionReport [JsonProperty("N")] public string CommissionAsset { get; set; } [JsonProperty("T")] - public string TransactionTime { get; set; } + public long TransactionTime { get; set; } [JsonProperty("t")] public string TradeId { get; set; } [JsonProperty("w")] @@ -92,7 +92,8 @@ public ExchangeOrderResult ExchangeOrderResult Price = OrderPrice, AveragePrice = CumulativeQuoteAssetTransactedQuantity / CumulativeFilledQuantity, // Average price can be found by doing Z divided by z. OrderDate = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(OrderCreationTime), - CompletedDate = status.IsCompleted() ? (DateTime?)CryptoUtility.UnixTimeStampToDateTimeMilliseconds(EventTime) : null, + CompletedDate = status.IsCompleted() ? (DateTime?)CryptoUtility.UnixTimeStampToDateTimeMilliseconds(TransactionTime) : null, + TradeDate = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(TransactionTime), MarketSymbol = Symbol, // IsBuy is not provided here Fees = CommissionAmount, diff --git a/src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs b/src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs index 66fe85ed..83b8403a 100644 --- a/src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs @@ -385,6 +385,7 @@ private ExchangeOrderResult TradeHistoryToExchangeOrderResult(JToken token) { var res = ParseOrderCore(token); res.TradeId = token["trade_id"].ToStringInvariant(); + res.TradeDate = token["executed_at"].ConvertInvariant().UnixTimeStampToDateTimeMilliseconds(); res.Amount = token["amount"].ConvertInvariant(); res.AmountFilled = res.Amount; res.Fees = token["fee_amount_base"].ConvertInvariant(); diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs index 019a5686..0fb242e5 100644 --- a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs @@ -65,7 +65,9 @@ private ExchangeOrderResult ParseFill(JToken result) Fees = fees, AveragePrice = price, IsBuy = (result["side"].ToStringInvariant() == "buy"), - OrderDate = result["created_at"].ToDateTimeInvariant(), + // OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate is not nullable + CompletedDate = null, // order not necessarily fully filled at this point + TradeDate = result["created_at"].ToDateTimeInvariant(), // even though it is named "created_at", the documentation says that it is the: timestamp of fill MarketSymbol = symbol, OrderId = result["order_id"].ToStringInvariant(), }; diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/Messages.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/Messages.cs index eaaacff2..5e43f04f 100644 --- a/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/Messages.cs +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/Messages.cs @@ -182,8 +182,9 @@ internal class Match : BaseMessage IsAmountFilledReversed = false, // the size here appears to be amount filled, no no need to reverse Price = Price, AveragePrice = Price, // not specified here - // OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate + // OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate is not nullable CompletedDate = null, // order not necessarily fullly filled at this point + TradeDate = Time.ToDateTimeInvariant(), MarketSymbol = ProductId, IsBuy = Side == OrderSide.Buy, Fees = (MakerFeeRate ?? TakerFeeRate) * Price * Size, diff --git a/src/ExchangeSharp/API/Exchanges/Digifinex/ExchangeDigifinexAPI.cs b/src/ExchangeSharp/API/Exchanges/Digifinex/ExchangeDigifinexAPI.cs index 0d281491..8a8407ea 100644 --- a/src/ExchangeSharp/API/Exchanges/Digifinex/ExchangeDigifinexAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Digifinex/ExchangeDigifinexAPI.cs @@ -356,7 +356,9 @@ protected override async Task> OnGetCompletedOr AmountFilled = x["amount"].ConvertInvariant(), Fees = x["fee"].ConvertInvariant(), FeesCurrency = x["fee_currency"].ToStringInvariant(), - CompletedDate = CryptoUtility.UnixTimeStampToDateTimeSeconds(x["timestamp"].ConvertInvariant()), + // OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate is not nullable + CompletedDate = null, // order not necessarily fully filled at this point + TradeDate = CryptoUtility.UnixTimeStampToDateTimeSeconds(x["timestamp"].ConvertInvariant()), IsBuy = x["side"].ToStringLowerInvariant() == "buy", Result = ExchangeAPIOrderResult.Unknown, }); diff --git a/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs b/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs index 2742a452..cb5e7aea 100644 --- a/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs @@ -239,7 +239,6 @@ private async Task ParseHistoryOrder(string orderId, JToken ExchangeOrderResult orderResult = new ExchangeOrderResult { OrderId = orderId }; orderResult.Result = ExchangeAPIOrderResult.Filled; orderResult.Message = ""; - orderResult.OrderDate = CryptoUtility.UnixTimeStampToDateTimeSeconds(order["time"].ConvertInvariant()); orderResult.MarketSymbol = order["pair"].ToStringInvariant(); orderResult.IsBuy = (order["type"].ToStringInvariant() == "buy"); orderResult.Amount = order["vol"].ConvertInvariant(); @@ -249,7 +248,9 @@ private async Task ParseHistoryOrder(string orderId, JToken orderResult.TradeId = order["postxid"].ToStringInvariant(); //verify which is orderid & tradeid orderResult.OrderId = order["ordertxid"].ToStringInvariant(); //verify which is orderid & tradeid orderResult.AmountFilled = order["vol"].ConvertInvariant(); - orderResult.CompletedDate = CryptoUtility.UnixTimeStampToDateTimeSeconds(order["time"].ConvertInvariant()); + // orderResult.OrderDate - not provided here. ideally would be null but ExchangeOrderResult.OrderDate is not nullable + orderResult.CompletedDate = null; // order not necessarily fully filled at this point + orderResult.TradeDate = CryptoUtility.UnixTimeStampToDateTimeSeconds(order["time"].ConvertInvariant()); string[] pairs = (await ExchangeMarketSymbolToGlobalMarketSymbolAsync(order["pair"].ToStringInvariant())).Split('-'); orderResult.FeesCurrency = pairs[1]; diff --git a/src/ExchangeSharp/Model/ExchangeOrderResult.cs b/src/ExchangeSharp/Model/ExchangeOrderResult.cs index 9f925229..6221eaa4 100644 --- a/src/ExchangeSharp/Model/ExchangeOrderResult.cs +++ b/src/ExchangeSharp/Model/ExchangeOrderResult.cs @@ -88,9 +88,12 @@ public sealed class ExchangeOrderResult /// The id of the trade if this is only one trade out of the order. public string TradeId { get; set; } - /// Append another order to this order - order id and type must match - /// Order to append - public void AppendOrderWithOrder(ExchangeOrderResult other) + /// datetime in UTC of the trade. Null if not a trade. + public DateTime? TradeDate { get; set; } + + /// Append another order to this order - order id and type must match + /// Order to append + public void AppendOrderWithOrder(ExchangeOrderResult other) { if ((OrderId != null) && (MarketSymbol != null) && ((OrderId != other.OrderId) || (IsBuy != other.IsBuy) || (MarketSymbol != other.MarketSymbol))) {