示例#1
0
        /// <summary>Handle messages received from the trade data source</summary>
        public void DispatchMsg(ITradeeMsg msg)
        {
            // Ignore messages after dispose
            if (!IsConnected)
            {
                return;
            }

            // Dispatch received messages
            switch (msg.ToMsgType())
            {
            default:
                #region
            {
                Debug.WriteLine("Unknown Message Type {0} received".Fmt(msg.GetType().Name));
                Owner.Status.SetStatusMessage(msg: "Unknown Message Type {0} received".Fmt(msg.GetType().Name), fr_color: Color.Red, display_time: TimeSpan.FromSeconds(5));
                break;
            }

                #endregion
            case EMsgType.HelloTradee:
                #region
            {
                var m = (InMsg.HelloTradee)msg;
                MsgBox.Show(Owner, m.Text, "Test Msg Received");
                break;
            }

                #endregion
            case EMsgType.CandleData:
                #region
            {
                var cd = (InMsg.CandleData)msg;
                if (cd.Candle != null)
                {
                    MarketData[cd.SymbolCode].Add(cd.TimeFrame, cd.Candle);
                }
                if (cd.Candles != null)
                {
                    MarketData[cd.SymbolCode].Add(cd.TimeFrame, cd.Candles);
                }
                break;
            }

                #endregion
            case EMsgType.AccountUpdate:
                #region
            {
                var acct = (InMsg.AccountUpdate)msg;
                Acct.Update(acct.Acct);
                break;
            }

                #endregion
            case EMsgType.PositionsUpdate:
                #region
            {
                var pos = (InMsg.PositionsUpdate)msg;
                Acct.Update(pos.Positions);
                Positions.Update(pos.Positions);
                break;
            }

                #endregion
            case EMsgType.PendingOrdersUpdate:
                #region
            {
                var orders = (InMsg.PendingOrdersUpdate)msg;
                Acct.Update(orders.PendingOrders);
                Positions.Update(orders.PendingOrders);
                break;
            }

                #endregion
            case EMsgType.SymbolData:
                #region
            {
                var sd = (InMsg.SymbolData)msg;
                MarketData[sd.Symbol].PriceData = sd.Data;
                break;
            }

                #endregion
            case EMsgType.HistoryData:
                #region
            {
                var hd = (InMsg.HistoryData)msg;
                Positions.Update(hd.Orders);
                break;
            }
                #endregion
            }
        }
示例#2
0
 /// <summary>Update the non-instrument related things</summary>
 public void Step()
 {
     Acct.Update();
 }