Ejemplo n.º 1
0
        public List <Tuple <DateTime, double> > GetFXTimeSeries(ITimeSeriesKey itsk, DateTime startDate)
        {
            List <Tuple <DateTime, double> > res  = new List <Tuple <DateTime, double> >();
            CurrencyPairTimeSeries           cpts = CurrencyPairTimeSeries.RequestIDToCurrencyPairTimeSeries(itsk.GetTimeSeriesKey());

            if (!Data.CpList.Contains(cpts.CurPair))
            {
                bool loadTs = !ReadFXHistory(cpts);
                if (!loadTs)
                {
                    return(res);
                }
            }
            Frequency fq = itsk.GetFrequency();

            if (fq.IsInferiorFrequency(Frequency.Day1))
            {
                fq = Frequency.Day1;
            }
            List <DateTime> schedule = fq.GetSchedule(DateTime.UtcNow, ScheduleDepth).Where(x => x > startDate).ToList();
            bool            doSave   = false;

            foreach (DateTime date in schedule)
            {
                var item = GetFullData(cpts.CurPair, date);
                doSave = doSave || item.Item2;
                res.Add(new Tuple <DateTime, double>(date, item.Item1));
            }
            if (doSave)
            {
                WriteFXHistory(cpts);
            }
            return(res);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get OHLC timeseries (possibly post-processed into an index)
        /// </summary>
        /// <param name="itsk"></param>
        /// <param name="isIndex"></param>
        /// <returns></returns>
        public List <Tuple <DateTime, double> > GetTimeSeries(ITimeSeriesKey itsk, bool isIndex, DateTime startDate)
        {
            TimeSeriesKeyType type = itsk.GetKeyType();

            if (type == TimeSeriesKeyType.CurrencyPair)
            {
                CurrencyPairTimeSeries cpts = CurrencyPairTimeSeries.RequestIDToCurrencyPairTimeSeries(itsk.GetTimeSeriesKey());
                if (!cpts.IsFiatPair)
                {
                    return(KrakenData.GetTimeSeries(itsk, isIndex, startDate));
                }
                else
                {
                    return(FXData.GetFXTimeSeries(itsk, startDate));
                }
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 3
0
 public void LoadPrices(List <ITimeSeriesKey> TimeSeriesKeyList, bool useLowerFrequencies = false)
 {
     foreach (ITimeSeriesKey itsk in TimeSeriesKeyList)
     {
         if (itsk.GetKeyType() == TimeSeriesKeyType.CurrencyPair)
         {
             CurrencyPairTimeSeries cpts = CurrencyPairTimeSeries.RequestIDToCurrencyPairTimeSeries(itsk.GetTimeSeriesKey());
             if (!cpts.CurPair.IsIdentity)
             {
                 if (!cpts.CurPair.IsFiatPair)
                 {
                     KrakenData.LoadOHLC(itsk, useLowerFrequencies);
                 }
                 else
                 {
                     FXData.LoadData(cpts);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create, Update and Save OHLC data (as much as needed)
 /// </summary>
 /// <param name="itsk"></param>
 /// <param name="useLowerFrequencies"></param>
 public void LoadOHLC(ITimeSeriesKey itsk, bool useLowerFrequencies = false)
 {
     if (itsk.GetKeyType() == TimeSeriesKeyType.CurrencyPair)
     {
         CurrencyPairTimeSeries cpts = CurrencyPairTimeSeries.RequestIDToCurrencyPairTimeSeries(itsk.GetTimeSeriesKey());
         if (!cpts.CurPair.IsIdentity)
         {
             if (cpts.Freq == Frequency.None)
             {
                 cpts.Freq = SavingMinimumFrequency.GetNextFrequency();
             }
             List <Frequency> freqList = (useLowerFrequencies && SaveableFrequency(cpts.Freq)) ? cpts.Freq.GetFrequencyList() : new List <Frequency> {
                 cpts.Freq
             };
             foreach (Frequency item in freqList)
             {
                 CurrencyPairTimeSeries newCpts = (CurrencyPairTimeSeries)cpts.Clone();
                 newCpts.Freq = item;
                 LoadOHLCCore(newCpts);
             }
         }
     }
 }