예제 #1
0
        internal DeferredAutoFillInfo Add(Transaction tran)
        {
            var order = tran.FirstOrder;
            var isBuy = order.IsBuy;
            var price = order.SetPrice;
            DeferredAutoFillInfo entity = new DeferredAutoFillInfo(isBuy, price, tran);

            this.InnerAdd(entity, tran.InstrumentId);
            return(entity);
        }
예제 #2
0
        private List <OrderPriceInfo> GetPricesForBO(DeferredAutoFillInfo item)
        {
            Price buyPrice  = null;
            Price sellPrice = null;
            var   tran      = item.Transaction;
            var   order     = tran.FirstOrder;

            if (order.BestPrice != null)
            {
                buyPrice = sellPrice = order.BestPrice;
            }
            else
            {
                var quotation = tran.AccountInstrument.GetQuotation(tran.SubmitorQuotePolicyProvider);
                buyPrice  = quotation.BuyPrice;
                sellPrice = quotation.SellPrice;
            }
            return(this.CreateOrderPriceInfos(tran, buyPrice, sellPrice));
        }
예제 #3
0
        private List <OrderPriceInfo> GetBuySellPrice(DeferredAutoFillInfo item)
        {
            List <OrderPriceInfo> result = new List <OrderPriceInfo>();
            var tran = item.Transaction;

            foreach (var eachOrder in tran.Orders)
            {
                Price buyPrice = null, sellPrice = null;
                if (eachOrder.IsBuy)
                {
                    this.SetPrice(ref buyPrice, tran, eachOrder);
                }
                else
                {
                    this.SetPrice(ref sellPrice, tran, eachOrder);
                }
                result.Add(new OrderPriceInfo(eachOrder.Id, buyPrice, sellPrice));
            }
            return(result);
        }
예제 #4
0
        private void InnerAdd(DeferredAutoFillInfo item, Guid instrumentId)
        {
            lock (_mutex)
            {
                List <DeferredAutoFillInfo> autoFillEntities = null;
                if (!_deferredAutoFillEntitiesDict.TryGetValue(instrumentId, out autoFillEntities))
                {
                    autoFillEntities = new List <DeferredAutoFillInfo>(AUTO_FILL_ENTITY_LIST_LOAD_FACTOR);
                    _deferredAutoFillEntitiesDict.Add(instrumentId, autoFillEntities);
                }

                Logger.InfoFormat("tranID = {0}, isValid ={1}", item.Transaction.Id, item.IsValid);

                if (item.IsValid)
                {
                    autoFillEntities.Add(item);
                }
                else
                {
                    TransactionExpireChecker.Default.Add(item.Transaction);
                }
            }
        }
예제 #5
0
        internal void CancelInvalidAutoFillTransaction(DeferredAutoFillInfo entity, int dealay = 0)
        {
            Action action = () =>
            {
                if (dealay > 0)
                {
                    Thread.Sleep(dealay);
                }
                try
                {
                    iExchangeEngine.Default.Cancel(entity.Transaction, CancelReason.OtherReason);
                }
                catch (TransactionServerException tranException)
                {
                    Logger.Warn(tranException.ToString());
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }
            };

            Task.Factory.StartNew(action);
        }