Ejemplo n.º 1
0
 public void Save(TickSeries series, SaveMode option = SaveMode.Add)
 {
     foreach (var tick in series)
     {
         Save(tick, option);
     }
 }
Ejemplo n.º 2
0
        public TickSeries GetHistoricalTicks(IHistoricalDataProvider provider, TickType type, Instrument instrument, DateTime dateTime1, DateTime dateTime2)
        {
            if (provider.IsDisconnected)
            {
                provider.Connect();
            }

            DataNotifier @class = new DataNotifier();
            string       text   = Guid.NewGuid().ToString();

            lock (this.dictionary_0)
            {
                this.dictionary_0.Add(text, @class);
            }
            HistoricalDataRequest request = null;

            switch (type)
            {
            case TickType.Bid:
                request = new HistoricalDataRequest(instrument, dateTime1, dateTime2, DataObjectType.Bid);
                break;

            case TickType.Ask:
                request = new HistoricalDataRequest(instrument, dateTime1, dateTime2, DataObjectType.Ask);
                break;

            case TickType.Trade:
                request = new HistoricalDataRequest(instrument, dateTime1, dateTime2, DataObjectType.Trade);
                break;
            }
            request.RequestId = text;
            provider.Send(request);
            @class.ReadyEvent.WaitOne();
            lock (this.dictionary_0)
            {
                this.dictionary_0.Remove(text);
            }
            var ts = new TickSeries("", "");

            foreach (var data in @class.Data)
            {
                var objs = data.Objects;
                foreach (var tick in objs)
                {
                    ts.Add((Tick)tick);
                }
            }
            return(ts);
        }
Ejemplo n.º 3
0
        public TickSeries GetHistoricalTicks(TickType type, Instrument instrument, DateTime dateTime1, DateTime dateTime2)
        {
            DataSeries ds = null;

            switch (type)
            {
            case TickType.Bid:
                ds = GetDataSeries(instrument, DataObjectType.Bid, BarType.Time, 60);
                break;

            case TickType.Ask:
                ds = GetDataSeries(instrument, DataObjectType.Ask, BarType.Time, 60);
                break;

            case TickType.Trade:
                ds = GetDataSeries(instrument, DataObjectType.Trade, BarType.Time, 60);
                break;
            }

            var ts = new TickSeries();

            if (ds != null && ds.Count != 0)
            {
                var index1 = ds.GetIndex(dateTime1, SearchOption.Next);
                var index2 = ds.GetIndex(dateTime2, SearchOption.Prev);
                for (long i = index1; i <= index2; i++)
                {
                    var obj = ds[i];
                    switch (type)
                    {
                    case TickType.Bid:
                        if (obj.TypeId == DataObjectType.Bid)
                        {
                            ts.Add((Bid)obj);
                        }
                        else
                        {
                            Console.WriteLine($"DataManager::GetHistoricalTicks Error, object type is not Bid {obj}");
                        }
                        break;

                    case TickType.Ask:
                        if (obj.TypeId == DataObjectType.Ask)
                        {
                            ts.Add((Ask)obj);
                        }
                        else
                        {
                            Console.WriteLine($"DataManager::GetHistoricalTicks Error, object type is not Ask {obj}");
                        }
                        break;

                    case TickType.Trade:
                        if (obj.TypeId == DataObjectType.Trade)
                        {
                            ts.Add((Trade)obj);
                        }
                        else
                        {
                            Console.WriteLine($"DataManager::GetHistoricalTicks Error, object type is not Trade {obj}");
                        }
                        break;
                    }
                }
            }
            return(ts);
        }