forked from DigitalRuby/ExchangeSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebSocketsCandesOption.cs
41 lines (35 loc) · 1.1 KB
/
WebSocketsCandesOption.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CommandLine;
using ExchangeSharp;
using ExchangeSharpConsole.Options.Interfaces;
namespace ExchangeSharpConsole.Options
{
[Verb("ws-candles", HelpText =
"Connects to the given exchange websocket and keeps printing the candles from that exchange.\n" +
"If market symbol is not set then uses all.")]
public class WebSocketsCandlesOption : BaseOption, IOptionPerExchange, IOptionWithMultipleMarketSymbol, IOptionWithPeriod
{
public override async Task RunCommand()
{
async Task<IWebSocket> GetWebSocket(IExchangeAPI api)
{
var symbols = await ValidateMarketSymbolsAsync(api, MarketSymbols.ToArray(), true);
return await api.GetCandlesWebSocketAsync(candle =>
{
Console.WriteLine($"Market {candle.Name,8}: {candle}");
return Task.CompletedTask;
},
Period,
symbols
);
}
await RunWebSocket(ExchangeName, GetWebSocket);
}
public string ExchangeName { get; set; }
public IEnumerable<string> MarketSymbols { get; set; }
public int Period { get; set; }
}
}