コード例 #1
0
        private bool UpdateToTodayBuyList(int index, bool IsInsert, StackTradeUnit buyUnit)
        {
            lock (_lock)
            {
                this.DailyInfo.DelegateBuyStoneSum += buyUnit.TradeStoneHandCount;

                if (IsInsert)
                {
                    BuyOrderPriceCountList.Insert(index, new StackTradeUnit()
                    {
                        Price = buyUnit.Price,
                        TradeStoneHandCount = buyUnit.TradeStoneHandCount
                    });
                }
                else
                {
                    if (BuyOrderPriceCountList[index] == null)
                    {
                        BuyOrderPriceCountList[index] = new StackTradeUnit()
                        {
                            Price = buyUnit.Price,
                            TradeStoneHandCount = buyUnit.TradeStoneHandCount
                        };
                    }
                    else
                    {
                        BuyOrderPriceCountList[index].TradeStoneHandCount += buyUnit.TradeStoneHandCount;
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        private bool UpdateToTodaySellList(int index, bool IsInsert, StackTradeUnit sellUnit)
        {
            lock (_lock)
            {
                this.DailyInfo.DelegateSellStoneSum += sellUnit.TradeStoneHandCount;

                if (IsInsert)
                {
                    SellOrderPriceCountList.Insert(index, new StackTradeUnit()
                    {
                        Price = sellUnit.Price,
                        TradeStoneHandCount = sellUnit.TradeStoneHandCount
                    });
                }
                else
                {
                    if (SellOrderPriceCountList[index] == null)
                    {
                        SellOrderPriceCountList[index] = new StackTradeUnit()
                        {
                            Price = sellUnit.Price,
                            TradeStoneHandCount = sellUnit.TradeStoneHandCount
                        };
                    }
                    else
                    {
                        SellOrderPriceCountList[index].TradeStoneHandCount += sellUnit.TradeStoneHandCount;
                    }
                }
            }
            return(true);
        }
コード例 #3
0
        public OperResultObject DeleteBuyUnit(StackTradeUnit buyUnit)
        {
            OperResultObject result = new OperResultObject();

            lock (_lock)
            {
                for (int i = 0; i < this.BuyOrderPriceCountList.Count; i++)
                {
                    var priceUnit = this.BuyOrderPriceCountList[i];
                    if (priceUnit != null)
                    {
                        if (priceUnit.Price == buyUnit.Price)
                        {
                            if (priceUnit.TradeStoneHandCount < buyUnit.TradeStoneHandCount)
                            {
                                result.OperResultCode = OperResult.RESULTCODE_STACK_CANCELORDER_FAILED_TOTALHANDCOUNTERROR;
                            }
                            else
                            {
                                priceUnit.TradeStoneHandCount -= buyUnit.TradeStoneHandCount;
                                result.OperResultCode          = OperResult.RESULTCODE_TRUE;
                            }

                            if (priceUnit.TradeStoneHandCount == 0)
                            {
                                this.BuyOrderPriceCountList.RemoveAt(i);
                            }
                            break;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #4
0
        public int InsertBuyUnit(StackTradeUnit buyUnit)
        {
            bool isInsert = false;
            int  index    = CheckinBuyListIndex(buyUnit.Price, out isInsert);

            if (index >= 0)
            {
                UpdateToTodayBuyList(index, isInsert, buyUnit);
            }

            return(index);
        }
コード例 #5
0
        public int InsertSellUnit(StackTradeUnit sellUnit)
        {
            bool isInsert = false;
            int  index    = CheckinSellListIndex(sellUnit.Price, out isInsert);

            if (index >= 0)
            {
                UpdateToTodaySellList(index, isInsert, sellUnit);
            }

            return(index);
        }