/// <summary> /// To get historical ticks. /// </summary> /// <param name="securityId">The instrument identifier for which you need to get all trades.</param> /// <param name="from">Begin period.</param> /// <param name="to">End period.</param> /// <param name="isSuccess">Whether all data were obtained successfully or the download process has been interrupted.</param> /// <returns>Historical ticks.</returns> public IEnumerable <Level1ChangeMessage> GetHistoricalLevel1(SecurityId securityId, DateTimeOffset from, DateTimeOffset to, out bool isSuccess) { this.AddInfoLog(LocalizedStrings.Str2145Params, securityId, from, to); var transactionId = TransactionIdGenerator.GetNextId(); var info = new RefFive <List <Level1ChangeMessage>, SyncObject, bool, SecurityId, bool>(new List <Level1ChangeMessage>(), new SyncObject(), false, securityId, false); _level1Info.Add(transactionId, info); SendInMessage(new MarketDataMessage { SecurityId = securityId, DataType = MarketDataTypes.Level1, From = from, To = to, IsSubscribe = true, TransactionId = transactionId, }); lock (info.Second) { if (!info.Third) { info.Second.Wait(); } } isSuccess = info.Fifth; return(info.First); }
/// <summary> /// Получить исторических тиков. /// </summary> /// <param name="security">Инструмент, для которого необходимо получить все сделки.</param> /// <param name="count">Максимальное количество тиков.</param> /// <param name="isSuccess">Успешно ли получены все данные или процесс загрузки был прерван.</param> /// <returns>Исторические сделки.</returns> public IEnumerable<Trade> GetHistoricalTicks(Security security, long count, out bool isSuccess) { if (security == null) throw new ArgumentNullException("security"); this.AddInfoLog(LocalizedStrings.Str2144Params, security, count); var transactionId = TransactionIdGenerator.GetNextId(); var info = new RefFive<List<Trade>, SyncObject, bool, Security, bool>(new List<Trade>(), new SyncObject(), false, security, false); _ticksInfo.Add(transactionId, info); SendInMessage(new MarketDataMessage { SecurityId = security.ToSecurityId(), DataType = MarketDataTypes.Trades, Count = count, IsSubscribe = true, TransactionId = transactionId, }); lock (info.Second) { if (!info.Third) info.Second.Wait(); } isSuccess = info.Fifth; return info.First; }
/// <summary> /// To get historical candles. /// </summary> /// <param name="security">The instrument for which you need to get candles.</param> /// <param name="candleType">The candle type.</param> /// <param name="arg">The candle parameter (for example, time-frame).</param> /// <param name="count">Maximum ticks count.</param> /// <param name="isSuccess">Whether all data were obtained successfully or the download process has been interrupted.</param> /// <returns>Historical candles.</returns> public IEnumerable <Candle> GetHistoricalCandles(Security security, Type candleType, object arg, long count, out bool isSuccess) { if (security == null) { throw new ArgumentNullException("security"); } //if (timeFrame <= TimeSpan.Zero) // throw new ArgumentException("Тайм-фрейм должен быть больше 0."); var transactionId = TransactionIdGenerator.GetNextId(); var series = new CandleSeries(candleType, security, arg); this.AddInfoLog(LocalizedStrings.Str2146Params, series, count); var info = new RefFive <List <Candle>, SyncObject, bool, CandleSeries, bool>(new List <Candle>(), new SyncObject(), false, series, false); _candleInfo.Add(transactionId, info); var mdMsg = new MarketDataMessage { //SecurityId = GetSecurityId(series.Security), DataType = GetCandleType(series.CandleType), TransactionId = transactionId, Count = count, Arg = arg, IsSubscribe = true, }.FillSecurityInfo(this, series.Security); _candleSeries.Add(transactionId, series); SendInMessage(mdMsg); lock (info.Second) { if (!info.Third) { info.Second.Wait(); } } isSuccess = info.Fifth; return(info.First); }
/// <summary> /// To get historical candles. /// </summary> /// <param name="security">The instrument for which you need to get candles.</param> /// <param name="candleType">The candle type.</param> /// <param name="arg">The candle parameter (for example, time-frame).</param> /// <param name="from">Begin period.</param> /// <param name="to">End period.</param> /// <param name="isSuccess">Whether all data were obtained successfully or the download process has been interrupted.</param> /// <returns>Historical candles.</returns> public IEnumerable <Candle> GetHistoricalCandles(Security security, Type candleType, object arg, DateTimeOffset from, DateTimeOffset to, out bool isSuccess) { if (security == null) { throw new ArgumentNullException("security"); } //if (timeFrame <= TimeSpan.Zero) // throw new ArgumentException("Тайм-фрейм должен быть больше 0."); if (from > to) { throw new ArgumentException(LocalizedStrings.Str2147); } var id = TransactionIdGenerator.GetNextId(); var series = new CandleSeries(candleType, security, arg); this.AddInfoLog(LocalizedStrings.Str2148Params, series, from, to); var info = new RefFive <List <Candle>, SyncObject, bool, CandleSeries, bool>(new List <Candle>(), new SyncObject(), false, series, false); _candleInfo.Add(id, info); SubscribeCandles(series, from, to, id); lock (info.Second) { if (!info.Third) { info.Second.Wait(); } } isSuccess = info.Fifth; return(info.First); }
/// <summary> /// Получить исторических тиков. /// </summary> /// <param name="security">Инструмент, для которого необходимо получить все сделки.</param> /// <param name="from">Дата начала периода.</param> /// <param name="to">Дата окончания периода.</param> /// <param name="isSuccess">Успешно ли получены все данные или процесс загрузки был прерван.</param> /// <returns>Исторические сделки.</returns> public IEnumerable <Trade> GetHistoricalTicks(Security security, DateTime from, DateTime to, out bool isSuccess) { if (security == null) { throw new ArgumentNullException("security"); } this.AddInfoLog(LocalizedStrings.Str2145Params, security, from, to); var transactionId = TransactionIdGenerator.GetNextId(); var info = new RefFive <List <Trade>, SyncObject, bool, Security, bool>(new List <Trade>(), new SyncObject(), false, security, false); _ticksInfo.Add(transactionId, info); SendInMessage(new MarketDataMessage { SecurityId = security.ToSecurityId(), DataType = MarketDataTypes.Trades, From = from, To = to, IsSubscribe = true, TransactionId = transactionId, }); lock (info.Second) { if (!info.Third) { info.Second.Wait(); } } isSuccess = info.Fifth; return(info.First); }
/// <summary> /// Получить исторические свечи. /// </summary> /// <param name="security">Инструмент, для которого необходимо получить свечи.</param> /// <param name="candleType">Тип свечи.</param> /// <param name="arg">Параметр свечки (например, тайм-фрейм).</param> /// <param name="from">Дата начала периода.</param> /// <param name="to">Дата окончания периода.</param> /// <param name="isSuccess">Успешно ли получены все данные или процесс загрузки был прерван.</param> /// <returns>Исторические свечи.</returns> public IEnumerable<Candle> GetHistoricalCandles(Security security, Type candleType, object arg, DateTime from, DateTime to, out bool isSuccess) { if (security == null) throw new ArgumentNullException("security"); //if (timeFrame <= TimeSpan.Zero) // throw new ArgumentException("Тайм-фрейм должен быть больше 0."); if (from > to) throw new ArgumentException(LocalizedStrings.Str2147); var id = TransactionIdGenerator.GetNextId(); var series = new CandleSeries(candleType, security, arg); this.AddInfoLog(LocalizedStrings.Str2148Params, series, from, to); var info = new RefFive<List<Candle>, SyncObject, bool, CandleSeries, bool>(new List<Candle>(), new SyncObject(), false, series, false); _candleInfo.Add(id, info); SubscribeCandles(series, from, to, id); lock (info.Second) { if (!info.Third) info.Second.Wait(); } isSuccess = info.Fifth; return info.First; }
/// <summary> /// Получить исторические свечи. /// </summary> /// <param name="security">Инструмент, для которого необходимо получить свечи.</param> /// <param name="candleType">Тип свечи.</param> /// <param name="arg">Параметр свечки (например, тайм-фрейм).</param> /// <param name="count">Максимальное количество тиков.</param> /// <param name="isSuccess">Успешно ли получены все данные или процесс загрузки был прерван.</param> /// <returns>Исторические свечи.</returns> public IEnumerable<Candle> GetHistoricalCandles(Security security, Type candleType, object arg, long count, out bool isSuccess) { if (security == null) throw new ArgumentNullException("security"); //if (timeFrame <= TimeSpan.Zero) // throw new ArgumentException("Тайм-фрейм должен быть больше 0."); var transactionId = TransactionIdGenerator.GetNextId(); var series = new CandleSeries(candleType, security, arg); this.AddInfoLog(LocalizedStrings.Str2146Params, series, count); var info = new RefFive<List<Candle>, SyncObject, bool, CandleSeries, bool>(new List<Candle>(), new SyncObject(), false, series, false); _candleInfo.Add(transactionId, info); var mdMsg = new MarketDataMessage { //SecurityId = GetSecurityId(series.Security), DataType = GetCandleType(series.CandleType), TransactionId = transactionId, Count = count, Arg = arg, IsSubscribe = true, }.FillSecurityInfo(this, series.Security); _candleSeries.Add(transactionId, series); SendInMessage(mdMsg); lock (info.Second) { if (!info.Third) info.Second.Wait(); } isSuccess = info.Fifth; return info.First; }
/// <summary> /// To get historical ticks. /// </summary> /// <param name="securityId">The instrument identifier for which you need to get all trades.</param> /// <param name="from">Begin period.</param> /// <param name="to">End period.</param> /// <param name="isSuccess">Whether all data were obtained successfully or the download process has been interrupted.</param> /// <returns>Historical ticks.</returns> public IEnumerable<Level1ChangeMessage> GetHistoricalLevel1(SecurityId securityId, DateTimeOffset from, DateTimeOffset to, out bool isSuccess) { this.AddInfoLog(LocalizedStrings.Str2145Params, securityId, from, to); var transactionId = TransactionIdGenerator.GetNextId(); var info = new RefFive<List<Level1ChangeMessage>, SyncObject, bool, SecurityId, bool>(new List<Level1ChangeMessage>(), new SyncObject(), false, securityId, false); _level1Info.Add(transactionId, info); SendInMessage(new MarketDataMessage { SecurityId = securityId, DataType = MarketDataTypes.Level1, From = from, To = to, IsSubscribe = true, TransactionId = transactionId, }); lock (info.Second) { if (!info.Third) info.Second.Wait(); } isSuccess = info.Fifth; return info.First; }