public BrokerInfo GetBrokerInfo()
        {
            BrokerInfo brokerInfo = new BrokerInfo();

            if (!this.isConnected)
            {
                this.EmitError(this.Id, -1, "The TDXTradeProvider is not connected.");
                return(brokerInfo);
            }
            ReportArgs rargs = this.trader.QueryFund();

            if (rargs.Succeeded && rargs.Result != null)
            {
                FundRecord    fundRecord    = (FundRecord)rargs.Result;
                BrokerAccount brokerAccount = new BrokerAccount("通达信-" + this.fundID);
                brokerAccount.AddField("Balance", fundRecord.Balance.ToString());
                brokerAccount.AddField("Available", fundRecord.Available.ToString());
                brokerAccount.AddField("TotalAssets", fundRecord.TotalAsserts.ToString());
                brokerAccount.AddField("Desirable", fundRecord.Desirable.ToString());
                brokerAccount.AddField("MarketValue", fundRecord.MarketValue.ToString());
                brokerAccount.AddField("Frozen", fundRecord.Frozen.ToString());
                brokerAccount.BuyingPower = fundRecord.Available;
                brokerInfo.Accounts.Add(brokerAccount);
                rargs = this.trader.QueryPositions();
                if (rargs.Succeeded && rargs.Result != null)
                {
                    List <PositionRecord> positions = (List <PositionRecord>)rargs.Result;
                    foreach (PositionRecord position in positions)
                    {
                        BrokerPosition brokerPosition = new BrokerPosition();
                        brokerPosition.SecurityExchange = position.SecurityExchange;
                        brokerPosition.Symbol           = position.SecurityExchange + "." + position.SecurityID;
                        brokerPosition.AddCustomField("Available", position.Available.ToString());
                        brokerPosition.Qty = position.Quantity;
                        brokerPosition.AddCustomField("CostPrice", position.CostPrice.ToString());
                        brokerPosition.LongQty = position.Quantity;
                        brokerAccount.AddPosition(brokerPosition);
                    }
                }
                else
                {
                    this.EmitError(this.Id, -1, rargs.ErrorInfo);
                }
            }
            else
            {
                this.EmitError(this.Id, -1, rargs.ErrorInfo);
            }


            return(brokerInfo);
        }
        public ReportArgs QueryFund()
        {
            ReportArgs reportArgs = new ReportArgs();

            if (this.clientID != -1)
            {
                StringBuilder errInfo = new StringBuilder(256);
                StringBuilder result  = new StringBuilder(1024 * 1024);
                TDXWrapper.QueryData(this.clientID, 0, result, errInfo);
                if (errInfo.ToString() != string.Empty)//查询失败
                {
                    reportArgs.Succeeded = false;
                    reportArgs.ErrorInfo = errInfo.ToString();
                }
                else//查询成功
                {
                    List <string[]> data = this.pickUp(result);
                    reportArgs.Succeeded = true;
                    if (data.Count > 1)
                    {
                        FundRecord fundRecord = new FundRecord();
                        fundRecord.Balance      = double.Parse(data[1][1]);
                        fundRecord.Available    = double.Parse(data[1][2]);
                        fundRecord.Frozen       = double.Parse(data[1][3]);
                        fundRecord.Desirable    = double.Parse(data[1][4]);
                        fundRecord.TotalAsserts = double.Parse(data[1][5]);
                        fundRecord.MarketValue  = double.Parse(data[1][6]);
                        reportArgs.Result       = fundRecord;
                    }
                }
            }
            else
            {
                reportArgs.Succeeded = false;
                reportArgs.ErrorInfo = "交易账号未登录.";
            }
            return(reportArgs);
        }