示例#1
0
        public Message CreateNewOrderSingleMessage(string symbol,
                                                   MarketSide marketSide,
                                                   string clOrdID,
                                                   TradingAccount account,
                                                   decimal price,
                                                   decimal quantity,
                                                   OrderType orderType,
                                                   string execID)
        {
            var fOrdType      = TranslateFixFields.Translate(orderType);
            var fSide         = TranslateFixFields.Translate(marketSide);
            var fSymbol       = new Symbol(symbol);
            var fTransactTime = new TransactTime(DateTime.Now);
            var fClOrdID      = new ClOrdID(clOrdID);

            var nos = new NewOrderSingle(fClOrdID,
                                         fSymbol,
                                         fSide,
                                         fTransactTime,
                                         fOrdType)
            {
                OrderQty    = new OrderQty(quantity),
                TimeInForce = new TimeInForce(TimeInForce.GOOD_TILL_CANCEL)
            };

            if (orderType == OrderType.Limit)
            {
                nos.Price = new Price(price);
            }

            return(nos);
        }
        public static void PlaceNewSingleOrder()
        {
            QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle();

            #region Order Details

            QuickFix.OrderQty   orderQty = new QuickFix.OrderQty(10); order.setField(orderQty);
            QuickFix.Symbol     symbol   = new QuickFix.Symbol("EGS48031C016"); order.setField(symbol);
            QuickFix.SecurityID secID    = new QuickFix.SecurityID("EGS48031C016"); order.setField(secID);
            QuickFix.Side       side     = new QuickFix.Side(Side.SELL); order.setField(side);
            QuickFix.OrdType    ordType  = new QuickFix.OrdType(OrdType.LIMIT); order.setField(ordType);
            QuickFix.Price      price    = new QuickFix.Price(10); order.setField(price);
            Currency            currency = new Currency("EGP"); order.setField(currency);
            Account             acc      = new Account("1003"); order.setField(acc);
            QuickFix.PartyID    custody  = new PartyID("5004"); order.setField(custody);
            TimeInForce         tif      = new TimeInForce(TimeInForce.DAY); order.setField(tif);
            IDSource            ids      = new IDSource("4"); order.setField(ids);
            TransactTime        tt       = new TransactTime(DateTime.Now); order.setField(tt);
            //SenderSubID ss = new SenderSubID("05095a"); order.setField(ss);
            #endregion Order Details

            #region Fix Order Message IDs

            QuickFix.ClOrdID clOrdID = new ClOrdID(Guid.NewGuid().ToString());
            order.setField(clOrdID);

            #endregion Fix Order Message IDs

            #region Exchange
            ExDestination    exd         = new ExDestination("CA"); order.setField(exd);
            TradingSessionID tradSession = new TradingSessionID("NOPL"); order.setField(tradSession);
            #endregion Exchange

            Session.sendToTarget(order, _app.SessionID);
        }
示例#3
0
        //35 = D
        public override void onMessage(QuickFix42.NewOrderSingle message, SessionID sessionID)
        {
            Console.WriteLine("Receive message " + message.getHeader().getField(35) + ", session: " + sessionID.toString());
            try
            {
                ClOrdID      clordid = message.getClOrdID();
                string       clord   = clordid.getValue();
                Side         side    = message.getSide();
                char         s       = side.getValue();
                OrdType      ordtype = message.getOrdType();
                char         ord     = ordtype.getValue();
                TransactTime time    = message.getTransactTime();
                DateTime     dt      = time.getValue();

                QuickFix42.ExecutionReport executionReport = new QuickFix42.ExecutionReport(new OrderID("neworderid"), new ExecID("Hehe")
                                                                                            , new ExecTransType(ExecTransType.CORRECT), new ExecType(ExecType.NEW), new OrdStatus(OrdStatus.DONE_FOR_DAY),
                                                                                            new Symbol("VND"), new Side(Side.BUY), new LeavesQty(1), new CumQty(2), new AvgPx(100));

                bool x = Session.sendToTarget(executionReport, sessionID);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
示例#4
0
        public override string ToXml()
        {
            StringBuilder sb = new StringBuilder("<AlarmInfo>");

            try
            {
                sb.Append("<SystemContext>" + SystemContext.MonitorSystem.Name + "</SystemContext>");
                sb.Append("<ID>" + ID + "</ID>");
                sb.Append("<Sender>" + Sender + "</Sender>");

                IVisionMonitorConfig config = this.Monitor.Config as IVisionMonitorConfig;
                if (config != null)
                {
                    sb.Append("<VideoSource>" + config.VisionParamConfig.VSName + "</VideoSource>");
                }
                sb.Append("<AlarmType>" + (int)EventType + "</AlarmType>");
                sb.Append("<GuardLevel>" + (int)GuardLevel + "</GuardLevel>");
                sb.Append("<AreaIndex>" + AreaIndex + "</AreaIndex>");
                sb.Append("<AreaType>" + (int)AreaType + "</AreaType>");
                sb.Append("<AlertOpt>" + (int)AlertOpt + "</AlertOpt>");
                sb.Append("<AlarmTime>" + AlarmTime.ToString("yyyy-MM-dd HH:mm:ss") + "</AlarmTime>");
                sb.Append("<TransactTime>" + TransactTime.ToString("yyyy-MM-dd HH:mm:ss") + "</TransactTime>");
                sb.Append("<Transactor>" + Transactor + "</Transactor>");
            }
            finally
            {
                sb.Append("</AlarmInfo>");
            }
            return(sb.ToString());
        }
示例#5
0
        public void NewOrder(string clrID, char handinst, char sideID, char orderType, string symbolID, string exchange, float?price, long Quantity)
        {
            ClOrdID      clOrdID = new ClOrdID(clrID);
            HandlInst    inst    = new HandlInst('1');//似乎国信只支持直通私有
            Side         side    = new Side(sideID);
            OrdType      ordType = new OrdType(orderType);
            Symbol       symbol  = new Symbol(symbolID);
            TransactTime time    = new TransactTime();

            QuickFix42.NewOrderSingle message = new QuickFix42.NewOrderSingle(clOrdID, inst, symbol, side, time, ordType);
            message.setString(38, Quantity.ToString());
            if (ordType.getValue() == OrdType.LIMIT)
            {
                message.setString(44, price.Value.ToString());
            }
            message.setString(15, "CNY");
            if (exchange == "SH")
            {
                message.setString(207, "XSHG");
            }
            else if (exchange == "SZ")
            {
                message.setString(207, "XSHE");
            }
            SendToServer(message);
        }
示例#6
0
        //[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
        public static void PlaceNewSingleOrder(string _clOrderID, string _clientID, string _securityCode, int _quantity, double _price, string _custodyCode,
                                               char _orderSide, char _orderType, string currencyCode, string exDestination, char _timeInForce, string groupID,
                                               char handleInst, DateTime expiration, bool hasAON, int minQty)
        {
            QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle();

            #region Order Details

            QuickFix.OrderQty   orderQty = new QuickFix.OrderQty(_quantity); order.setField(orderQty);
            QuickFix.Symbol     symbol   = new QuickFix.Symbol(_securityCode); order.setField(symbol);
            QuickFix.SecurityID secID    = new QuickFix.SecurityID(_securityCode); order.setField(secID);
            QuickFix.Side       side     = new QuickFix.Side(_orderSide); order.setField(side);
            QuickFix.OrdType    ordType  = new QuickFix.OrdType(_orderType); order.setField(ordType);
            QuickFix.Price      price    = new QuickFix.Price(_price); order.setField(price);
            Currency            currency = new Currency(currencyCode); order.setField(currency);
            Account             acc      = new Account(_clientID); order.setField(acc);
            //QuickFix.ClearingFirm custody = new ClearingFirm(_custodyCode);order.setField(custody);
            QuickFix.PartyID custody = new PartyID(_custodyCode); order.setField(custody);
            //QuickFix.PartyRole pr = new PartyRole(PartyRole.CUSTODIAN); order.setField(pr);
            //QuickFix.NoPartyIDs npid = new NoPartyIDs(1); order.setField(npid);
            //QuickFix.PartyIDSource pid = new PartyIDSource(PartyIDSource.PROPRIETARY); order.setField(pid);
            TimeInForce  tif = new TimeInForce(_timeInForce); order.setField(tif);
            IDSource     ids = new IDSource("4"); order.setField(ids);
            TransactTime tt  = new TransactTime(DateTime.Now); order.setField(tt);
            //SenderSubID ss = new SenderSubID("05095a"); order.setField(ss);
            if (_timeInForce == QuickFix.TimeInForce.GOOD_TILL_DATE)
            {
                ExpireDate ed = new ExpireDate(expiration.ToString("yyyyMMdd")); order.setField(ed);
                //ExpireTime et = new ExpireTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour + 4, 0, 0)); order.setField(et);
                ExpireTime et = new ExpireTime(expiration); order.setField(et);
            }
            if (hasAON)
            {
                order.setField(new ExecInst(ExecInst.ALL_OR_NONE.ToString()));
                order.setField(new MinQty(minQty));
            }
            #endregion Order Details

            #region Fix Order Message IDs

            QuickFix.ClOrdID clOrdID = new QuickFix.ClOrdID(string.Format("{0}{1}", _wcfMsgPrefix, _clOrderID));
            order.setField(clOrdID);

            #endregion Fix Order Message IDs

            #region Reporting

            //QuickFix.HandlInst handlInst = new QuickFix.HandlInst(QuickFix.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION); order.setField(handlInst);
            QuickFix.HandlInst handlInst = new QuickFix.HandlInst(handleInst); order.setField(handlInst);

            #endregion Reporting

            #region Exchange

            ExDestination    exd         = new ExDestination(exDestination); order.setField(exd);
            TradingSessionID tradSession = new TradingSessionID(groupID); order.setField(tradSession);
            #endregion Exchange

            Session.sendToTarget(order, _sessionID);
        }
示例#7
0
        public void DateTimeFieldNanoTest()
        {
            fieldmap.SetField(new StringField(Tags.TransactTime, "20200309-20:53:10.643649215"));
            TransactTime tt = new TransactTime();

            fieldmap.GetField(tt);
            // Ticks resolution is 100 nanoseconds, so we lose the last 2 decimal points
            Assert.That(tt.Obj.Ticks, Is.EqualTo(637193839906436492));
        }
示例#8
0
        public Message NewOrder(MDEntryGroup entryGroup, double quantity)
        {
            bool isInvertedSecurity = entryGroup.OwnerEntry.IsInverted;
            Message message = null;
            Account account = new Account(GetOrderSession().getSenderCompID().ToLower());

            ClOrdID clOrdId = new ClOrdID("ClOrd_" + Guid.NewGuid());
            HandlInst handlInst = new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION);
            OrdType ordType = new OrdType(OrdType.LIMIT);
            TimeInForce timeInForce = new TimeInForce(TimeInForce.FILL_OR_KILL);
            TransactTime transactTime = new TransactTime();

            Price price = new Price(entryGroup.MDEntryPx);
            SecurityExchange securityExchange = new SecurityExchange(entryGroup.OwnerEntry.SecurityExchange);
            SecurityType securityType = new SecurityType(entryGroup.OwnerEntry.SecurityType);
            Symbol symbol = new Symbol(entryGroup.OwnerEntry.Symbol);
            SecurityID securityId = new SecurityID(entryGroup.OwnerEntry.SecurityID);
            OrderQty orderQty = new OrderQty(quantity);

            Side side = null;
            switch (entryGroup.MDEntryType)
            {
                case MDEntryType.BID:
                    side = new Side(Side.SELL);
                    break;
                case MDEntryType.OFFER:
                    side = new Side(Side.BUY);
                    break;
                default:
                    throw new Exception("Undefined entry type.");
            }

            //if (isInvertedSecurity && side.getValue() == Side.BUY)
            //    price = new Price(-price.getValue());

            message = new QuickFix42.NewOrderSingle();

            ((QuickFix42.NewOrderSingle) message).set(account);

            ((QuickFix42.NewOrderSingle) message).set(clOrdId);
            ((QuickFix42.NewOrderSingle) message).set(side);
            ((QuickFix42.NewOrderSingle) message).set(transactTime);
            ((QuickFix42.NewOrderSingle) message).set(ordType);

            ((QuickFix42.NewOrderSingle) message).set(price);
            ((QuickFix42.NewOrderSingle) message).set(orderQty);
            ((QuickFix42.NewOrderSingle) message).set(securityId);
            ((QuickFix42.NewOrderSingle) message).set(securityExchange);
            ((QuickFix42.NewOrderSingle) message).set(timeInForce);

            ((QuickFix42.NewOrderSingle) message).set(securityType);

            return message;
        }
示例#9
0
        public void DateTimeFieldTest()
        {
            fieldmap.SetField(new DateTimeField(Tags.TransactTime, new DateTime(2009, 12, 10)));
            TransactTime tt = new TransactTime();

            fieldmap.GetField(tt);
            Assert.That(new DateTime(2009, 12, 10), Is.EqualTo(tt.Obj));
            fieldmap.SetField(new TransactTime(new DateTime(2010, 12, 10)));
            fieldmap.GetField(tt);
            Assert.That(new DateTime(2010, 12, 10), Is.EqualTo(tt.getValue()));
        }
示例#10
0
        public void CancelOrder(string oriID, string clrID, char sideID, string symbolID)
        {
            OrigClOrdID  origClOrdID = new OrigClOrdID(oriID);
            ClOrdID      clOrdID     = new ClOrdID(clrID);
            Side         side        = new Side(sideID);
            Symbol       symbol      = new Symbol(symbolID);
            TransactTime time        = new TransactTime();

            QuickFix42.OrderCancelRequest message = new QuickFix42.OrderCancelRequest(origClOrdID, clOrdID, symbol, side, time);
            message.setInt(38, 0);//委托数量,这里不设置竟无法撤单。
            SendToServer(message);
        }
示例#11
0
        public QuickFix42.OrderCancelRequest GenerateCancelRequest(string clOrdId, int index)
        {
            string originalId = (string)LimitOrders[index];

            QuickFix42.Message msg = Msgs[originalId];


            //check for a recent ID
            string temp = LimitLib.GetRecentId(originalId);

            if (temp != null)
            {
                //limitLib.add(originalID, clOrdId);  //associate new Id
                originalId = temp;                  //send with most recent from previous request
            }

            Side oldSide = new Side();

            msg.getField(oldSide);

            TransactTime uTime = new TransactTime();

            msg.getField(uTime);

            QuickFix42.OrderCancelRequest ocr = new QuickFix42.OrderCancelRequest(
                new OrigClOrdID(originalId),
                new ClOrdID(clOrdId),
                new Symbol(msg.getField(Symbol.FIELD)),                                         //Necessary Field for canceling child orders
                oldSide,                                                                        //Necessary Field for canceling child orders
                uTime);

            OrderID oid = new OrderID("x");

            ocr.setField(oid);

            //Neccessary Field for canceling child orders
            Price limitPrice = new Price();

            msg.getField(limitPrice);
            //OCR.setField(limitPrice);

            ocr.setField(57, msg.getField(57));
            ocr.setField(9102, msg.getField(9102));

            return(ocr);
        }
示例#12
0
        public QuickFix42.OrderCancelRequest GenerateManualCancelRequest(string clOrdId, string originalId, string symbol, string side, double price, string route = "NEFAN", string channel = "X")
        {
            //QuickFix42.Message msg = MSGS[(string)LimitOrders[index]];
            Side sd = new Side(Side.BUY);

            if (side.Equals("B") || side.Equals("b") || side.Equals("buy") || side.Equals("BUY"))
            {
                sd = new Side(Side.BUY);
            }
            else if (side.Equals("S") || side.Equals("s") || side.Equals("sell") || side.Equals("SELL"))
            {
                sd = new Side(Side.SELL);
            }
            else if (side.Equals("SS") || side.Equals("ss") || side.Equals("ssell") || side.Equals("SSELL") || side.Equals("SHORT") || side.Equals("short"))
            {
                sd = new Side(Side.SELL_SHORT);
            }

            TransactTime uTime = new TransactTime(DateTime.Parse("20110708 15:24:26"));

            //msg.getField(uTime);

            QuickFix42.OrderCancelRequest ocr = new QuickFix42.OrderCancelRequest(
                new OrigClOrdID(originalId),
                new ClOrdID(clOrdId),
                new Symbol(symbol), //Necessary Field for canceling child orders
                sd,                 //Necessary Field for canceling child orders
                uTime);

            OrderID oid = new OrderID("x");

            ocr.setField(oid);

            //Neccessary Field for canceling child orders
            Price limitPrice = new Price(price);

            //msg.getField(limitPrice);
            ocr.setField(limitPrice);

            ocr.setField(57, "ALGO1");
            ocr.setField(9102, "T");

            return(ocr);
        }
示例#13
0
        public virtual string ToXml()
        {
            StringBuilder sb = new StringBuilder("<AlarmInfo>");

            try
            {
                sb.Append("<SystemContext>" + SystemContext.MonitorSystem.Name + "</SystemContext>");
                sb.Append("<ID>" + ID + "</ID>");
                sb.Append("<Sender>" + Sender + "</Sender>");
                sb.Append("<AlarmTime>" + AlarmTime.ToString("yyyy-MM-dd HH:mm:ss") + "</AlarmTime>");
                sb.Append("<TransactTime>" + TransactTime.ToString("yyyy-MM-dd HH:mm:ss") + "</TransactTime>");
                sb.Append("<Transactor>" + Transactor + "</Transactor>");
            }
            finally
            {
                sb.Append("</AlarmInfo>");
            }
            return(sb.ToString());
        }
示例#14
0
        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new System.Text.StringBuilder();

            sb.Append("class OrderResponse {\n");
            sb.Append("  OrderID: ").Append(OrderId.ToString()).Append("\n");
            sb.Append("  ClOrdID: ").Append(ClOrdId.ToString()).Append("\n");
            sb.Append("  ClOrdLinkID: ").Append(ClOrdLinkId.ToString()).Append("\n");
            sb.Append("  Account: ").Append(Account.ToString()).Append("\n");
            sb.Append("  Symbol: ").Append(Symbol.ToString()).Append("\n");
            sb.Append("  Side: ").Append(Side.ToString()).Append("\n");
            sb.Append("  OrderQty: ").Append(OrderQty.ToString()).Append("\n");
            sb.Append("  Price: ").Append(Price.ToString()).Append("\n");
            sb.Append("  DisplayQty: ").Append((DisplayQty == null) ? "null" : DisplayQty.ToString()).Append("\n");
            sb.Append("  StopPx: ").Append((StopPx == null) ? "null" : StopPx.ToString()).Append("\n");
            sb.Append("  PegOffsetValue: ").Append((PegOffsetValue == null) ? "null" : PegOffsetValue.ToString()).Append("\n");
            sb.Append("  PegPriceType: ").Append((PegPriceType == null) ? "null" : PegPriceType.ToString()).Append("\n");
            sb.Append("  Currency: ").Append((Currency == null) ? "null" : Currency.ToString()).Append("\n");
            sb.Append("  SettlCurrency: ").Append((SettlCurrency == null) ? "null" : SettlCurrency.ToString()).Append("\n");
            sb.Append("  OrdType: ").Append((OrdType == null) ? "null" : OrdType.ToString()).Append("\n");
            sb.Append("  TimeInForce: ").Append((TimeInForce == null) ? "null" : TimeInForce.ToString()).Append("\n");
            sb.Append("  ExecInst: ").Append((ExecInst == null) ? "null" : ExecInst.ToString()).Append("\n");
            sb.Append("  ContingencyType: ").Append((ContingencyType == null) ? "null" : ContingencyType.ToString()).Append("\n");
            sb.Append("  ExDestination: ").Append((ExDestination == null) ? "null" : ExDestination.ToString()).Append("\n");
            sb.Append("  OrdStatus: ").Append((OrdStatus == null) ? "null" : OrdStatus.ToString()).Append("\n");
            sb.Append("  Triggered: ").Append((Triggered == null) ? "null" : Triggered.ToString()).Append("\n");
            sb.Append("  WorkingIndicator: ").Append((WorkingIndicator == null) ? "null" : WorkingIndicator.ToString()).Append("\n");
            sb.Append("  OrdRejReason: ").Append((OrdRejReason == null) ? "null" : OrdRejReason.ToString()).Append("\n");
            sb.Append("  LeavesQty: ").Append((LeavesQty == null) ? "null" : LeavesQty.ToString()).Append("\n");
            sb.Append("  CumQty: ").Append((CumQty == null) ? "null" : CumQty.ToString()).Append("\n");
            sb.Append("  AvgPx: ").Append((AvgPx == null) ? "null" : AvgPx.ToString()).Append("\n");
            sb.Append("  MultiLegReportingType: ").Append((MultiLegReportingType == null) ? "null" : MultiLegReportingType.ToString()).Append("\n");
            sb.Append("  Text: ").Append((Text == null) ? "null" : Text.ToString()).Append("\n");
            sb.Append("  TransactTime: ").Append(TransactTime.ToString()).Append("\n");
            sb.Append("  Timestamp: ").Append(Timestamp.ToString()).Append("\n");
            sb.Append("}\n");
            return(sb.ToString());
        }
示例#15
0
        private Queue <QuickFix.FIX42.NewOrderSingle> CreateOrders(int n)
        {
            Queue <QuickFix.FIX42.NewOrderSingle> orders = new Queue <QuickFix.FIX42.NewOrderSingle>(n);

            for (int i = 0; i < n; i++)
            {
                ClOrdID      cloudOrderId           = new ClOrdID(Guid.NewGuid().ToString());
                HandlInst    handlInst              = new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION);
                Symbol       symbol                 = new Symbol("MSFT");
                Side         side                   = new Side(Side.BUY);
                TransactTime time                   = new TransactTime();
                OrdType      orderType              = new OrdType(OrdType.LIMIT);
                QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle(cloudOrderId, handlInst, symbol, side, time, orderType);
                order.Account       = new Account("Account");
                order.OrderQty      = new OrderQty(100);
                order.ExDestination = new ExDestination("*");
                order.TimeInForce   = new TimeInForce(TimeInForce.DAY);
                order.Price         = new Price(50m);
                order.SecurityType  = new SecurityType(SecurityType.COMMON_STOCK);
                orders.Enqueue(order);
            }
            return(orders);
        }
示例#16
0
 public void MergeFrom(OrderMessage other)
 {
     if (other == null)
     {
         return;
     }
     if (other.OrderId.Length != 0)
     {
         OrderId = other.OrderId;
     }
     if (other.ClinetOrderId.Length != 0)
     {
         ClinetOrderId = other.ClinetOrderId;
     }
     if (other.ClinetOrderLinkId.Length != 0)
     {
         ClinetOrderLinkId = other.ClinetOrderLinkId;
     }
     if (other.Side != 0)
     {
         Side = other.Side;
     }
     if (other.SimpleOrderQuantity != 0D)
     {
         SimpleOrderQuantity = other.SimpleOrderQuantity;
     }
     if (other.OrderQuantity != 0D)
     {
         OrderQuantity = other.OrderQuantity;
     }
     if (other.Price != 0D)
     {
         Price = other.Price;
     }
     if (other.DisplayQuantity != 0D)
     {
         DisplayQuantity = other.DisplayQuantity;
     }
     if (other.StopPrice != 0D)
     {
         StopPrice = other.StopPrice;
     }
     if (other.PegOffsetValue != 0D)
     {
         PegOffsetValue = other.PegOffsetValue;
     }
     if (other.PegPriceType.Length != 0)
     {
         PegPriceType = other.PegPriceType;
     }
     if (other.OrderType != 0)
     {
         OrderType = other.OrderType;
     }
     if (other.TimeInForce != 0)
     {
         TimeInForce = other.TimeInForce;
     }
     if (other.ExecutionInstruction.Length != 0)
     {
         ExecutionInstruction = other.ExecutionInstruction;
     }
     if (other.OrderStatus != 0)
     {
         OrderStatus = other.OrderStatus;
     }
     if (other.SimpleLeavesQuantity != 0D)
     {
         SimpleLeavesQuantity = other.SimpleLeavesQuantity;
     }
     if (other.LeavesQuantity != 0D)
     {
         LeavesQuantity = other.LeavesQuantity;
     }
     if (other.AveragePrice != 0D)
     {
         AveragePrice = other.AveragePrice;
     }
     if (other.Text.Length != 0)
     {
         Text = other.Text;
     }
     if (other.transactTime_ != null)
     {
         if (transactTime_ == null)
         {
             TransactTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
         }
         TransactTime.MergeFrom(other.TransactTime);
     }
     if (other.timestamp_ != null)
     {
         if (timestamp_ == null)
         {
             Timestamp = new global::Google.Protobuf.WellKnownTypes.Timestamp();
         }
         Timestamp.MergeFrom(other.Timestamp);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
示例#17
0
        public QuickFix42.OrderCancelReplaceRequest GenerateReplaceRequest(string clOrdId, int qty, double limitPx, double stopPx, int index)
        {
            string originalId = (string)LimitOrders[index];

            QuickFix42.Message msg = Msgs[originalId];


            //check for a recent ID
            string temp = LimitLib.GetRecentId(originalId);

            if (temp != null)
            {
                LimitLib.Add(originalId, clOrdId);  //associate new Id
                originalId = temp;                  //send with most recent from previous request
            }
            else
            {
                LimitLib.Add(originalId, clOrdId);
            }

            Side oldSide = new Side();

            msg.getField(oldSide);

            TransactTime uTime = new TransactTime();

            msg.getField(uTime);

            QuickFix42.OrderCancelReplaceRequest ocrr = new QuickFix42.OrderCancelReplaceRequest(
                new OrigClOrdID(originalId),
                new ClOrdID(clOrdId),
                new HandlInst('1'),
                new Symbol(msg.getField(Symbol.FIELD)),
                oldSide,
                uTime,
                new OrdType(OrdType.LIMIT));

            // Update prices and quantity
            ocrr.set(limitPx > 0 ? new Price(limitPx) : new Price(double.Parse(msg.getField(Price.FIELD))));

            if (stopPx > 0) // If the user specified a new stop price
            {
                ocrr.set(new StopPx(stopPx));
            }
            else
            { // Otherwise use the original stop price
                StopPx spx = new StopPx();
                if (msg.isSetField(spx))
                {
                    msg.getField(spx);
                    ocrr.set(spx);
                }
                else
                {
                    msg.setField(spx);
                }
            }

            ocrr.set(qty > 0 ? new OrderQty(qty) : new OrderQty(int.Parse(msg.getField(OrderQty.FIELD))));

            OrderID oid = new OrderID("x");

            ocrr.setField(oid);
            ocrr.setField(57, msg.getField(57));
            ocrr.setField(9102, msg.getField(9102));

            return(ocrr);
        }
示例#18
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (Price != 0F)
        {
            hash ^= Price.GetHashCode();
        }
        if (Date.Length != 0)
        {
            hash ^= Date.GetHashCode();
        }
        if (Datetime.Length != 0)
        {
            hash ^= Datetime.GetHashCode();
        }
        if (SendingTime.Length != 0)
        {
            hash ^= SendingTime.GetHashCode();
        }
        if (TransactTime.Length != 0)
        {
            hash ^= TransactTime.GetHashCode();
        }
        if (Amount != 0F)
        {
            hash ^= Amount.GetHashCode();
        }
        if (Towards != 0L)
        {
            hash ^= Towards.GetHashCode();
        }
        if (Code.Length != 0)
        {
            hash ^= Code.GetHashCode();
        }
        if (User.Length != 0)
        {
            hash ^= User.GetHashCode();
        }
        if (Strategy.Length != 0)
        {
            hash ^= Strategy.GetHashCode();
        }
        if (Type.Length != 0)
        {
            hash ^= Type.GetHashCode();
        }
        if (BidModel.Length != 0)
        {
            hash ^= BidModel.GetHashCode();
        }
        if (AmountModel.Length != 0)
        {
            hash ^= AmountModel.GetHashCode();
        }
        if (OrderId.Length != 0)
        {
            hash ^= OrderId.GetHashCode();
        }
        if (TradeId.Length != 0)
        {
            hash ^= TradeId.GetHashCode();
        }
        if (Status.Length != 0)
        {
            hash ^= Status.GetHashCode();
        }
        return(hash);
    }
示例#19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (OrderId.Length != 0)
            {
                hash ^= OrderId.GetHashCode();
            }
            if (ClinetOrderId.Length != 0)
            {
                hash ^= ClinetOrderId.GetHashCode();
            }
            if (ClinetOrderLinkId.Length != 0)
            {
                hash ^= ClinetOrderLinkId.GetHashCode();
            }
            if (Side != 0)
            {
                hash ^= Side.GetHashCode();
            }
            if (SimpleOrderQuantity != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SimpleOrderQuantity);
            }
            if (OrderQuantity != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(OrderQuantity);
            }
            if (Price != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Price);
            }
            if (DisplayQuantity != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DisplayQuantity);
            }
            if (StopPrice != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(StopPrice);
            }
            if (PegOffsetValue != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(PegOffsetValue);
            }
            if (PegPriceType.Length != 0)
            {
                hash ^= PegPriceType.GetHashCode();
            }
            if (OrderType != 0)
            {
                hash ^= OrderType.GetHashCode();
            }
            if (TimeInForce != 0)
            {
                hash ^= TimeInForce.GetHashCode();
            }
            if (ExecutionInstruction.Length != 0)
            {
                hash ^= ExecutionInstruction.GetHashCode();
            }
            if (OrderStatus != 0)
            {
                hash ^= OrderStatus.GetHashCode();
            }
            if (SimpleLeavesQuantity != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(SimpleLeavesQuantity);
            }
            if (LeavesQuantity != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(LeavesQuantity);
            }
            if (AveragePrice != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(AveragePrice);
            }
            if (Text.Length != 0)
            {
                hash ^= Text.GetHashCode();
            }
            if (transactTime_ != null)
            {
                hash ^= TransactTime.GetHashCode();
            }
            if (timestamp_ != null)
            {
                hash ^= Timestamp.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#20
0
 private void CancelOrder(string id)
 {
     if (id != null)
     {
         if (ordersAll.ContainsKey(id))
         {
             OrigClOrdID orig = new OrigClOrdID(id);
             OrderInfo info = (OrderInfo)ordersAll[id];
             ClOrdID clordid = new ClOrdID(GetNextID());
             Symbol symbol=info.Order .getSymbol ();
             QuickFix.Side side = info.Order.getSide();
             TransactTime time = new TransactTime();
             QuickFix42.OrderCancelRequest cxl = new OrderCancelRequest(orig ,clordid ,symbol ,side,time);
             _quickFixWrapper.Send(cxl);
         }
     }
 }