Ejemplo n.º 1
0
        private async void GetCandles()
        {
            this.builder = null;
            var candles = await Task.Run(() => { return(CandleCenter.GetCandles(this.instrumentID, this.CandleType, this.From)); });

            this.Candles = new ObservableCollection <Candle>(candles);
            this.builder = new CandleBuilder(this.Candles.LastOrDefault(), this.CandleType);
        }
Ejemplo n.º 2
0
        public static void ProcessQuotation(Quotation quotation, int volume)
        {
            CandleBuilder builder;

            if (!builders.TryGetValue(quotation.InstrumentID, out builder))
            {
                builder = new CandleBuilder(CandleDAL.GetLast(quotation.InstrumentID), CandleType.Minute);
                builders.Add(quotation.InstrumentID, builder);
            }
            builder.ProcessQuotation(quotation, volume);
            DataSaver.AddCandle(builder.LastData);
        }
Ejemplo n.º 3
0
        //Многопоточная конвертации партии .qsh файлов
        private void ConvertPart(List <string> files)
        {
            var array = new Task[files.Count];

            for (int i = 0; i < files.Count; i++)
            {
                var file = files[i];

                array[i] = new Task((() =>
                {
                    try
                    {
                        var totalList = new List <List <Trade> >();

                        if (_sourceDataType == SourceDataType.OrderLog)
                        {
                            totalList = OrdLogReader(file);
                        }

                        if (_sourceDataType == SourceDataType.Deals)
                        {
                            totalList.Add(DealsReader(file));
                        }

                        foreach (var list in totalList)
                        {
                            if (list.Count > 1)
                            {
                                var sec = list[0].Security;

                                _storage.Save(list, sec);

                                for (int j = 0; j < _timeFrames.Count; j++)
                                {
                                    var tf = _timeFrames[j];

                                    using (var createCandle = new CandleBuilder(tf))
                                    {
                                        var candles = createCandle.Build(list);
                                        _storage.Save(candles, tf, sec);
                                    }
                                }

                                list.Clear();
                            }
                        }

                        lock (_lock)
                            Progress();
                    }
                    catch (Exception e)
                    {
                        Exception?.Invoke(e.ToString());
                    }
                }));
            }

            foreach (var task in array)
            {
                task.Start();
            }

            Task.WaitAll(array);
        }