/// <summary>
        /// 
        /// </summary>
        public AnalyzerSessionIndicatorsControl(AnalyzerSession session, IEnumerable<ChartPane> chartPanes)
        {
            InitializeComponent();

            _session = session;
            _chartPanes = chartPanes;
        }
Example #2
0
        public bool Initialize(AnalyzerSession session)
        {
            lock (this)
            {
                //SystemMonitor.CheckThrow(_expertSession == null);
                _expertSession = session;
                //_executionAccount.Initialize(session);

                double balance = 10000;
                //_executionAccount.InitializeInfo(balance, 0, "NA", session.SessionInfo.BaseCurrency, balance,
                //    0, 100, 0, session.SessionInfo.Symbol, 1, 0, "Local");

                this.Name = "Simulation Order Executioner of " + _expertSession.SessionInfo.Id;

                if (_expertSession != null && _expertSession.DataProvider != null)
                {
                    _expertSession.DataProvider.ValuesUpdateEvent += new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
                }
                else
                {// Wait for session to be ready before trying to subsribe again.
                 //_expertSession.OperationalStatusChangedEvent += new GeneralHelper.GenericDelegate<IOperational>(_expertSession_OperationalStatusChangedEvent);
                }
            }

            _operationalState = OperationalStateEnum.Operational;
            //GeneralHelper.SafeEventRaise(OperationalStatusChangedEvent, this);
            return(OperationalState == OperationalStateEnum.Operational);
        }
        /// <summary>
        ///
        /// </summary>
        public AnalyzerSessionIndicatorsControl(AnalyzerSession session, IEnumerable <ChartPane> chartPanes)
        {
            InitializeComponent();

            _session    = session;
            _chartPanes = chartPanes;
        }
Example #4
0
        public AnalyzerSession CreateSimulationSession(
            SessionInfo sessionInfo)
        {
            AnalyzerSession session      = new AnalyzerSession(sessionInfo);
            DataProvider    dataProvider = null;

            lock (this)
            {
                if (AppContext.FirstDataProvider != null)
                {
                    dataProvider = AppContext.FirstDataProvider; // new DataProvider(sessionInfo.Symbol);
                    dataProvider.Run();
                }
                else
                {
                    dataProvider = new DataProvider(sessionInfo.Symbol);
                    dataProvider.Init();
                }
                session.Initialize(dataProvider);
                _existingSessions.Add(session);
            }
            // comment by Harry
            //GeneralHelper.SafeEventRaise(SessionsUpdateEvent, this);
            return(session);
        }
        protected override void OnHandleDestroyed(EventArgs e)
        {
            base.OnHandleDestroyed(e);

            listViewIndicators.Clear();
            listViewIndicatorTypes.Clear();
            this.indicatorControl1.Indicator = null;
            _session = null;
        }
        protected override void OnHandleDestroyed(EventArgs e)
        {
            base.OnHandleDestroyed(e);

            listViewIndicators.Clear();
            listViewIndicatorTypes.Clear();
            this.indicatorControl1.Indicator = null;
            _session = null;
        }
Example #7
0
        private void priceListView_DoubleClick(object sender, EventArgs e)
        {
            AnalyzerSession session        = null;
            SessionInfo     seletedSession = SelectedSession.Value;

            bool existed = false;

            foreach (ToolStripButton button in GetSessionsButtons())
            {
                if (((AnalyzerSessionControl)(button.Tag)).AnalyzerSession.SessionInfo.Symbol == seletedSession.Symbol)
                {
                    button.Checked = true;
                    existed        = true;
                    ((AnalyzerSessionControl)(button.Tag)).Visible = true;
                    session = ((AnalyzerSessionControl)(button.Tag)).AnalyzerSession;
                }
                else
                {
                    ((AnalyzerSessionControl)(button.Tag)).Visible = false;
                }
            }

            if (!existed)
            {
                foreach (SessionInfo sin in FxpaSource.AvailableSessionList)
                {
                    if (sin.Symbol == seletedSession.Symbol)
                    {
                        session = _host.CreateSimulationSession(seletedSession);
                        break;
                    }
                }
            }

            if (session == null)
            {
                MessageBox.Show("该商品没有被订阅。", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                foreach (ToolStripButton button in GetSessionsButtons())
                {
                    button.Checked = true;
                    ((AnalyzerSessionControl)(button.Tag)).Visible = true;
                }
            }
            else
            {
                closeToolStripButton.Enabled = true;
                if (!aliveSessions.Contains(session.Symbol.ToString()))
                {
                    aliveSessions.Add(session.Symbol.ToString());
                }
                UpdateUI();
                //GeneralHelper.SafeEventRaise(_host.SessionsUpdateEvent, _host);
                //SessionCreatedEvent();
            }
        }
Example #8
0
        public void DestroySession(AnalyzerSession session)
        {
            lock (this)
            {
                ((DataProvider)session.DataProvider).UnInitialize();
                session.UnInitialize();
                _existingSessions.Remove(session);
            }

            GeneralHelper.SafeEventRaise(SessionsUpdateEvent, this);
        }
Example #9
0
        public void UnInitialize()
        {
            lock (this)
            {
                if (_session != null && _session.DataProvider != null)
                {
                    _session.DataProvider.ValuesUpdateEvent -= new ValuesUpdatedDelegate(DataProviderSession_OnValuesUpdateEvent);
                }

                _session = null;
            }
        }
Example #10
0
        public bool Initialize(AnalyzerSession session)
        {
            if (this.IsInitialized)
            {
                return(_session == session);
            }

            lock (this)
            {
                _session = session;
                _session.DataProvider.ValuesUpdateEvent += new ValuesUpdatedDelegate(DataProviderSession_OnValuesUpdateEvent);
            }

            return(true);
        }
Example #11
0
        //void _expertSession_OperationalStatusChangedEvent(IOperational session)
        //{
        //    if (session.OperationalState != OperationalStateEnum.Operational)
        //    {
        //        return;
        //    }

        //    _expertSession.OperationalStatusChangedEvent -= new GeneralHelper.GenericDelegate<IOperational>(_expertSession_OperationalStatusChangedEvent);
        //    if (_expertSession != null && _expertSession.DataProvider != null)
        //    {
        //        _expertSession.DataProvider.ValuesUpdateEvent += new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
        //    }
        //}

        public void UnInitialize()
        {
            lock (this)
            {
                _operationalState = OperationalStateEnum.UnInitialized;
            }
            //_executionAccount.UnInitialize();
            //_executionAccount = null;
            if (_expertSession != null && _expertSession.DataProvider != null)
            {
                _expertSession.DataProvider.ValuesUpdateEvent -= new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
            }
            _expertSession = null;

            //GeneralHelper.SafeEventRaise(OperationalStatusChangedEvent, this);
        }
Example #12
0
 void _session_IndicatorRemovedEvent(AnalyzerSession session, Indicator indicator)
 {
     foreach (ChartPane pane in chartControl.Panes)
     {
         foreach (ChartSeries series in pane.Series)
         {
             if (series is IndicatorChartSeries && ((IndicatorChartSeries)series).Indicator == indicator)
             {
                 pane.Remove(series);
                 if (pane.Series.Length == 0)
                 {
                     chartControl.RemoveSlavePane((SubChartPane)pane);
                 }
                 return;
             }
         }
     }
 }
Example #13
0
        private void toolStripButton_Click(object sender, EventArgs e)
        {
            foreach (ToolStripButton button in GetSessionsButtons())
            {
                if (button == sender)
                {
                    //设置Operate 按钮
                    ControlButton.Tag = button.Tag;
                    OpChartControl    = ((AnalyzerSessionControl)(ControlButton.Tag)).ChartControl1;
                    asession          = ((AnalyzerSessionControl)(ControlButton.Tag)).AnalyzerSession;
                    Symbol symbol = asession.Symbol;
                    OpToolBarStatus = ((AnalyzerSessionControl)(ControlButton.Tag)).ToolBarStatus;

                    button.Checked = true;
                    ((AnalyzerSessionControl)(button.Tag)).Visible = true;

                    if (signalSymbols.Contains(symbol))
                    {
                        signalSymbols.Remove(symbol);
                    }
                    button.BackColor = btnBOriColor;
                    button.ForeColor = btnFOriColor;
                    button.Font      = btnOriFont;
                    //更改工具条的状态
                    ChangeToolBarStatus();
                    //   if(!AppContext.IsAppInitializing)
                    InvokeSignalListUpdate(symbol.ToString());
                }
            }

            //Iterate 2nd time for better UI transition.
            foreach (ToolStripButton button in GetSessionsButtons())
            {
                if (button != sender)
                {
                    button.Checked = false;
                    //((DataProvider)((AnalyzerSessionControl)(button.Tag)).Session.DataProvider).timerAuto.Stop();
                    ((AnalyzerSessionControl)(button.Tag)).Visible = false;
                }
            }
        }
        private void toolStripButton_Click(object sender, EventArgs e)
        {
            foreach (ToolStripButton button in GetSessionsButtons())
            {
                if (button == sender)
                {
                    //����Operate ��ť
                    ControlButton.Tag = button.Tag;
                    OpChartControl = ((AnalyzerSessionControl)(ControlButton.Tag)).ChartControl1;
                    asession = ((AnalyzerSessionControl)(ControlButton.Tag)).AnalyzerSession;
                    Symbol symbol = asession.Symbol;
                    OpToolBarStatus = ((AnalyzerSessionControl)(ControlButton.Tag)).ToolBarStatus;

                    button.Checked = true;
                    ((AnalyzerSessionControl)(button.Tag)).Visible = true;

                    if (signalSymbols.Contains(symbol))
                    {
                        signalSymbols.Remove(symbol);
                    }
                    button.BackColor = btnBOriColor;
                    button.ForeColor = btnFOriColor;
                    button.Font = btnOriFont;
                    //���Ĺ�������״̬
                    ChangeToolBarStatus();
                 //   if(!AppContext.IsAppInitializing)
                        InvokeSignalListUpdate(symbol.ToString());

                }
            }

             //Iterate 2nd time for better UI transition.
            foreach (ToolStripButton button in GetSessionsButtons())
            {
                if (button != sender)
                {
                    button.Checked = false;
                    //((DataProvider)((AnalyzerSessionControl)(button.Tag)).Session.DataProvider).timerAuto.Stop();
                    ((AnalyzerSessionControl)(button.Tag)).Visible = false;
                }
            }
        }
Example #15
0
 void _session_IndicatorAddedEvent(AnalyzerSession session, Indicator indicator)
 {
 }
        public void DestroySession(AnalyzerSession session)
        {
            lock (this)
            {
                ((DataProvider)session.DataProvider).UnInitialize();
                session.UnInitialize();
                _existingSessions.Remove(session);
            }

            GeneralHelper.SafeEventRaise(SessionsUpdateEvent, this);
        }
 public AnalyzerSession CreateSimulationSession(
   SessionInfo sessionInfo)
 {
     AnalyzerSession session = new AnalyzerSession(sessionInfo);
     DataProvider dataProvider = null;
     lock (this)
     {
         if (AppContext.FirstDataProvider != null)
         {
             dataProvider = AppContext.FirstDataProvider; // new DataProvider(sessionInfo.Symbol);
             dataProvider.Run();
         }
         else
         {
              dataProvider = new DataProvider(sessionInfo.Symbol);
             dataProvider.Init();
         }
         session.Initialize(dataProvider);
         _existingSessions.Add(session);
     }
     // comment by Harry
     //GeneralHelper.SafeEventRaise(SessionsUpdateEvent, this);
     return session;
 }
 void _session_IndicatorAddedEvent(AnalyzerSession session, Indicator indicator)
 {
 }
 void _session_IndicatorRemovedEvent(AnalyzerSession session, Indicator indicator)
 {
     foreach (ChartPane pane in chartControl.Panes)
     {
         foreach (ChartSeries series in pane.Series)
         {
             if (series is IndicatorChartSeries && ((IndicatorChartSeries)series).Indicator == indicator)
             {
                 pane.Remove(series);
                 if (pane.Series.Length == 0)
                 {
                     chartControl.RemoveSlavePane((SubChartPane)pane);
                 }
                 return;
             }
         }
     }
 }
        public bool Initialize(AnalyzerSession session)
        {
            lock (this)
            {
                //SystemMonitor.CheckThrow(_expertSession == null);
                _expertSession = session;
                //_executionAccount.Initialize(session);

                double balance = 10000;
                //_executionAccount.InitializeInfo(balance, 0, "NA", session.SessionInfo.BaseCurrency, balance,
                //    0, 100, 0, session.SessionInfo.Symbol, 1, 0, "Local");

                this.Name = "Simulation Order Executioner of " + _expertSession.SessionInfo.Id;

                if (_expertSession != null && _expertSession.DataProvider != null)
                {
                    _expertSession.DataProvider.ValuesUpdateEvent += new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
                }
                else
                {// Wait for session to be ready before trying to subsribe again.
                    //_expertSession.OperationalStatusChangedEvent += new GeneralHelper.GenericDelegate<IOperational>(_expertSession_OperationalStatusChangedEvent);
                }
            }

            _operationalState = OperationalStateEnum.Operational;
            //GeneralHelper.SafeEventRaise(OperationalStatusChangedEvent, this);
            return OperationalState == OperationalStateEnum.Operational;
        }
        //void _expertSession_OperationalStatusChangedEvent(IOperational session)
        //{
        //    if (session.OperationalState != OperationalStateEnum.Operational)
        //    {
        //        return;
        //    }
        //    _expertSession.OperationalStatusChangedEvent -= new GeneralHelper.GenericDelegate<IOperational>(_expertSession_OperationalStatusChangedEvent);
        //    if (_expertSession != null && _expertSession.DataProvider != null)
        //    {
        //        _expertSession.DataProvider.ValuesUpdateEvent += new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
        //    }
        //}
        public void UnInitialize()
        {
            lock (this)
            {
                _operationalState = OperationalStateEnum.UnInitialized;
            }
            //_executionAccount.UnInitialize();
            //_executionAccount = null;
            if (_expertSession != null && _expertSession.DataProvider != null)
            {
                _expertSession.DataProvider.ValuesUpdateEvent -= new ValuesUpdatedDelegate(DataProvider_ValuesUpdateEvent);
            }
            _expertSession = null;

            //GeneralHelper.SafeEventRaise(OperationalStatusChangedEvent, this);
        }
Example #22
0
 public override void UnInitializeControl()
 {
     base.UnInitializeControl();
     AnalyzerSession = null;
 }