示例#1
0
        public double TimeFrameGetPrice(IntervalPeriod periodInterval, PriceType priceType, int index = 0)
        {
            var date  = TimeFrameRequest <BarData>(periodInterval);
            var price = 0D;


            if (date != null && date.Count > 0)
            {
                price = date.GetValue(priceType, index);
            }

            return(price);
        }
示例#2
0
        private DateTime GetFromPeriod(IntervalPeriod periodInterval)
        {
            var currentFromInterval = HistoryDataSeries.GetTimeUtc(HistoryDataSeries.Count - 1);

            switch (periodInterval.Period)
            {
            case Period.Second: return(currentFromInterval > DateTime.UtcNow.AddSeconds(-periodInterval.Value) ? DateTime.UtcNow.AddSeconds(-periodInterval.Value) : currentFromInterval);

            case Period.Minute: return(currentFromInterval > DateTime.UtcNow.AddMinutes(-periodInterval.Value) ? DateTime.UtcNow.AddMinutes(-periodInterval.Value) : currentFromInterval);

            case Period.Hour: return(currentFromInterval > DateTime.UtcNow.AddHours(-periodInterval.Value) ? DateTime.UtcNow.AddHours(-periodInterval.Value) : currentFromInterval);

            case Period.Day: return(currentFromInterval > DateTime.UtcNow.AddDays(-periodInterval.Value) ? DateTime.UtcNow.AddDays(-periodInterval.Value) : currentFromInterval);

            case Period.Week: return(currentFromInterval > DateTime.UtcNow.AddDays(-periodInterval.Value * 7) ? DateTime.UtcNow.AddDays(-periodInterval.Value * 7) : currentFromInterval);

            case Period.Month: return(currentFromInterval > DateTime.UtcNow.AddMonths(-periodInterval.Value) ? DateTime.UtcNow.AddMonths(-periodInterval.Value) : currentFromInterval);

            case Period.Year: return(currentFromInterval > DateTime.UtcNow.AddYears(-periodInterval.Value) ? DateTime.UtcNow.AddYears(-periodInterval.Value) : currentFromInterval);

            default: return(currentFromInterval);
            }
        }
示例#3
0
        public T TimeFrameRequest <T>(IntervalPeriod periodInterval, DataType dataType = DataType.Bid) where T : HistoricalData
        {
            var request = new TimeHistoricalRequest(InstrumentsManager.Current, dataType, periodInterval.Period, periodInterval.Value);
            var data    = HistoricalDataManager.Get(request, new Interval(GetFromPeriod(periodInterval), DateTime.UtcNow)) as T;


            var result = new AsyncResult(data);

            HistoricalDataManager.OnLoaded = (historianData) =>
            {
                result        = new AsyncResult(historianData, true);
                result.Status = "Done";
            };

            do
            {
                result.Status = "Loading";
            } while (!result.IsReady);


            data = result.Data as T;

            return(data);
        }