Esempio n. 1
0
        // Notes:
        //   - API Info:
        //     https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

        public BinanceApi(string key, string secret, CancellationToken shutdown, Logger log)
            : base(key, secret, shutdown, 6, "https://api.binance.com/", "wss://stream.binance.com:9443/")
        {
            try
            {
                Log         = new Logger("BinanceApi", log);
                SymbolRules = new SymbolRulesMap();
                TickerData  = new TickerDataCache(this);
                MarketData  = new MarketDataCache(this);
                CandleData  = new CandleDataCache(this);
                UserData    = new UserDataCache(this);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Esempio n. 2
0
            public UserDataStream(UserDataCache owner)
            {
                try
                {
                    Cache    = owner;
                    Balances = Api.GetBalances().Result;
                    Orders   = new OrdersStream(Api);
                    History  = new HistoryStream(Api);
                    UserDataKeepAliveTimeout = TimeSpan.FromMinutes(30);

                    // Start the user data stream. User data times out after 60minutes
                    ListenKey         = Api.StartUserDataStream().Result;
                    m_listen_key_bump = DateTimeOffset.Now;

                    // Create the socket (requires the ListenKey in the endpoint URL)
                    Socket = new WebSocket(Api.Shutdown);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }