Пример #1
0
        private void OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            try
            {
                Array data = (Array)pInstr.get_Get("Bid#,Ask#,NetPos,PL.Z,OpenPL^");

                //get currency amount of tick
                double tickvalue = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "^"));

                for (int i = 0; i < data.Length; ++i)
                {
                    if (data.GetValue(i) == null)
                    {
                        return;
                    }
                }

                Update update = new Update();

                update.Bid    = Convert.ToDouble(data.GetValue(0));
                update.Ask    = Convert.ToDouble(data.GetValue(1));
                update.NetPos = Convert.ToInt16(data.GetValue(2));
                //convert number of ticks from PL to currency
                update.PL     = tickvalue * Convert.ToDouble(data.GetValue(3));
                update.OpenPL = Convert.ToDouble(data.GetValue(4));
                update.Symbol = pInstr.Product;


                if (OnUpdate != null)
                {
                    OnUpdate(this, new UpdateEventArgs(update));
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error(ex.StackTrace);
                }
            }
        }
Пример #2
0
        public void OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr)
        {
            try
            {
                //we use the same TTInstrNotify.OnNotifyFound event so we need to check the Product
                if (Convert.ToString(pInstr.get_Get("Product")) == instrument.Product)
                {
                    tickPrice = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "#"));
                    tickIncr  = Convert.ToInt16(pInstr.get_Get("TickIncrement"));
                }


                if (OnFound != null)
                {
                    OnFound(this, new FoundEventArgs(tickPrice));
                }

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Upon the application form loading, the TTGate, TTDropHandler, TTInstrNotify, and
        /// TTRiskManager are initialized and events are subscribed to.
        /// </summary>
        public frmManualFill()
        {
            // Required for Windows Form Designer support
            InitializeComponent();

            // Indicates when the connection is established
            m_TTGate = new XTAPI.TTGate();

            //Subscribe to the OnExchangeStateupdate and OnStatusUpdate events
            m_TTGate.OnExchangeStateUpdate += new XTAPI._ITTGateEvents_OnExchangeStateUpdateEventHandler(m_TTGate_OnExchangeStateUpdate);
            m_TTGate.OnStatusUpdate += new XTAPI._ITTGateEvents_OnStatusUpdateEventHandler(m_TTGate_OnStatusUpdate);

            // Instantiate the drag and drop handler class.
            m_TTDropHandler = new XTAPI.TTDropHandler();

            // Register the active form for drag and drop.
            m_TTDropHandler.RegisterDropWindow((int)this.Handle);

            // Associate the drop and drag callback event.
            m_TTDropHandler.OnNotifyDrop += new XTAPI._ITTDropHandlerEvents_OnNotifyDropEventHandler(m_TTDropHandler_OnNotifyDrop);

            // Instantiate the instrumebtnt notification class.
            m_TTInstrNotify = new XTAPI.TTInstrNotify();

            // Setup the instrument notification call back functions.
            m_TTInstrNotify.OnNotifyFound += new XTAPI._ITTInstrNotifyEvents_OnNotifyFoundEventHandler(m_TTInstrNotify_OnNotifyFound);

            //Instantiate the TTRiskManagerClass
            m_RiskManager = new XTAPI.TTRiskManager();

            //Subscribe to the TTRiskManager Events
            m_RiskManager.OnLoginFailed += new XTAPI._ITTRiskManagerEvents_OnLoginFailedEventHandler(m_RiskManager_OnLoginFailed);
            m_RiskManager.OnDataLoaded += new XTAPI._ITTRiskManagerEvents_OnDataLoadedEventHandler(m_RiskManager_OnDataLoaded);

            // Initialize our internal list
            m_manualFillList = new List<XTAPI.TTManualFill>();
        }