2026-06-09 14:32:05 +02:00
|
|
|
using Wickra;
|
|
|
|
|
|
2026-06-17 01:49:11 +02:00
|
|
|
// Stream live BTCUSDT 1-minute klines from Binance and feed each close through EMA(20),
|
|
|
|
|
// using Wickra's native BinanceFeed — no third-party WebSocket or JSON library.
|
2026-06-09 14:32:05 +02:00
|
|
|
// Requires network access (build-only in CI). Runs for up to 60 seconds.
|
2026-06-17 01:49:11 +02:00
|
|
|
Console.WriteLine("Streaming live BTCUSDT 1-minute klines from Binance (up to 60s)...");
|
2026-06-09 14:32:05 +02:00
|
|
|
|
2026-06-17 01:49:11 +02:00
|
|
|
// Native feed: a blocking poll over the same tested stream as the Rust core.
|
|
|
|
|
// Next(timeout) returns the event, or null on timeout (poll again).
|
|
|
|
|
using var feed = new BinanceFeed("BTCUSDT", BinanceInterval.OneMinute);
|
2026-06-09 14:32:05 +02:00
|
|
|
using var ema = new Ema(20);
|
|
|
|
|
|
2026-06-17 01:49:11 +02:00
|
|
|
var deadline = DateTime.UtcNow.AddSeconds(60);
|
|
|
|
|
while (DateTime.UtcNow < deadline)
|
2026-06-09 14:32:05 +02:00
|
|
|
{
|
2026-06-17 01:49:11 +02:00
|
|
|
var ev = feed.Next(TimeSpan.FromSeconds(1));
|
|
|
|
|
if (ev is null)
|
2026-06-09 14:32:05 +02:00
|
|
|
{
|
2026-06-17 01:49:11 +02:00
|
|
|
continue;
|
2026-06-09 14:32:05 +02:00
|
|
|
}
|
2026-06-17 01:49:11 +02:00
|
|
|
Console.WriteLine($"close={ev.Value.Close:F2} EMA(20)={ema.Update(ev.Value.Close):F2}");
|
2026-06-09 14:32:05 +02:00
|
|
|
}
|
2026-06-17 01:49:11 +02:00
|
|
|
|
|
|
|
|
Console.WriteLine("Done (time limit reached).");
|