public async Task GetTradeHistory() { int iterations = 3; var request = new TTTradeHistoryRequest { TimestampTo = DateTime.UtcNow, RequestDirection = TTStreamingDirections.Backward, RequestPageSize = 10 }; // Try to get trade history from now to the past. Request is limited to 30 records! while (iterations-- > 0) { TTTradeHistoryReport report = await _client.GetTradeHistoryAsync(request); foreach (var record in report.Records) { Console.WriteLine("TradeHistory record: Id={0}, TransactionType={1}, TransactionReason={2}, Symbol={3}, TradeId={4}", record.Id, record.TransactionType, record.TransactionReason, record.Symbol, record.TradeId); request.RequestLastId = record.Id; } // Stop for last report if (report.IsLastReport) { break; } } }
public Task <TTTradeHistoryReport> GetTradeHistoryAsync(TTTradeHistoryRequest request) { return(PrivateHttpPostAsync <TTTradeHistoryReport, TTTradeHistoryRequest>("api/v1/tradehistory", request)); }
/// <summary> /// Get account trade history /// </summary> /// <remarks> /// New trade history request is described by the filling following fields: /// - **TimestampFrom** (optional) - Lower timestamp bound of the trade history request /// - **TimestampTo** (optional) - Upper timestamp bound of the trade history request /// - **OrderId** (optional) - Skip canel order history records /// - **SkipCancelOrder** (optional) - OrderId to filter the trade history request /// - **RequestDirection** (optional) - Request paging direction ("Forward" or "Backward"). Default is "Forward". /// - **RequestPageSize** (optional) - Request page size. Default is 100. /// - **RequestFromId** (optional) - Request paging from Id /// /// If timestamps fields are not set trade history will be requests from the begin or from the current timestamp /// depending on **RequestDirection** value. /// /// Trade history is returned by chunks by paging size (default is 100). You can provide timestamp bounds (from, to) /// and direction of access (forward or backward). After the first request you'll get a list of trade history /// records with Ids. The next request should contain **RequestFromId** with the Id of the last processed trade /// history record. As the result you'll get the next chunk of trade history records. If the last page was reached /// response flag **IsLastReport** will be set. /// </remarks> /// <param name="request">Trade history request</param> /// <returns>Trade history report</returns> public TTTradeHistoryReport GetTradeHistory(TTTradeHistoryRequest request) { return(ConvertToSync(() => GetTradeHistoryAsync(request).Result)); }