Exemple #1
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            Console.WriteLine("Startup Initialized");
            Redis.redis = ConnectionMultiplexer.Connect("localhost");
            Console.WriteLine("Redis Connected to... " + Redis.redis);
            ISubscriber sub = Redis.redis.GetSubscriber();

            sub.Subscribe("messages", (channel, message) =>
            {
                Console.WriteLine((string)message);
            });
            IBinanceSocketClient socketClient = new BinanceSocketClient();
            IBinanceDataProvider prov         = new BinanceDataProvider(socketClient);

            prov.Start();
        }
Exemple #2
0
        /// <summary>
        /// Builds a container for Binance.
        /// </summary>
        /// <param name="config">The algorithm configuration to use.</param>
        /// <typeparam name="T">The algorithm type.</typeparam>
        /// <returns>ExchangeProviderContainer.</returns>
        public ExchangeProvidersContainer BuildBinanceContainer <T>(AlgorithmConfiguration config)
            where T : IBaseAlgorithm
        {
            // Makes sure that the communication is enabled
            _binanceCommunications.EnableStreams();
            var timerProvider         = new BinanceTimerProvider(_loggerFactory, _binanceCommunications.CandleDispenser);
            var dataImplementation    = new BinanceDataProvider(_loggerFactory, _binanceCommunications, timerProvider);
            var tradingImplementation = new BinanceTradingProvider(_loggerFactory, _binanceCommunications, timerProvider);

            var dataProvider    = new DataProvider(_loggerFactory, dataImplementation, config);
            var tradingProvider = new TradingProvider(_loggerFactory, tradingImplementation, dataProvider, _allocationManager);

            // Doubly linked data provider to check candles
            timerProvider.DataProvider = dataProvider;

            // Inject database event listener
            DatabaseEventListenerService.AddOrderSource(tradingProvider);

            return(new ExchangeProvidersContainer(_loggerFactory, dataProvider, timerProvider, tradingProvider, typeof(T)));
        }
Exemple #3
0
        public NeblioCryptocurrency(bool withPrice = true)
        {
            Name               = "Neblio";
            Symbol             = "NEBL";
            BaseURL            = "https://ntp1node.nebl.io/";
            ProjectWebsite     = "https://nebl.io/";
            TokensAvailable    = true;
            OpenAPIAddress     = "https://raw.githubusercontent.com/NeblioTeam/neblio-api-swagger-docs/master/swagger.json";
            FromSatToMainRatio = 100000000;
            Tokens             = new List <NeblioNTP1Token>();
            KlineDataHistory   = new List <IBinanceStreamKlineData>();

            if (withPrice)
            {
                // create connection to kline data of Neblio
                commonBinanceSocketClient       = new BinanceSocketClient();
                binanceDataProvider             = new BinanceDataProvider(commonBinanceSocketClient, "NEBLBTC", Binance.Net.Enums.KlineInterval.OneMinute);
                binanceDataProvider.OnKlineData = (data) =>
                {
                    KlineDataHistory.Add(data);
                    ActualBTCPrice = Convert.ToDouble(data.Data.CommonClose);

                    //remember one hour of graph
                    if (KlineDataHistory.Count > 60)
                    {
                        KlineDataHistory.RemoveAt(0);
                    }
                };
            }
            // load other detail about cryptocurrency
            try
            {
                //GetDetails().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                //todo
            }
        }