Exemplo n.º 1
0
 private void CopyOneDirStock(Direction dir, ref CSharedStocks source, int precision)
 {
     for (int i = 0; i < this[dir][precision].Length; i++)
     {
         this[dir][precision][i].Price  = source[dir][precision][i].Price;
         this[dir][precision][i].Volume = source[dir][precision][i].Volume;
     }
 }
Exemplo n.º 2
0
        public bool CopyStocksFull(ref CSharedStocks source)
        {
            //2018-06-26 removed
            //if (source.Count != this.Count)
            //return false;


            bool bWasCopied = false;


            lock (source.Lck)
            {
                lock (this.Lck)
                {
                    try
                    {
                        CopyOneDirStockFull(Direction.Up, ref source);
                        CopyOneDirStockFull(Direction.Down, ref source);

                        UpdateBidAsk();

                        LstStockConf = new List <CStockConf>(source.LstStockConf);

                        //return true;
                        bWasCopied = true;

                        foreach (var kvp in source.QueueCmdStockExch)
                        {
                            Direction dir = kvp.Key;
                            foreach (var kvp2 in kvp.Value)
                            {
                                int prec = kvp2.Key;
                                foreach (var cmdStockCh in kvp2.Value)
                                {
                                    _queueCmdStockExch[dir][prec].Add(cmdStockCh);
                                }


                                kvp2.Value.Clear();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        //return false;
                        bWasCopied = false;
                    }
                }
            }

            return(bWasCopied);
        }
Exemplo n.º 3
0
        public bool IsStocksDifferent(CSharedStocks stkToCompare)
        {
            lock (this.Lck)
            {
                lock (stkToCompare.Lck)
                {
                    return(OneDirStockIsDifferent(Direction.Up, stkToCompare) ||
                           OneDirStockIsDifferent(Direction.Down, stkToCompare));
                }
            }

            //return false;
        }
Exemplo n.º 4
0
 private void CopyOneDirStockFull(Direction dir, ref CSharedStocks source)
 {
     foreach (var el in this[dir])
     {
         int prec = el.Key;
         //2018-06-26 was "till source.Count;"
         //now "till this[dir][prec].Length", source could have more length,
         //so truncate stock (edge elements far from stock - not important)
         for (int i = 0; i < this[dir][prec].Length; i++)
         {
             this[dir][prec][i].Price  = source[dir][prec][i].Price;
             this[dir][prec][i].Volume = source[dir][prec][i].Volume;
         }
     }
 }
Exemplo n.º 5
0
        public bool CopyStocksBothDir(ref CSharedStocks source, int precision)
        {
            //2018-06-26 removed
            //if (source.Count != this.Count)
            //return false;


            bool bWasCopied = false;


            lock (source.Lck)
            {
                lock (this.Lck)
                {
                    try
                    {
                        CopyOneDirStock(Direction.Up, ref source, precision);
                        CopyOneDirStock(Direction.Down, ref source, precision);

                        UpdateBidAsk();

                        LstStockConf = new List <CStockConf>(source.LstStockConf);

                        //return true;
                        bWasCopied = true;

                        if (source.InpCmdStockChange[Direction.Up][precision] != null)
                        {
                            _queueCmdStockExch[Direction.Up][precision].Add(source.InpCmdStockChange[Direction.Up][precision]);
                        }

                        if (source.InpCmdStockChange[Direction.Down][precision] != null)
                        {
                            _queueCmdStockExch[Direction.Down][precision].Add(source.InpCmdStockChange[Direction.Down][precision]);
                        }
                    }
                    catch (Exception e)
                    {
                        //return false;
                        bWasCopied = false;
                    }
                }
            }

            return(bWasCopied);
        }
Exemplo n.º 6
0
        private bool OneDirStockIsDifferent(Direction dir, CSharedStocks stkToCompare)
        {
            foreach (var el in this[dir])
            {
                int prec = el.Key;
                for (int i = 0; i < stkToCompare.GetStockDepth(prec); i++)
                {
                    if (this[dir][prec][i].Price != stkToCompare[dir][prec][i].Price ||
                        this[dir][prec][i].Volume != stkToCompare[dir][prec][i].Volume)
                    {
                        return(true);
                    }
                }
            }



            return(false);
        }