Beispiel #1
0
        private void TradeDemo_Load(object sender, EventArgs e)
        {
            /// 默认操作中国平安
            this.STOCKCODE.Text = "000001";
            /// 初始化界面参数,模拟账号
            this.SERVERADDR.Text   = "mock.tdx.com.cn";
            this.SERVERPORT.Text   = "7708";
            this.TRADEACCOUNT.Text = "001001001020115";
            this.LOGINID.Text      = "*****@*****.**";
            this.LOGINPW.Text      = "";
            this.DEPID.Text        = "9000";

            int nAddItem = this.TRADEDATA.Items.Add("资金");

            nAddItem = this.TRADEDATA.Items.Add("股份");
            nAddItem = this.TRADEDATA.Items.Add("当日委托");
            nAddItem = this.TRADEDATA.Items.Add("当日成交");
            nAddItem = this.TRADEDATA.Items.Add("当日可撤委托");
            nAddItem = this.TRADEDATA.Items.Add("股东代码");
            nAddItem = this.TRADEDATA.Items.Add("融资余额");
            nAddItem = this.TRADEDATA.Items.Add("融券余额");
            nAddItem = this.TRADEDATA.Items.Add("可融证券");
            nAddItem = this.TRADEDATA.Items.Add("可申购新股");
            nAddItem = this.TRADEDATA.Items.Add("新股申购额度");
            nAddItem = this.TRADEDATA.Items.Add("配号");
            nAddItem = this.TRADEDATA.Items.Add("中签");
            nAddItem = this.TRADEDATA.SelectedIndex = 0;

            nAddItem = this.HISDATA.Items.Add("历史委托");
            nAddItem = this.HISDATA.Items.Add("历史成交");
            nAddItem = this.HISDATA.Items.Add("交割单");
            nAddItem = this.HISDATA.SelectedIndex = 0;

            /// 创建对象并初始化
            m_StockTrade = new StockTradeClass();
            if (null != m_StockTrade)
            {
                m_TradeEvent = new TradeEventSink();
                m_TradeEvent.SetIndex(1);
                /// 挂接事件
                m_StockTrade.InitEvent         += m_TradeEvent.InitEvent;
                m_StockTrade.LoginEvent        += m_TradeEvent.LoginEvent;
                m_StockTrade.OrderOKEvent      += m_TradeEvent.OrderOKEvent;
                m_StockTrade.OrderErrEvent     += m_TradeEvent.OrderErrEvent;
                m_StockTrade.OrderSuccessEvent += m_TradeEvent.OrderSuccessEvent;
                m_StockTrade.StockQuoteEvent   += m_TradeEvent.StockQuoteEvent;

                m_StockTrade.ServerErrEvent     += m_TradeEvent.ServerErrEvent;
                m_StockTrade.ServerChangedEvent += m_TradeEvent.ServerChangedEvent;

                /// 设置通讯版本(请查看自己券商的TDX版本),初始化结果异步通过事件通知
                /// 设置最大连接数,默认传1(最好跟调用登录前设置的服务器主机数量一致)
                m_StockTrade.Init("6.4", 1);
            }
            else
            {
                /// 创建失败,请检查是否正常注册完成
                MessageBox.Show("创建失败,请检查是否正常注册完成");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 程序退出时调用释放资源
        /// </summary>
        private void TradeDemo_Closed(object sender, EventArgs e)
        {
            /// 移除事件挂接
            m_StockTrade.InitEvent         -= m_TradeEvent.InitEvent;
            m_StockTrade.LoginEvent        -= m_TradeEvent.LoginEvent;
            m_StockTrade.OrderOKEvent      -= m_TradeEvent.OrderOKEvent;
            m_StockTrade.OrderErrEvent     -= m_TradeEvent.OrderErrEvent;
            m_StockTrade.OrderSuccessEvent -= m_TradeEvent.OrderSuccessEvent;
            m_StockTrade.StockQuoteEvent   -= m_TradeEvent.StockQuoteEvent;

            m_StockTrade.ServerErrEvent     -= m_TradeEvent.ServerErrEvent;
            m_StockTrade.ServerChangedEvent -= m_TradeEvent.ServerChangedEvent;

            if (null != m_StockTrade)
            {
                m_TradeEvent.ReleaseTrade();
                m_TradeEvent = null;
            }

            m_StockTrade  = null;
            m_StockTrade2 = null;
        }
Beispiel #3
0
        private void TradeDemo_Load(object sender, EventArgs e)
        {
            /// 默认操作中国平安
            this.STOCKCODE.Text = "000001";
            /// 初始化界面参数,模拟账号
            this.SERVERADDR.Text   = "mock.tdx.com.cn"; /// 券商的交易服务器IP,这儿默认模拟服务器
            this.SERVERPORT.Text   = "7708";
            this.TRADEACCOUNT.Text = "";                ///你的交易账号
            this.LOGINID.Text      = "";                ///你的登录账号
            this.LOGINPW.Text      = "";
            this.DEPID.Text        = "9000";

            int nAddItem = this.ACCOUNTTYPE.Items.Add("模拟");

            nAddItem = this.ACCOUNTTYPE.Items.Add("资金账号");
            nAddItem = this.ACCOUNTTYPE.Items.Add("客户号");

            nAddItem = BROKERTYPE.Items.Add("模拟测试");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_MNCS);
            nAddItem = BROKERTYPE.Items.Add("长江证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_CJZQ);
            nAddItem = BROKERTYPE.Items.Add("第一创业");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DYCY);
            nAddItem = BROKERTYPE.Items.Add("东莞证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DGZQ);
            nAddItem = BROKERTYPE.Items.Add("国信证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GXZQ);
            nAddItem = BROKERTYPE.Items.Add("华泰联合证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_LHZQ);
            nAddItem = BROKERTYPE.Items.Add("平安证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_PAZQ);
            nAddItem = BROKERTYPE.Items.Add("广发证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GFZQ);
            nAddItem = BROKERTYPE.Items.Add("大通证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DTZQ);
            nAddItem = BROKERTYPE.Items.Add("华西证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HXZQ);
            nAddItem = BROKERTYPE.Items.Add("兴业证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XYZQ);
            nAddItem = BROKERTYPE.Items.Add("招商证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZSZQ);
            nAddItem = BROKERTYPE.Items.Add("金元证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_JYDT);
            nAddItem = BROKERTYPE.Items.Add("中信建投");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZXJT);
            nAddItem = BROKERTYPE.Items.Add("红塔证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_YNHT);
            nAddItem = BROKERTYPE.Items.Add("长城证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_CCZQ);
            nAddItem = BROKERTYPE.Items.Add("宏源证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HYZQ);
            nAddItem = BROKERTYPE.Items.Add("国泰君安");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GTJA);
            nAddItem = BROKERTYPE.Items.Add("世纪证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SJZQ);
            nAddItem = BROKERTYPE.Items.Add("安信证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_AXZQ);
            nAddItem = BROKERTYPE.Items.Add("财富证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_CFZQ);
            nAddItem = BROKERTYPE.Items.Add("东兴证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DXZQ);
            nAddItem = BROKERTYPE.Items.Add("银河证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_YHZQ);
            nAddItem = BROKERTYPE.Items.Add("光大证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GDZQ);
            nAddItem = BROKERTYPE.Items.Add("英大证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_YDZQ);
            nAddItem = BROKERTYPE.Items.Add("德邦证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DBZQ);
            nAddItem = BROKERTYPE.Items.Add("南京证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_NJZQ);
            nAddItem = BROKERTYPE.Items.Add("中信证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZXZQ);
            nAddItem = BROKERTYPE.Items.Add("上海证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SHZQ);
            nAddItem = BROKERTYPE.Items.Add("华宝证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HBZQ);
            nAddItem = BROKERTYPE.Items.Add("爱建证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_AJZQ);
            nAddItem = BROKERTYPE.Items.Add("齐鲁证券(中泰证券)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_QLZQ);
            nAddItem = BROKERTYPE.Items.Add("中银国际");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZYGJ);
            nAddItem = BROKERTYPE.Items.Add("民族证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_MZZQ);
            nAddItem = BROKERTYPE.Items.Add("湘财证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XCZQ);
            nAddItem = BROKERTYPE.Items.Add("国金证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GJZQ);
            nAddItem = BROKERTYPE.Items.Add("首创证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SCZQ);
            nAddItem = BROKERTYPE.Items.Add("国联证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GLZQ);
            nAddItem = BROKERTYPE.Items.Add("华林证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HLZQ);
            nAddItem = BROKERTYPE.Items.Add("华福证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HFZQ);
            nAddItem = BROKERTYPE.Items.Add("国元证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GYZQ);
            nAddItem = BROKERTYPE.Items.Add("广州证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GZZQ);
            nAddItem = BROKERTYPE.Items.Add("方正证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_FZZQ);
            nAddItem = BROKERTYPE.Items.Add("渤海证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_BHZQ);
            nAddItem = BROKERTYPE.Items.Add("西南证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XNZQ);
            nAddItem = BROKERTYPE.Items.Add("新时代证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XSDZQ);
            nAddItem = BROKERTYPE.Items.Add("中投证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZTZQ);
            nAddItem = BROKERTYPE.Items.Add("华融证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HRZQ);
            nAddItem = BROKERTYPE.Items.Add("申万宏源");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SYWG);
            nAddItem = BROKERTYPE.Items.Add("华鑫证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SHXZQ);
            nAddItem = BROKERTYPE.Items.Add("东北证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_JLDB);
            nAddItem = BROKERTYPE.Items.Add("民生证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_MSZQ);
            nAddItem = BROKERTYPE.Items.Add("大同证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SXDT);
            nAddItem = BROKERTYPE.Items.Add("联储证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZCZQ);
            nAddItem = BROKERTYPE.Items.Add("厦门证券(长城国瑞证券)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XMZQ);
            nAddItem = BROKERTYPE.Items.Add("东方证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DFZQ);
            nAddItem = BROKERTYPE.Items.Add("银泰证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_YTZQ);
            nAddItem = BROKERTYPE.Items.Add("江南证券(中航证券)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_JLDT);
            nAddItem = BROKERTYPE.Items.Add("万和证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_WHZQ);
            nAddItem = BROKERTYPE.Items.Add("国开证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GKZQ);
            nAddItem = BROKERTYPE.Items.Add("中信万通(青岛证券)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZXWT);
            nAddItem = BROKERTYPE.Items.Add("信达证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XDZQ);
            nAddItem = BROKERTYPE.Items.Add("五矿证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_WKZQ);
            nAddItem = BROKERTYPE.Items.Add("江海证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_JHZQ);
            nAddItem = BROKERTYPE.Items.Add("华创证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HCZQ);
            nAddItem = BROKERTYPE.Items.Add("太平洋证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_TPYZQ);
            nAddItem = BROKERTYPE.Items.Add("国海证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GHZQ);
            nAddItem = BROKERTYPE.Items.Add("东海证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DHZQ);
            nAddItem = BROKERTYPE.Items.Add("西部证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XBZQ);
            nAddItem = BROKERTYPE.Items.Add("山西证券(汇通启富)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SXZQ);
            nAddItem = BROKERTYPE.Items.Add("华安证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HAHX);
            nAddItem = BROKERTYPE.Items.Add("国盛证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GSZQ);
            nAddItem = BROKERTYPE.Items.Add("宏信证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SCHX);
            nAddItem = BROKERTYPE.Items.Add("万联证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_WLZQ);
            nAddItem = BROKERTYPE.Items.Add("中天证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_LNZT);
            nAddItem = BROKERTYPE.Items.Add("恒泰证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_NMHT);
            nAddItem = BROKERTYPE.Items.Add("天风证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_TFZQ);
            nAddItem = BROKERTYPE.Items.Add("华龙证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_GSHL);
            nAddItem = BROKERTYPE.Items.Add("日信证券(国融证券)");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_RXZQ);
            nAddItem = BROKERTYPE.Items.Add("财通证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_CTZQ);
            nAddItem = BROKERTYPE.Items.Add("海通证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_HTZQ);
            nAddItem = BROKERTYPE.Items.Add("东吴证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_DWZQ);
            nAddItem = BROKERTYPE.Items.Add("浙商证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZJZS);
            nAddItem = BROKERTYPE.Items.Add("联讯证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_LXZQ);
            nAddItem = BROKERTYPE.Items.Add("上海华信");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SHHX);
            nAddItem = BROKERTYPE.Items.Add("东方财富");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_XZTX);
            nAddItem = BROKERTYPE.Items.Add("中原证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_ZYZQ);
            nAddItem = BROKERTYPE.Items.Add("国都证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_BJGD);
            nAddItem = BROKERTYPE.Items.Add("中邮证券");
            BrokerMap.Add(nAddItem, EZMBrokerType.BROKERTYPE_SXZY);
            this.BROKERTYPE.SelectedIndex = 0;

            nAddItem = this.TRADEDATA.Items.Add("资金");
            nAddItem = this.TRADEDATA.Items.Add("股份");
            nAddItem = this.TRADEDATA.Items.Add("当日委托");
            nAddItem = this.TRADEDATA.Items.Add("当日成交");
            nAddItem = this.TRADEDATA.Items.Add("当日可撤委托");
            nAddItem = this.TRADEDATA.Items.Add("股东代码");
            nAddItem = this.TRADEDATA.Items.Add("融资余额");
            nAddItem = this.TRADEDATA.Items.Add("融券余额");
            nAddItem = this.TRADEDATA.Items.Add("可融证券");
            nAddItem = this.TRADEDATA.Items.Add("可申购新股");
            nAddItem = this.TRADEDATA.Items.Add("新股申购额度");
            nAddItem = this.TRADEDATA.Items.Add("配号");
            nAddItem = this.TRADEDATA.Items.Add("中签");
            this.TRADEDATA.SelectedIndex = 0;

            nAddItem = this.HISDATA.Items.Add("历史委托");
            nAddItem = this.HISDATA.Items.Add("历史成交");
            nAddItem = this.HISDATA.Items.Add("资金流水");
            nAddItem = this.HISDATA.Items.Add("交割单");
            this.HISDATA.SelectedIndex = 0;

            /// 创建对象并初始化
            m_StockTrade = new StockTradeClass();
            if (null != m_StockTrade)
            {
                m_TradeEvent = new TradeEventSink();
                m_TradeEvent.SetIndex(1);

                /// 挂接事件
                m_StockTrade.InitEvent         += m_TradeEvent.InitEvent;
                m_StockTrade.LoginEvent        += m_TradeEvent.LoginEvent;
                m_StockTrade.OrderOKEvent      += m_TradeEvent.OrderOKEvent;
                m_StockTrade.OrderErrEvent     += m_TradeEvent.OrderErrEvent;
                m_StockTrade.OrderSuccessEvent += m_TradeEvent.OrderSuccessEvent;
                m_StockTrade.StockQuoteEvent   += m_TradeEvent.StockQuoteEvent;

                m_StockTrade.ServerErrEvent     += m_TradeEvent.ServerErrEvent;
                m_StockTrade.ServerChangedEvent += m_TradeEvent.ServerChangedEvent;

                /// 启用日志输出,便于调试程序
                m_StockTrade.EnableLog = true;

                /// 测试指定授权文件路径,否则使用默认和COM组件同目录的TradeAuth.zmd
                //m_StockTrade.AuthFile = "D:\\TradeAuth.zmd";

                /// 设置通讯版本(请查看自己券商的TDX版本),初始化结果异步通过事件通知
                /// 设置最大连接数,默认传1(最好跟调用登录前设置的服务器主机数量一致)
                m_StockTrade.Init("8.05", 1);
            }
            else
            {
                /// 创建失败,请检查是否正常注册完成
                MessageBox.Show("创建失败,请检查是否正常注册完成");
            }

            if (null == m_StockTrade2)
            {
                m_StockTrade2 = new StockTradeClass();
                m_TradeEvent.SetIndex(2);
            }
        }