public void SubscribeToChartCandle() { if (CurrentAccount == null) { return; } if (_hasNewReceiver == false) { return; } if (_candleMultiSubKey != null) { UnsubscribeToChartData(_candleMultiSubKey); _candleMultiSubKey = null; } var candleInfos = CandleReceivers.OfType <CandleDataReceiver>().Select(c => new ChartCandleInfo(c.Epic, (ChartScale)c.Period)).ToArray(); if (candleInfos.Length > 0) { _candleMultiSubKey = _igStreamApiClient.SubscribeToChartCandleData(candleInfos, _candleMultiSub); } var tickInfos = CandleReceivers.OfType <TicksDataReceiver>().Select(c => c.Epic).Distinct().ToArray(); if (tickInfos.Length > 0) { _candleMultiSubKey = _igStreamApiClient.SubscribeToChartTicks(tickInfos, _tickMultiSub); } _hasNewReceiver = false; }
public CandleReceiver GetCandleReceiver(string epic, int ticksCount, int averageOpen, int maxSeconds) { var receiver = CandleReceivers.OfType <TicksDataReceiver>().FirstOrDefault(c => c.Epic == epic && c.TicksCount == ticksCount && c.AverageOpen == averageOpen && c.MaxSeconds == maxSeconds); if (receiver == null) { receiver = new TicksDataReceiver(epic, ticksCount, averageOpen, maxSeconds); CandleReceivers.Add(receiver); _hasNewReceiver = true; } return(receiver); }
public CandleReceiver GetCandleReceiver(string epic, Periods period, int averageOpen) { var receiver = CandleReceivers.OfType <CandleDataReceiver>().FirstOrDefault(c => c.Epic == epic && c.Period == period && c.AverageOpen == averageOpen); if (receiver == null) { receiver = new CandleDataReceiver(epic, period, averageOpen); CandleReceivers.Add(receiver); _hasNewReceiver = true; } return(receiver); }