示例#1
0
 /// <summary>
 /// Returns candle data at the specified resolution skipping the first specified number of seconds
 /// </summary>
 public IEnumerable <CandleSample> GetCandleDataAsCandleSamples(CandleHeader header, int skipSeconds = 0)
 {
     return(this.GetCandleData(header, skipSeconds)
            .Select(cd =>
     {
         var cs = cd.ToCandleSample();
         cs.TimeSpanMs = header.ResolutionSec * 1000;
         return cs;
     }));
 }
示例#2
0
        private void parseCandlesMeta(Stream stream)
        {
            var bt = SecDBPrimitives.ReadByte(stream);

            if (bt != 0x03)//0x3 -  Candles metadata header
            {
                throw new FinancialException("CandlesMeta.Header != 0x03");
            }

            //Filler
            bt = SecDBPrimitives.ReadByte(stream);

            //HdrCount
            var icount = SecDBPrimitives.ReadUInt16(stream);

            var chdrs = new CandleHeader[icount];

            //CandleHeader
            for (var i = 0; i < icount; i++)
            {
                bt = SecDBPrimitives.ReadByte(stream);
                if (bt != 0x04)//0x4 -  Candle Header
                {
                    throw new FinancialException("CandleHeader.Header != 0x04");
                }

                //Filler
                bt = SecDBPrimitives.ReadByte(stream);

                var resolution = SecDBPrimitives.ReadUInt16(stream);
                var starttime  = SecDBPrimitives.ReadUInt32(stream);
                var count      = SecDBPrimitives.ReadUInt32(stream);
                var offset     = SecDBPrimitives.ReadUInt32(stream);


                if (resolution == 0)
                {
                    throw new FinancialException("CandleHeader.Resolution == 0x00");
                }

                var sdt = new DateTime(m_SystemHeader.Date.Year,
                                       m_SystemHeader.Date.Month,
                                       m_SystemHeader.Date.Day,
                                       0, 0, 0, DateTimeKind.Utc).AddSeconds(starttime);

                var ch = new CandleHeader(this, resolution, starttime, sdt, count, offset);
                chdrs[i] = ch;
            }
            m_Candles_Meta = new CandlesMeta(this, chdrs);
        }
示例#3
0
        /// <summary>
        /// Gets stream data per candle header index skipping the specified seconds count from data start
        /// </summary>
        public IEnumerable <StreamSample> GetStreamData(CandleHeader header, int skipSeconds = 0)
        {
            var candle = GetCandleData(header, skipSeconds).FirstOrDefault();

            if (!candle.IsAssigned)
            {
                return(Enumerable.Empty <StreamSample>());
            }

            return(workWithFile <enumerateStreamDataArgs, IEnumerable <StreamSample> >(
                       enumerateStreamData,
                       new enumerateStreamDataArgs
            {
                Candle = candle
            }));
        }
示例#4
0
        /// <summary>
        /// Returns candle data at the specified resolution skipping the first specified number of seconds
        /// </summary>
        public IEnumerable <CandleData> GetCandleData(CandleHeader header, int skipSeconds = 0)
        {
            if (!header.IsAssigned || header.File != this)
            {
                throw new FinancialException(StringConsts.ARGUMENT_ERROR + "GetCandleData(!header.IsAssigned | wrong)");
            }


            return(workWithFile <enumerateCandleDataArgs, IEnumerable <CandleData> >(
                       enumerateCandleData,
                       new enumerateCandleDataArgs
            {
                Header = header,
                SkipSeconds = skipSeconds
            }));
        }
示例#5
0
 /// <summary>
 /// Gets stream data per candle header index starting from the specified UTC start time
 /// </summary>
 public IEnumerable <StreamSample> GetStreamData(CandleHeader header, DateTime startTimeUTC)
 {
     return(GetStreamData(header, header.GetSkipSecondsUntil(startTimeUTC)));
 }
示例#6
0
 /// <summary>
 /// Returns candle data at the specified resolution starting at the specified start time
 /// </summary>
 public IEnumerable <CandleSample> GetCandleDataAsCandleSamples(CandleHeader header, DateTime startTimeUTC)
 {
     return(this.GetCandleDataAsCandleSamples(header, header.GetSkipSecondsUntil(startTimeUTC)));
 }
示例#7
0
 /// <summary>
 /// Returns candle data at the specified resolution starting at the specified start time
 /// </summary>
 public IEnumerable <CandleData> GetCandleData(CandleHeader header, DateTime startTimeUTC)
 {
     return(GetCandleData(header, header.GetSkipSecondsUntil(startTimeUTC)));
 }
 internal CandlesMeta(SecDBFileReader file, CandleHeader[] candles) { File = file; Candles = candles;}