示例#1
0
        private static void BuildOrderMessage(Order orderToSend)
        {
            LegacyOrderReq orderReq = new LegacyOrderReq();//TODO: Map from orderToSend!!

            orderReq.AccountId    = orderToSend.Account;
            orderReq.ClOrderId    = orderToSend.ClOrdId;
            orderReq.InstrumentId = orderToSend.Symbol;
            orderReq.Msg          = "LegacyOrderReq";
            orderReq.cOrderType   = orderToSend.OrdType == OrdType.Limit ? LegacyOrderReq._ORD_TYPE_LIMIT : LegacyOrderReq._ORD_TYPE_MARKET;
            orderReq.Price        = orderToSend.Price.HasValue ? (decimal?)Convert.ToDecimal(orderToSend.Price.Value) : null;
            orderReq.Quantity     = Convert.ToDecimal(orderToSend.OrderQty);
            orderReq.cSide        = orderToSend.Side == Side.Buy ? LegacyOrderReq._SIDE_BUY : LegacyOrderReq._SIDE_SELL;
            orderReq.cTimeInForce = LegacyOrderReq._TIF_DAY;
            orderReq.UserId       = ClientLoginResponse.UserId;
            orderReq.JsonWebToken = ClientLoginResponse.JsonWebToken;


            string strLegacyOrderReq = JsonConvert.SerializeObject(orderReq, Newtonsoft.Json.Formatting.None,
                                                                   new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            DoSend(strLegacyOrderReq);
        }
示例#2
0
        private static void ProcessRouteOrder(string[] param)
        {
            if (JWTToken == null)
            {
                DoLog("Missing authentication token in memory!. User not logged");
                return;
            }

            if (param.Length >= 1)
            {
                LegacyOrderReq legacyOrdReq = CreateNewOrder(param);

                string strMsg = JsonConvert.SerializeObject(legacyOrdReq, Newtonsoft.Json.Formatting.None,
                                                            new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });

                DoSend(strMsg);
            }
            else
            {
                DoLog(string.Format("Missing mandatory parameters for LegacyOrderReq message"));
            }
        }
示例#3
0
        private static void ProcessRouteAndCancelOrder(string[] param)
        {
            if (JWTToken == null)
            {
                DoLog("Missing authentication token in memory!. User not logged");
                return;
            }

            if (param.Length >= 1)
            {
                LegacyOrderReq legacyOrdReq = CreateNewOrder(param);

                string strMsg = JsonConvert.SerializeObject(legacyOrdReq, Newtonsoft.Json.Formatting.None,
                                                            new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });

                DoSend(strMsg);

                Thread.Sleep(5000);

                LegacyOrderCancelReq legacyOrderCancelReq = new LegacyOrderCancelReq();
                legacyOrderCancelReq.ClOrderId     = BuildClOrdId();
                legacyOrderCancelReq.OrigClOrderId = legacyOrdReq.ClOrderId;
                //legacyOrderCancelReq.OrigClOrderId = "xxx";
                legacyOrderCancelReq.Msg          = "LegacyOrderCancelReq";
                legacyOrderCancelReq.JsonWebToken = legacyOrdReq.JsonWebToken;
                legacyOrderCancelReq.Sender       = legacyOrdReq.Sender;
                legacyOrderCancelReq.Side         = legacyOrdReq.Side;
                legacyOrderCancelReq.UserId       = legacyOrdReq.UserId;
                legacyOrderCancelReq.InstrumentId = legacyOrdReq.InstrumentId;


                string strCancelMsg = JsonConvert.SerializeObject(legacyOrderCancelReq, Newtonsoft.Json.Formatting.None,
                                                                  new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });

                DoSend(strCancelMsg);
            }
            else
            {
                DoLog(string.Format("Missing mandatory parameters for LegacyOrderReq message"));
            }
        }
示例#4
0
        private static LegacyOrderReq CreateNewOrder(string[] param)
        {
            LegacyOrderReq legacyOrdReq = new LegacyOrderReq()
            {
                Msg          = "LegacyOrderReq",
                Sender       = 0,
                JsonWebToken = JWTToken,
                UserId       = UserId,
                ClOrderId    = BuildClOrdId(),
                AccountId    = param.Length >= 2 && param[1].Trim() != "" ? param[1] : "VIRT_STD_ACCT1",
                InstrumentId = ConfigurationManager.AppSettings["OrderSymbol"],
                Price        = Convert.ToDecimal(ConfigurationManager.AppSettings["OrderPrice"]),
                cSide        = ConfigurationManager.AppSettings["OrderSide"] == "B" ? 'B' : 'S', //Buy or sell
                Quantity     = Convert.ToDecimal(ConfigurationManager.AppSettings["OrderSize"]),
                cTimeInForce = '0',                                                              //Day
                cOrderType   = LegacyOrderReq._ORD_TYPE_LIMIT,                                   //Limit
            };

            return(legacyOrdReq);
        }
        public NewOrderSingleWrapper(LegacyOrderReq pLegactyOrderReq, string pOutgoingSymbol)
        {
            LegacyOrderReq = pLegactyOrderReq;

            OutgoingSymbol = pOutgoingSymbol;
        }