Пример #1
0
        public static DepthTickView FromList(List <DepthDetailView> list)
        {
            if (list == null || list.Count == 0)
            {
                return(null);
            }

            DepthTickView first = null;
            DepthTickView next  = null;

            for (int i = 0; i < list.Count; ++i)
            {
                DepthDetailView detail = list[i];
                switch (i % 3)
                {
                case 0:
                    if (next == null)
                    {
                        next  = new DepthTickView();
                        first = next;
                    }
                    else
                    {
                        next.Next = new DepthTickView();
                        next      = next.Next;
                    }

                    next.BidPrice1 = detail.BidPrice;
                    next.BidSize1  = detail.BidSize;
                    next.BidCount1 = detail.BidCount;
                    next.AskPrice1 = detail.AskPrice;
                    next.AskSize1  = detail.AskSize;
                    next.AskCount1 = detail.AskCount;
                    break;

                case 1:
                    next.BidPrice2 = detail.BidPrice;
                    next.BidSize2  = detail.BidSize;
                    next.BidCount2 = detail.BidCount;
                    next.AskPrice2 = detail.AskPrice;
                    next.AskSize2  = detail.AskSize;
                    next.AskCount2 = detail.AskCount;
                    break;

                case 2:
                    next.BidPrice3 = detail.BidPrice;
                    next.BidSize3  = detail.BidSize;
                    next.BidCount3 = detail.BidCount;
                    next.AskPrice3 = detail.AskPrice;
                    next.AskSize3  = detail.AskSize;
                    next.AskCount3 = detail.AskCount;
                    break;
                }
            }

            return(first);
        }
Пример #2
0
        public static List <DepthDetailView> ToList(DepthTickView deep)
        {
            List <DepthDetailView> list = new List <DepthDetailView>();
            DepthDetailView        detail;

            DepthTickView last = deep;

            while (last != null)
            {
                if (last.BidSize1 == 0 && last.AskSize1 == 0)
                {
                    break;
                }

                detail          = new DepthDetailView();
                detail.BidPrice = last.BidPrice1;
                detail.BidSize  = last.BidSize1;
                detail.BidCount = last.BidCount1;
                detail.AskPrice = last.AskPrice1;
                detail.AskSize  = last.AskSize1;
                detail.AskCount = last.AskCount1;
                list.Add(detail);

                if (last.BidSize2 == 0 && last.AskSize2 == 0)
                {
                    break;
                }

                detail          = new DepthDetailView();
                detail.BidPrice = last.BidPrice2;
                detail.BidSize  = last.BidSize2;
                detail.BidCount = last.BidCount2;
                detail.AskPrice = last.AskPrice2;
                detail.AskSize  = last.AskSize2;
                detail.AskCount = last.AskCount2;
                list.Add(detail);

                if (last.BidSize3 == 0 && last.AskSize3 == 0)
                {
                    break;
                }

                detail          = new DepthDetailView();
                detail.BidPrice = last.BidPrice3;
                detail.BidSize  = last.BidSize3;
                detail.BidCount = last.BidCount3;
                detail.AskPrice = last.AskPrice3;
                detail.AskSize  = last.AskSize3;
                detail.AskCount = last.AskCount3;
                list.Add(detail);

                last = last.Next;
            }

            return(list);
        }
Пример #3
0
        public DepthTickView Int2Double(DepthTick depthTick)
        {
            if (depthTick == null)
            {
                return(null);
            }

            DepthTickView field = new DepthTickView();

            field.BidPrice1 = Codec.TickToPrice(depthTick.BidPrice1);
            field.BidSize1  = depthTick.BidSize1;
            field.AskPrice1 = Codec.TickToPrice(depthTick.AskPrice1);
            field.AskSize1  = depthTick.AskSize1;
            field.BidPrice2 = Codec.TickToPrice(depthTick.BidPrice2);
            field.BidSize2  = depthTick.BidSize2;
            field.AskPrice2 = Codec.TickToPrice(depthTick.AskPrice2);
            field.AskSize2  = depthTick.AskSize2;
            field.BidPrice3 = Codec.TickToPrice(depthTick.BidPrice3);
            field.BidSize3  = depthTick.BidSize3;
            field.AskPrice3 = Codec.TickToPrice(depthTick.AskPrice3);
            field.AskSize3  = depthTick.AskSize3;

            if (depthTick.Next != null)
            {
                field.Next = Int2Double(depthTick.Next);
            }

            field.BidCount1 = depthTick.BidCount1;
            field.AskCount1 = depthTick.AskCount1;
            field.BidCount2 = depthTick.BidCount2;
            field.AskCount2 = depthTick.AskCount2;
            field.BidCount3 = depthTick.BidCount3;
            field.AskCount3 = depthTick.AskCount3;

            return(field);
        }
Пример #4
0
        public DepthTick Double2Int(DepthTickView depthTick)
        {
            if (depthTick == null)
            {
                return(null);
            }

            DepthTick field = new DepthTick();

            field.BidPrice1 = Codec.PriceToTick(depthTick.BidPrice1);
            field.BidSize1  = depthTick.BidSize1;
            field.AskPrice1 = Codec.PriceToTick(depthTick.AskPrice1);
            field.AskSize1  = depthTick.AskSize1;
            field.BidPrice2 = Codec.PriceToTick(depthTick.BidPrice2);
            field.BidSize2  = depthTick.BidSize2;
            field.AskPrice2 = Codec.PriceToTick(depthTick.AskPrice2);
            field.AskSize2  = depthTick.AskSize2;
            field.BidPrice3 = Codec.PriceToTick(depthTick.BidPrice3);
            field.BidSize3  = depthTick.BidSize3;
            field.AskPrice3 = Codec.PriceToTick(depthTick.AskPrice3);
            field.AskSize3  = depthTick.AskSize3;

            if (depthTick.Next != null)
            {
                field.Next = Double2Int(depthTick.Next);
            }

            field.BidCount1 = depthTick.BidCount1;
            field.AskCount1 = depthTick.AskCount1;
            field.BidCount2 = depthTick.BidCount2;
            field.AskCount2 = depthTick.AskCount2;
            field.BidCount3 = depthTick.BidCount3;
            field.AskCount3 = depthTick.AskCount3;

            return(field);
        }