forked from DigitalRuby/ExchangeSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExportOption.cs
47 lines (40 loc) · 1.46 KB
/
ExportOption.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
39
40
41
42
43
44
45
46
47
using System;
using System.Globalization;
using System.Threading.Tasks;
using CommandLine;
using ExchangeSharp;
using ExchangeSharpConsole.Options.Interfaces;
namespace ExchangeSharpConsole.Options
{
[Verb("export", HelpText =
"Export exchange data. CSV files have millisecond timestamp, price and amount columns. " +
"The export will also convert the CSV to bin files. " +
"This can take a long time depending on your sinceDateTime parameter.\n" +
"Please note that not all exchanges will let you do this and may ban your IP if you try to grab to much data at once. " +
"I've added sensible sleep statements to limit request rates.\n" +
"Example: export -e gemini --since 2015-01-01 -s btcusd -p \"./data/gemini\"")]
public class ExportOption : BaseOption, IOptionPerExchange, IOptionPerMarketSymbol, IOptionWithIO,
IOptionWithStartDate
{
public override async Task RunCommand()
{
long total = 0;
await TraderExchangeExport.ExportExchangeTrades(
await ExchangeAPI.GetExchangeAPIAsync(ExchangeName),
MarketSymbol,
Path,
DateTime.Parse(SinceDateString, CultureInfo.InvariantCulture),
count =>
{
total = count;
Console.WriteLine($"Exporting {ExchangeName}: {total}");
}
);
Console.WriteLine($"Finished Exporting {ExchangeName}: {total}");
}
public string ExchangeName { get; set; }
public string MarketSymbol { get; set; }
public string Path { get; set; }
public string SinceDateString { get; set; }
}
}