Exemple #1
0
        private void tb_Trade_Click(object sender, EventArgs e)
        {
            if (!chartComponent.ConnectedServer)
            {
                if (this.marketTrader == null)
                {
                    //弹出交易账号选择界面
                    FormAccount  formAccount = new FormAccount(DataCenter.Default.AccountManager, FormAccount.PATH_MOCK);
                    DialogResult result      = formAccount.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        chartComponent.Account = formAccount.SelectedAccount;
                        IAccount account = chartComponent.Account;
                        if (account.Time > 0)
                        {
                            string code = null;
                            if (account.CurrentTradeInfo.Count > 0)
                            {
                                code = account.CurrentTradeInfo[account.CurrentTradeInfo.Count - 1].InstrumentID;
                            }
                            if (code != null)
                            {
                                chartComponent.Controller.Change(code, account.Time);
                            }
                            else
                            {
                                chartComponent.Controller.Change(account.Time);
                            }
                        }
                        account.BindRealTimeReader(this.chartComponent.Controller.CurrentRealTimeDataReader);
                        this.marketTrader = new Plugin_MarketTrader_Simu(account, this.chartComponent.DataCenter.AccountManager, formAccount.SelectedAccountPath, formAccount.SelectedAccountName);
                    }
                    else
                    {
                        return;
                    }
                }
            }
            FormTrade formTrade = new FormTrade(marketTrader, chartComponent.Controller.CurrentNavigater);

            formTrade.TopMost = true;
            formTrade.Show();
        }