forked from DigitalRuby/ExchangeSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrderHistoryOption.cs
38 lines (30 loc) · 1006 Bytes
/
OrderHistoryOption.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Threading.Tasks;
using CommandLine;
using ExchangeSharpConsole.Options.Interfaces;
namespace ExchangeSharpConsole.Options
{
[Verb("order-history", HelpText = "Prints the orders history from an exchange.")]
public class OrderHistoryOption : BaseOption, IOptionPerExchange, IOptionPerMarketSymbol, IOptionWithStartDate
{
public override async Task RunCommand()
{
using var api = await GetExchangeInstanceAsync(ExchangeName);
Authenticate(api);
DateTime? startDate = null;
if (!string.IsNullOrWhiteSpace(SinceDateString))
{
startDate = DateTime.Parse(SinceDateString).ToUniversalTime();
}
var completedOrders = await api.GetCompletedOrderDetailsAsync(MarketSymbol, startDate);
foreach (var completedOrder in completedOrders)
{
Console.WriteLine(completedOrder);
}
WaitInteractively();
}
public string ExchangeName { get; set; }
public string MarketSymbol { get; set; }
public string SinceDateString { get; set; }
}
}