forked from DigitalRuby/ExchangeSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebSocketsPositionsOption.cs
35 lines (30 loc) · 1001 Bytes
/
WebSocketsPositionsOption.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
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-positions", HelpText =
"Connects to the given exchange private websocket and keeps printing your position updates from that exchange.")]
public class WebSocketsPositionsOption : BaseOption, IOptionPerExchange, IOptionWithKey
{
public override async Task RunCommand()
{
async Task<IWebSocket> GetWebSocket(IExchangeAPI api)
{
api.LoadAPIKeys(KeyPath);
return await api.GetPositionsWebSocketAsync(position =>
{
Console.WriteLine($"Open TimeStamp: {position.TimeStamp} Market: {position.MarketSymbol}: Amount: {position.Amount} Average Price: {position.AveragePrice}");
}
);
}
await RunWebSocket(ExchangeName, GetWebSocket);
}
public string ExchangeName { get; set; }
public string KeyPath { get; set; }
}
}