Beispiel #1
0
        /// <summary>
        /// 更新委托回报。
        /// </summary>
        /// <param name="orderBook">委托回报。</param>
        /// <returns>更新委托回报条数。</returns>
        public OrderBookUpdateResult UpdateOrderBook(USeOrderBook orderBook)
        {
            for (int i = 0; i < m_orderBookList.Count; i++)
            {
                USeOrderBook orderBookItem = m_orderBookList[i];
                if (orderBookItem.OrderNum.Equals(orderBook.OrderNum))
                {
                    OrderBookUpdateResult result = GetOrderBookUpdateResult(m_orderBookList[i], orderBook);
                    m_orderBookList[i] = orderBook.Clone();
                    return(result);
                }
            }

            return(null);
        }
Beispiel #2
0
        public bool CanceledOrderActionReturn(USeOrderNum orderNum, bool isCancelSucceed)
        {
            if (isCancelSucceed == false)
            {
                return(false);
            }

            string error = "errorInfo";

            //Orderlist中找到OrderNum对应的单子删除
            if (orderNum == null)
            {
                return(false);
            }
            if (m_dataBuffer.OrderBookList.Count <= 0)
            {
                return(false);
            }
            USeOrderBook order_book = (from p in m_dataBuffer.OrderBookList
                                       where p.OrderNum.Equals(orderNum)
                                       select p).FirstOrDefault();

            if (order_book == null)
            {
                return(false);
            }

            if (order_book.TradeQty == order_book.OrderQty)
            {
                return(false);
            }

            if (order_book.TradeQty == 0)
            {
                order_book.OrderStatus = USeOrderStatus.AllCanceled;
                order_book.CancelQty   = order_book.OrderQty;
            }
            else
            {
                System.Diagnostics.Debug.Assert(order_book.TradeQty > 0);
                order_book.OrderStatus = USeOrderStatus.PartCanceled;
                order_book.CancelQty   = order_book.OrderQty - order_book.TradeQty;
            }

            m_pushOrderBookList.Enqueue(order_book.Clone());

            return(true);
        }
Beispiel #3
0
        public void AllTrade(USeOrderNum orderNum, int slipPoint)
        {
            USeOrderBook orderBook = (from p in m_dataBuffer.OrderBookList
                                      where p.OrderNum.Equals(orderNum)
                                      select p).FirstOrDefault();

            if (orderBook == null)
            {
                return;
            }

            USeInstrumentDetail instrumentDetail = QueryInstrumentDetail(orderBook.Instrument);

            int     tradeQty   = (orderBook.OrderQty - orderBook.TradeQty);
            decimal tradePrice = 0;

            if (orderBook.OrderSide == USeOrderSide.Buy)
            {
                tradePrice = orderBook.OrderPrice - instrumentDetail.PriceTick * slipPoint;
            }
            else if (orderBook.OrderSide == USeOrderSide.Sell)
            {
                tradePrice = orderBook.OrderPrice + instrumentDetail.PriceTick * slipPoint;
            }
            int volumeMultiple    = instrumentDetail.VolumeMultiple;
            int orderBookTradeQty = orderBook.TradeQty + tradeQty;

            orderBook.TradeQty    = orderBookTradeQty;
            orderBook.TradeAmount = tradePrice * orderBookTradeQty * volumeMultiple;
            orderBook.TradePrice  = tradePrice;
            orderBook.TradeFee    = 5 * orderBookTradeQty;
            orderBook.CancelQty   = 0;
            orderBook.Memo        = orderBook.Memo;
            orderBook.OrderTime   = DateTime.Now;
            orderBook.OrderStatus = USeOrderStatus.AllTraded;

            USeTradeBook tradeBook = CreateTradeBook(orderBook, tradeQty, tradePrice, tradeQty * tradePrice * volumeMultiple, 5 * tradeQty);

            USePosition positionBook = CreatePositionBook(tradeBook);

            m_pushTradeBookList.Enqueue(tradeBook);

            m_pushOrderBookList.Enqueue(orderBook.Clone());
            //推送持仓信息
            m_pushPositionList.Enqueue(positionBook.Clone());
        }