コード例 #1
0
        /// <summary>
        /// Send the trade to OMS
        /// </summary>
        /// <param name="setup">Setup</param>
        /// <param name="trade">Trade to send</param>
        /// <param name="command">How to process the trade</param>
        public void SendTrade(Setup setup, Trade trade, int command)
        {
            if (setup.How2Trade * command == 0)
            {
                return;
            }

            var side = command > 0
                ? trade.Type > 0 ? NewOrderRequest.BUY : NewOrderRequest.SELL
                : trade.Type > 0 ? NewOrderRequest.SELL : NewOrderRequest.BUY;

            var market = securities.Find(s => s.symbol == trade.Symbol).market;
            var price  = command == -2 ? trade.StopGain : setup.How2Trade == 6 ? 0
                : trade.ExitValue + setup.Slippage * trade.Type;

            switch (command)
            {
            case 6:
            {
                var cmd = new NewOrderRequest(trade.Symbol, side, trade.Qnty.ToString(), price.ToString(), market, esign);
                NotifyOMS(cmd.ToString());
                //this.send(cmd.Serialize());
                break;
            }

            case 1:
            {
                var cmd = new NewStopOrderRequest(trade.Symbol, side, trade.Qnty.ToString(), price.ToString(), price.ToString(), market, esign);
                NotifyOMS(cmd.ToString());
                //this.send(cmd.Serialize());
                break;
            }
            }

            ///
        }
コード例 #2
0
ファイル: BusniessManager.cs プロジェクト: MarvelFisher/midas
            public void OnMessage(object obj)
            {
                if (!(obj is ISpecificRecord))
                {
                    return;
                }
                ISpecificRecord avroObj = (ISpecificRecord)obj;
                ObjectType      type    = (ObjectType)avroObj.Get(0);

                switch (type)
                {
                case ObjectType.AmendOrderRequest:
                {
                    AmendOrderRequest req = (AmendOrderRequest)avroObj;
                    logger.Info("Get AmendOrderRequest: " + req.ToString());
                    IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount);
                    processAmendOrder(adaptor, req);

                    break;
                }

                case ObjectType.CancelOrderRequest:
                {
                    CancelOrderRequest req = (CancelOrderRequest)avroObj;
                    logger.Info("Get CancelOrderRequest: " + req.ToString());
                    IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount);
                    processCancelOrder(adaptor, req);

                    break;
                }

                case ObjectType.NewOrderRequest:
                {
                    NewOrderRequest req = (NewOrderRequest)avroObj;
                    logger.Info("Get NewOrderRequest: " + req.ToString());
                    IDownStreamAdaptor adaptor = _manager.downStreamManager.getAdaptorById(req.exchangeAccount);
                    processNewOrder(adaptor, req);

                    break;
                }

                case ObjectType.SubscribeQuote:
                {
                    SubscribeQuote req = (SubscribeQuote)avroObj;

                    break;
                }

                case ObjectType.UnsubscribeQuote:
                {
                    break;
                }

                default:
                {
                    //Log Error
                    logger.Error("Undefined ObjectType: " + type);
                    return;
                }
                }
            }