Example #1
0
        public override void Init(TextCommon t)
        {
            base.Init(t);

            TextQuote q = t as TextQuote;
            QuoteID = q.QuoteID;
            StayTime = q.StayTime;
        }
Example #2
0
        public override void Add(SingleOrder order, TextCommon t)
        {
            if (Index >= GetLegNum())
                return;

            Leg[Index] = new MultiOrderLeg { Order = order, OpenClose = t.OpenClose };
            ++Index;
        }
        public override void OnStrategyStart()
        {
            base.OnStrategyStart();

            TargetOrderBook = new OrderBook_BothSide_Size();
            TargetOrderBook.Sell.PriceHelper = base.PriceHelper;
            TargetOrderBook.Buy.PriceHelper = base.PriceHelper;
            TextParameterAsk = new TextCommon() { OpenClose = EnumOpenClose.OPEN };
            TextParameterBid = new TextCommon() { OpenClose = EnumOpenClose.OPEN };
        }
Example #4
0
 public override void Add(SingleOrder order, TextCommon t)
 {
     if (order.Side == Side.Buy)
     {
         Buy = new MultiOrderLeg() { Order = order, OpenClose = t.OpenClose };
     }
     else
     {
         Sell = new MultiOrderLeg() { Order = order, OpenClose = t.OpenClose };
     }
 }
        private void Send(NewOrderSingle order)
        {
            if (!_bTdConnected)
            {
                EmitError(-1, -1, "交易服务器没有连接,无法报单");
                tdlog.Error("交易服务器没有连接,无法报单");
                return;
            }

            // 表示特殊的Json格式
            if (order.Text.StartsWith("{") && order.Text.EndsWith("}"))
            {
                TextParameter parameter = JsonConvert.DeserializeObject<TextParameter>(order.Text);
                switch (parameter.Type)
                {
                    case EnumGroupType.COMMON:
                        {
                            TextCommon t = JsonConvert.DeserializeObject<TextCommon>(order.Text);
                            CommonOrderItem item = CommonOrderCombiner.Add(order as SingleOrder, t);
                            Send(item);
                        }
                        break;
                    case EnumGroupType.QUOTE:
                        {
                            TextQuote t = JsonConvert.DeserializeObject<TextQuote>(order.Text);
                            QuoteOrderItem item = QuoteOrderCombiner.Add(order as SingleOrder, t);
                        }
                        break;
                    case EnumGroupType.SP:
                        {
                            TextSP t = JsonConvert.DeserializeObject<TextSP>(order.Text);
                            SPOrderItem item = SPOrderCombiner.Add(order as SingleOrder, t);
                            Send(item);
                        }
                        break;
                    case EnumGroupType.SPC:
                        {
                            TextSPC t = JsonConvert.DeserializeObject<TextSPC>(order.Text);
                            SPCOrderItem item = SPCOrderCombiner.Add(order as SingleOrder, t);
                            Send(item);
                        }
                        break;
                    case EnumGroupType.SPD:
                        {
                            TextSPD t = JsonConvert.DeserializeObject<TextSPD>(order.Text);
                            SPDOrderItem item = SPDOrderCombiner.Add(order as SingleOrder, t);
                            Send(item);
                        }
                        break;
                }
            }
            else
            {
                // 无法识别的格式,直接发送报单,只开仓
                TextCommon t = new TextCommon()
                {
                    Type = EnumGroupType.COMMON,
                    OpenClose = EnumOpenClose.OPEN
                };
                CommonOrderItem item = CommonOrderCombiner.Add(order as SingleOrder, t);
                Send(item);
            }
        }
 public override void Add(SingleOrder order, TextCommon t)
 {
     Leg = new MultiOrderLeg { Order = order, OpenClose = t.OpenClose };
 }
 public override void Init(TextCommon t)
 {
     base.Init(t);
     Leg = null;
 }
        public override void OnStrategyStart()
        {
            TimeHelper = new TimeHelper(Instrument.Symbol);
            PriceHelper = new PriceHelper(Instrument.TickSize);
            TextParameter = new TextCommon() { OpenClose = EnumOpenClose.OPEN };
            CloseTodayHelper = new CloseTodayHelper(EnumExchangeID.SHFE);

            DualPosition = new DualPosition(Instrument.Symbol);
            DualPosition.Sell.PriceHelper = PriceHelper;
            DualPosition.Buy.PriceHelper = PriceHelper;
            DualPosition.CloseTodayHelper = CloseTodayHelper;

            TargetPosition = 0;
            DualPosition.Long.Qty = 0;
            DualPosition.Long.QtyToday = 0;
            DualPosition.Short.Qty = 0;
            DualPosition.Short.QtyToday = 0;
        }
Example #9
0
 public override void Init(TextCommon t)
 {
     base.Init(t);
     Index = 0;
 }
 public virtual void Add(SingleOrder order, TextCommon t)
 {
 }
 public virtual void Init(TextCommon t)
 {
     TextRequest = t;
 }