Beispiel #1
0
        /// <summary>
        /// Constructor for brokerage
        /// </summary>
        /// <param name="wssUrl">websockets url</param>
        /// <param name="restUrl">rest api url</param>
        /// <param name="apiKey">api key</param>
        /// <param name="apiSecret">api secret</param>
        /// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
        /// <param name="priceProvider">The price provider for missing FX conversion rates</param>
        public BitfinexBrokerage(string wssUrl, string restUrl, string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider)
            : base(wssUrl, new WebSocketWrapper(), new RestClient(restUrl), apiKey, apiSecret, Market.Bitfinex, "Bitfinex")
        {
            _subscriptionManager = new BitfinexSubscriptionManager(this, wssUrl, _symbolMapper);
            _algorithm           = algorithm;

            WebSocket.Open += (sender, args) =>
            {
                SubscribeAuth();
            };
        }
Beispiel #2
0
        /// <summary>
        /// Constructor for brokerage
        /// </summary>
        /// <param name="wssUrl">websockets url</param>
        /// <param name="websocket">instance of websockets client</param>
        /// <param name="restClient">instance of rest client</param>
        /// <param name="apiKey">api key</param>
        /// <param name="apiSecret">api secret</param>
        /// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
        /// <param name="priceProvider">The price provider for missing FX conversion rates</param>
        public BitfinexBrokerage(string wssUrl, IWebSocket websocket, IRestClient restClient, string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider)
            : base(wssUrl, websocket, restClient, apiKey, apiSecret, Market.Bitfinex, "Bitfinex")
        {
            _subscriptionManager      = new BitfinexSubscriptionManager(this, wssUrl, _symbolMapper);
            _symbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder();
            _algorithm = algorithm;

            WebSocket.Open += (sender, args) =>
            {
                SubscribeAuth();
            };
        }
        /// <summary>
        /// Constructor for brokerage
        /// </summary>
        /// <param name="websocket">instance of websockets client</param>
        /// <param name="restClient">instance of rest client</param>
        /// <param name="apiKey">api key</param>
        /// <param name="apiSecret">api secret</param>
        /// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
        /// <param name="priceProvider">The price provider for missing FX conversion rates</param>
        /// <param name="aggregator">consolidate ticks</param>
        public BitfinexBrokerage(IWebSocket websocket, IRestClient restClient, string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider, IDataAggregator aggregator)
            : base(WebSocketUrl, websocket, restClient, apiKey, apiSecret, TimeSpan.FromMinutes(1), "Bitfinex")
        {
            SubscriptionManager       = new BitfinexSubscriptionManager(this, WebSocketUrl, _symbolMapper);
            _symbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder();
            _algorithm  = algorithm;
            _aggregator = aggregator;

            WebSocket.Open += (sender, args) =>
            {
                SubscribeAuth();
            };
        }
Beispiel #4
0
        /// <summary>
        /// Constructor for brokerage
        /// </summary>
        /// <param name="websocket">instance of websockets client</param>
        /// <param name="restClient">instance of rest client</param>
        /// <param name="apiKey">api key</param>
        /// <param name="apiSecret">api secret</param>
        /// <param name="algorithm">the algorithm instance is required to retrieve account type</param>
        /// <param name="priceProvider">The price provider for missing FX conversion rates</param>
        /// <param name="aggregator">consolidate ticks</param>
        public BitfinexBrokerage(IWebSocket websocket, IRestClient restClient, string apiKey, string apiSecret, IAlgorithm algorithm, IPriceProvider priceProvider, IDataAggregator aggregator)
            : base(WebSocketUrl, websocket, restClient, apiKey, apiSecret, "Bitfinex")
        {
            SubscriptionManager       = new BitfinexSubscriptionManager(this, WebSocketUrl, _symbolMapper);
            _symbolPropertiesDatabase = SymbolPropertiesDatabase.FromDataFolder();
            _algorithm  = algorithm;
            _aggregator = aggregator;

            // load currency map
            using (var wc = new WebClient())
            {
                var json = wc.DownloadString("https://api-pub.bitfinex.com/v2/conf/pub:map:currency:sym");
                var rows = JsonConvert.DeserializeObject <List <List <List <string> > > >(json)[0];
                _currencyMap = rows
                               .ToDictionary(row => row[0], row => row[1].ToUpperInvariant());
            }

            WebSocket.Open += (sender, args) =>
            {
                SubscribeAuth();
            };
        }