Exemple #1
0
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "binance-api-secret", "binance-api-key", "binance-api-url", "binance-websocket-url" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new ArgumentException($"BinanceBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var brokerage = new BinanceBrokerage(
                job.BrokerageData["binance-api-key"],
                job.BrokerageData["binance-api-secret"],
                job.BrokerageData["binance-api-url"],
                job.BrokerageData["binance-websocket-url"],
                algorithm,
                Composer.Instance.GetExportedValueByTypeName <IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager"), forceTypeNameOnExisting: false),
                job);

            Composer.Instance.AddPart <IDataQueueHandler>(brokerage);

            return(brokerage);
        }
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "bitfinex-rest", "bitfinex-url", "bitfinex-api-secret", "bitfinex-api-key" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception($"BitfinexBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var priceProvider = new ApiPriceProvider(job.UserId, job.UserToken);

            var brokerage = new BitfinexBrokerage(
                job.BrokerageData["bitfinex-url"],
                job.BrokerageData["bitfinex-rest"],
                job.BrokerageData["bitfinex-api-key"],
                job.BrokerageData["bitfinex-api-secret"],
                algorithm,
                priceProvider,
                Composer.Instance.GetExportedValueByTypeName <IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager")));

            Composer.Instance.AddPart <IDataQueueHandler>(brokerage);

            return(brokerage);
        }
Exemple #3
0
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "bitfinex-rest", "bitfinex-url", "bitfinex-api-secret", "bitfinex-api-key" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception($"BitfinexBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var priceProvider = new ApiPriceProvider(job.UserId, job.UserToken);

            var brokerage = new BitfinexBrokerage(
                job.BrokerageData["bitfinex-url"],
                job.BrokerageData["bitfinex-rest"],
                job.BrokerageData["bitfinex-api-key"],
                job.BrokerageData["bitfinex-api-secret"],
                algorithm,
                priceProvider);

            Composer.Instance.AddPart <IDataQueueHandler>(brokerage);

            return(brokerage);
        }
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "zerodha-api-key", "zerodha-access-token", "zerodha-trading-segment", "zerodha-product-type" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception($"ZerodhaBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var brokerage = new ZerodhaBrokerage(
                job.BrokerageData["zerodha-trading-segment"],
                job.BrokerageData["zerodha-product-type"],
                job.BrokerageData["zerodha-api-key"],
                job.BrokerageData["zerodha-access-token"],
                algorithm,
                algorithm.Portfolio,
                Composer.Instance.GetExportedValueByTypeName <IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager"))
                );

            //Add the brokerage to the composer to ensure its accessible to the live data feed.
            Composer.Instance.AddPart <IDataQueueHandler>(brokerage);
            return(brokerage);
        }
Exemple #5
0
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "gdax-url", "gdax-api-secret", "gdax-api-key", "gdax-passphrase" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception($"GDAXBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var restApi = BrokerageData["gdax-rest-api"];

            if (job.BrokerageData.ContainsKey("gdax-rest-api"))
            {
                restApi = job.BrokerageData["gdax-rest-api"];
            }

            var restClient      = new RestClient(restApi);
            var webSocketClient = new WebSocketClientWrapper();
            var priceProvider   = new ApiPriceProvider(job.UserId, job.UserToken);
            var aggregator      = Composer.Instance.GetExportedValueByTypeName <IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager"), forceTypeNameOnExisting: false);

            IBrokerage brokerage;

            if (job.DataQueueHandler.Contains("GDAXDataQueueHandler"))
            {
                var dataQueueHandler = new GDAXDataQueueHandler(job.BrokerageData["gdax-url"], webSocketClient,
                                                                restClient, job.BrokerageData["gdax-api-key"], job.BrokerageData["gdax-api-secret"],
                                                                job.BrokerageData["gdax-passphrase"], algorithm, priceProvider, aggregator, job);

                Composer.Instance.AddPart <IDataQueueHandler>(dataQueueHandler);

                brokerage = dataQueueHandler;
            }
            else
            {
                brokerage = new GDAXBrokerage(job.BrokerageData["gdax-url"], webSocketClient,
                                              restClient, job.BrokerageData["gdax-api-key"], job.BrokerageData["gdax-api-secret"],
                                              job.BrokerageData["gdax-passphrase"], algorithm, priceProvider, aggregator, job);
            }

            return(brokerage);
        }
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override Interfaces.IBrokerage CreateBrokerage(Packets.LiveNodePacket job, Interfaces.IAlgorithm algorithm)
        {
            var required = new[] { "gdax-url", "gdax-api-secret", "gdax-api-key", "gdax-passphrase" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception(string.Format("GDAXBrokerageFactory.CreateBrokerage: Missing {0} in config.json", item));
                }
            }

            var restClient      = new RestClient("https://api.gdax.com");
            var webSocketClient = new WebSocketWrapper();

            var brokerage = new GDAXBrokerage(job.BrokerageData["gdax-url"], webSocketClient, restClient, job.BrokerageData["gdax-api-key"], job.BrokerageData["gdax-api-secret"],
                                              job.BrokerageData["gdax-passphrase"], algorithm);

            Composer.Instance.AddPart <IDataQueueHandler>(brokerage);

            return(brokerage);
        }
Exemple #7
0
        /// <summary>
        /// Create the Brokerage instance
        /// </summary>
        /// <param name="job"></param>
        /// <param name="algorithm"></param>
        /// <returns></returns>
        public override IBrokerage CreateBrokerage(Packets.LiveNodePacket job, IAlgorithm algorithm)
        {
            var required = new[] { "gdax-url", "gdax-api-secret", "gdax-api-key", "gdax-passphrase" };

            foreach (var item in required)
            {
                if (string.IsNullOrEmpty(job.BrokerageData[item]))
                {
                    throw new Exception($"GDAXBrokerageFactory.CreateBrokerage: Missing {item} in config.json");
                }
            }

            var restClient      = new RestClient("https://api.pro.coinbase.com");
            var webSocketClient = new WebSocketWrapper();
            var priceProvider   = new ApiPriceProvider(job.UserId, job.UserToken);

            IBrokerage brokerage;

            if (job.DataQueueHandler.EndsWith("GDAXDataQueueHandler"))
            {
                var dataQueueHandler = new GDAXDataQueueHandler(job.BrokerageData["gdax-url"], webSocketClient,
                                                                restClient, job.BrokerageData["gdax-api-key"], job.BrokerageData["gdax-api-secret"],
                                                                job.BrokerageData["gdax-passphrase"], algorithm, priceProvider);

                Composer.Instance.AddPart <IDataQueueHandler>(dataQueueHandler);

                brokerage = dataQueueHandler;
            }
            else
            {
                brokerage = new GDAXBrokerage(job.BrokerageData["gdax-url"], webSocketClient,
                                              restClient, job.BrokerageData["gdax-api-key"], job.BrokerageData["gdax-api-secret"],
                                              job.BrokerageData["gdax-passphrase"], algorithm, priceProvider);
            }

            return(brokerage);
        }