Exemple #1
0
        /// <summary>
        /// The Trade Streams push raw trade information; each trade has a unique buyer and seller
        /// </summary>
        /// <param name="symbol">Symbol.</param>
        public IObservable <Binance.WsTrade> SubscribePublicTradesAsync(string symbol, int limit)
        {
            // All symbols for streams are lowercase
            // A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark
            const string url = "wss://stream.binance.com:9443/ws";
            const string req = "/{0}@trade";

            var ws = new WebSocketWrapper(url + string.Format(req, symbol.ToLower()), $"{symbol} trades");

            return(ws.Observe().Select(OnTradeSocketMessage));
        }
Exemple #2
0
        /// <summary>
        /// 24hr Ticker statistics for all symbols that changed in an array pushed every second.
        /// </summary>
        /// <param name="symbols">Symbols.</param>
        public IObservable <Binance.WsPriceTicker24hr> SubscribeMarketSummariesAsync(IEnumerable <string> symbols)
        {
            // A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark
            const string url  = "wss://stream.binance.com:9443";
            const string req2 = "/ws/!ticker@arr";
            //const string req = "/stream?streams=";

            //var uri = url + req + string.Join("/", symbols.Select(s => s.ToLower() + "@ticker"));
            var uri2 = url + req2;
            var ws   = new WebSocketWrapper(uri2, "ticker");

            return(ws.Observe().SelectMany(OnTickerSocketMessage2));
        }