Ejemplo n.º 1
0
        private void UnloadRates(string pair, ServiceConfiguration.TimeFrame frame)
        {
            string path;

            lock (Locker.Get("GetPath")) path = this.GetPath(frame, pair);

            Rate[] Rates = Data[pair][frame].Values.ToArray();

            //Do not disassembly if no data is availible
            if (Rates == null || Rates.Length <= 0)
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < Rates.Length; i++)
            {
                Rate rate = Rates[i];
                builder.Append(ChartPointInfo.Serialize(rate.ChartData) + "$");//ToStringQuick()
            }

            byte[] bytes = Asmodat.IO.Compression.Zip(builder.ToString());

            lock (Locker.Get("DataDisassembler")) DataDisassembler.Add(path, bytes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates new instance using string serialized chartpoint data
        /// </summary>
        /// <param name="data"></param>
        public static Rate ToRate(string data, RateInfo.DataType type)
        {
            Rate rate = new Rate();

            if (type == RateInfo.DataType.ChartPoint)
            {
                rate.ChartData = ChartPointInfo.Deserialize(data);//.Deserialize(data);
                return(rate);
            }
            else
            {
                throw new Exception("Rate() Deserializing Unknown Format !");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method coverts chart points to data points
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        public static DataPoint[] ToDataPoints(ChartPoint[] points, DataPointType type)
        {
            DataPoint[] ADPoints = new DataPoint[points.Length];

            Parallel.For(0, points.Length, i =>
            {
                if (type == DataPointType.Candle)
                {
                    ADPoints[i] = ChartPointInfo.ToCandle(points[i]);
                }
                else if (type == DataPointType.AskBid)
                {
                    ADPoints[i] = ChartPointInfo.ToAskBid(points[i]);
                }
                else if (type == DataPointType.HiLo)
                {
                    ADPoints[i] = ChartPointInfo.ToHihgLow(points[i]);
                }
                else if (type == DataPointType.OpenClose)
                {
                    ADPoints[i] = ChartPointInfo.ToOpenClose(points[i]);
                }
                else if (type == DataPointType.AskBidErrorBar)
                {
                    ADPoints[i] = ChartPointInfo.ToAskBidErrorBar(points[i]);
                }
                else if (type == DataPointType.AskLine)
                {
                    ADPoints[i] = ChartPointInfo.ToAskLine(points[i]);
                }
                else
                {
                    throw new ArgumentException("ChartPointInfo ToDataPoints Unknown data point type !");
                }
            });

            return(ADPoints);
        }