예제 #1
0
        public Market(string mnemonic, KTASimulator parent)
        {
            m_Parent = parent;
            m_Mnemonic = mnemonic;
            m_Product = parent.Facade.GetProductManager().GetProductMnemonic(mnemonic);

            m_OrderContextOrdID = new Dictionary<string, DriverBase.OrderContext>();
            m_OrderContextClOrdID = new Dictionary<string, DriverBase.OrderContext>();
            StartTimer();
        }
예제 #2
0
        private void fillOrder(DriverBase.OrderContext cntx)
        {
            try
            {
                if (m_Product == null)
                {
                    m_Product = m_Parent.Facade.GetProductManager().GetProductMnemonic(m_Mnemonic);
                    if (m_Product == null)
                    {
                        return;
                    }
                }

                IL1PX L1PX = m_Parent.Facade.PriceHandler.GetPXPublisher(m_Product) as IL1PX;

                if (cntx.OrderType == KaiTrade.Interfaces.OrderType.MARKET)
                {
                    if (cntx.Side == KaiTrade.Interfaces.Side.BUY)
                    {

                        fillOrder(cntx, L1PX.OfferSize.Value, L1PX.OfferPrice);

                    }
                    else if (cntx.Side == KaiTrade.Interfaces.Side.SELL)
                    {

                        fillOrder(cntx, L1PX.BidSize.Value, L1PX.BidPrice.Value);

                    }
                }
                else
                {
                    if (cntx.Side == KaiTrade.Interfaces.Side.BUY)
                    {
                        if (cntx.Price >= L1PX.OfferPrice.Value)
                        {
                            fillOrder(cntx, L1PX.OfferSize.Value, L1PX.OfferPrice);
                        }
                    }
                    else if (cntx.Side == KaiTrade.Interfaces.Side.SELL)
                    {
                        if (cntx.Price <= L1PX.BidPrice.Value)
                        {
                            fillOrder(cntx, L1PX.BidSize.Value, L1PX.BidPrice);
                        }
                    }
                    else
                    {
                    }
                }

            }
            catch (Exception myE)
            {
                m_Parent.Log.Error("fillOrder", myE);
            }
        }