public void Create_ShouldCreateClientInstance() { IKrakenApiClient client = instance.Create("wss://ws-beta.kraken.com"); Assert.NotNull(client); Assert.IsAssignableFrom <IKrakenApiClient>(client); }
private static async Task RunKraken(IKrakenApiClient client) { client.HeartbeatReceived += (sender, e) => Console.WriteLine("Heartbeat received"); client.SystemStatusChanged += (sender, e) => Console.WriteLine($"System status changed: status={e.Message.Status}"); client.SubscriptionStatusChanged += (sender, e) => Console.WriteLine($"Subscription status changed: status={e.Message.Status}, pair={e.Message.Pair}, channelId={e.Message.ChannelId}, error={e.Message.ErrorMessage}, subscription.name={e.Message.Subscription.Name}");; client.TickerReceived += (sender, e) => Console.WriteLine($"Ticker received"); client.OhlcReceived += (sender, e) => Console.WriteLine($"Ohlc received"); client.TradeReceived += (sender, e) => Console.WriteLine($"Trade received"); client.SpreadReceived += (sender, e) => Console.WriteLine($"Spread received"); client.BookSnapshotReceived += (sender, e) => Console.WriteLine($"BookSnapshot received"); client.BookUpdateReceived += (sender, e) => Console.WriteLine($"BookUpdate received"); await client.ConnectAsync(); client.SubscriptionStatusChanged += async(sender, e) => { if (e.Message.Status == SubscriptionStatusNames.Subscribe && e.Message.ChannelId.HasValue) { await Task.Delay(50000); await client.UnsubscribeAsync(e.Message.ChannelId.Value); } }; await client.SubscribeAsync(new Subscribe(new[] { Pair.XBT_EUR }, new SubscribeOptions(SubscribeOptionNames.All))); }
public static async Task RunKraken(IKrakenApiClient c, AuthToken token) { if(clientOne == null) { clientOne = c; c.HeartbeatReceived += Client_HeartbeatReceived; c.SystemStatusChanged += Client_SystemStatusChanged; c.SubscriptionStatusChanged += Client_SubscriptionStatusChanged; c.TickerReceived += Client_TickerReceived; c.OhlcReceived += Client_OhlcReceived; c.TradeReceived += Client_TradeReceived; c.SpreadReceived += Client_SpreadReceived; c.BookSnapshotReceived += Client_BookSnapshotReceived; c.BookUpdateReceived += Client_BookUpdateReceived; c.OwnTradesReceived += Client_OwnTradesReceived; c.OpenOrdersReceived += Client_OpenOrdersReceived; await c.ConnectAsync(); } else { clientTwo = c; _token = token; c.HeartbeatReceived += Client_HeartbeatReceived; c.SystemStatusChanged += Client_SystemStatusChanged; c.SubscriptionStatusChanged += Client_SubscriptionStatusChanged; c.TickerReceived += Client_TickerReceived; c.OhlcReceived += Client_OhlcReceived; c.TradeReceived += Client_TradeReceived; c.SpreadReceived += Client_SpreadReceived; c.BookSnapshotReceived += Client_BookSnapshotReceived; c.BookUpdateReceived += Client_BookUpdateReceived; c.OwnTradesReceived += Client_OwnTradesReceived; c.OpenOrdersReceived += Client_OpenOrdersReceived; await c.ConnectAsync(); await clientTwo.SubscribeAsync(new Subscribe(null, new SubscribeOptions(SubscribeOptionNames.OwnTrades, token.Token))); await clientTwo.SubscribeAsync(new Subscribe(null, new SubscribeOptions(SubscribeOptionNames.OpenOrders, token.Token))); } }
private static async Task RunKraken(IKrakenApiClient client, AuthToken token) { client.HeartbeatReceived += (sender, e) => Console.WriteLine("Heartbeat received"); client.SystemStatusChanged += (sender, e) => Console.WriteLine($"System status changed: status={e.Message.Status}"); client.SubscriptionStatusChanged += (sender, e) => Console.WriteLine($"Subscription status changed: status={e.Message.Status}, pair={e.Message.Pair}, channelId={e.Message.ChannelId}, error={e.Message.ErrorMessage}, subscription.name={e.Message.Subscription.Name}"); client.TickerReceived += (sender, e) => Console.WriteLine($"Ticker received"); client.OhlcReceived += (sender, e) => Console.WriteLine($"Ohlc received"); client.TradeReceived += (sender, e) => Console.WriteLine($"Trade received"); client.SpreadReceived += (sender, e) => Console.WriteLine($"Spread received"); client.BookSnapshotReceived += (sender, e) => Console.WriteLine($"BookSnapshot received"); client.BookUpdateReceived += (sender, e) => Console.WriteLine($"BookUpdate received"); client.OwnTradesReceived += (sender, e) => Console.WriteLine($"OwnTrades received"); client.OpenOrdersReceived += (sender, e) => Console.WriteLine($"OpenOrders received"); await client.ConnectAsync(); client.SubscriptionStatusChanged += async(sender, e) => { if (e.Message.Status == SubscriptionStatusNames.Subscribe && e.Message.ChannelId.HasValue) { await Task.Delay(50000); await client.UnsubscribeAsync(e.Message.ChannelId.Value); } }; await client.SubscribeAsync(new Subscribe(new[] { Pair.XBT_EUR }, new SubscribeOptions(SubscribeOptionNames.All))); await client.SubscribeAsync(new Subscribe(null, new SubscribeOptions(SubscribeOptionNames.OwnTrades, token.Token))); await client.SubscribeAsync(new Subscribe(null, new SubscribeOptions(SubscribeOptionNames.OpenOrders, token.Token))); await client.AddOrder(new AddOrderCommand(token.Token, OrderType.Market, Side.Sell, "XBT/USD", 1) { TradingAgreement = "agree" }); }