Example #1
0
        void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            __DEBUGPF__();

            //pTradingAccount.Available;
            HandleStatusInternal("当前账户可用资金:" + pTradingAccount.Available);
        }
Example #2
0
 void _trade_OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (pTradingAccount != null)
     {
         this.Account.Available = pTradingAccount.Available;
         this.Account.Total     = pTradingAccount.Balance;
     }
 }
Example #3
0
        void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            __DEBUGPF__();

            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                //请求查询投资者持仓
                ReqQryInvestorPosition();
            }
        }
Example #4
0
        void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            DebugPrintFunc(new StackTrace());

            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                //请求查询投资者持仓
                ReqQryInvestorPosition();
            }
        }
Example #5
0
        /// <summary>
        /// 资金账户查询回报
        /// </summary>
        /// <param name="pTradingAccount"></param>
        /// <param name="pRspInfo"></param>
        /// <param name="nRequestID"></param>
        /// <param name="bIsLast"></param>
        public void HandleOnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            var account = new AccountData();

            ///账户推送
            this.Gateway.MainController.MainEvent._OnAccount.Invoke(account);
            if (bIsLast)
            {
                Console.WriteLine("资金账户查询回报完毕");
            }
        }
Example #6
0
 /// <summary>
 /// 更新资金信息
 /// </summary>
 /// <param name="source"></param>
 public static void UpdateAccountInfo(ThostFtdcTradingAccountField source)
 {
     DsAccountInfo.Clear();
     DsAccountInfo.Add(new AccountInfo
     {
         AccountID   = source.AccountID,
         Available   = source.Available,
         Balance     = source.Balance,
         CloseProfit = source.CloseProfit,
         Commission  = source.Commission
     });
     if (OnNeedRefreshAccount != null)
     {
         OnNeedRefreshAccount();
     }
 }
Example #7
0
 public override void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (pRspInfo != null && pRspInfo.ErrorID != 0)
     {
         LogCenter.Error("请求查询资金账户错误:" + pRspInfo.ErrorMsg);
         return;
     }
     if (pTradingAccount == null)
     {
         LogCenter.Error("请求查询资金账户错误,返回值为空");
         return;
     }
     var tradingAccount = new TradingAccount
     {
         BrokerID = pTradingAccount.BrokerID,
         AccountID = pTradingAccount.AccountID,
         PreMortgage = pTradingAccount.PreMortgage,
         PreCredit = pTradingAccount.PreCredit,
         PreDeposit = pTradingAccount.PreDeposit,
         PreBalance = pTradingAccount.PreBalance,
         PreMargin = pTradingAccount.PreMargin,
         InterestBase = pTradingAccount.InterestBase,
         Interest = pTradingAccount.Interest,
         Deposit = pTradingAccount.Deposit,
         Withdraw = pTradingAccount.Withdraw,
         FrozenMargin = pTradingAccount.FrozenMargin,
         FrozenCash = pTradingAccount.FrozenCash,
         FrozenCommission = pTradingAccount.FrozenCommission,
         CurrMargin = pTradingAccount.CurrMargin,
         CashIn = pTradingAccount.CashIn,
         Commission = pTradingAccount.Commission,
         CloseProfit = pTradingAccount.CloseProfit,
         PositionProfit = pTradingAccount.PositionProfit,
         Balance = pTradingAccount.Balance,
         Available = pTradingAccount.Available,
         WithdrawQuota = pTradingAccount.WithdrawQuota,
         Reserve = pTradingAccount.Reserve,
         TradingDay = pTradingAccount.TradingDay,
         SettlementID = pTradingAccount.SettlementID,
         Credit = pTradingAccount.Credit,
         Mortgage = pTradingAccount.Mortgage,
         ExchangeMargin = pTradingAccount.ExchangeMargin,
         DeliveryMargin = pTradingAccount.DeliveryMargin,
         ExchangeDeliveryMargin = pTradingAccount.ExchangeDeliveryMargin,
         ReserveBalance = pTradingAccount.ReserveBalance,
         CurrencyID = pTradingAccount.CurrencyID,
         PreFundMortgageIn = pTradingAccount.PreFundMortgageIn,
         PreFundMortgageOut = pTradingAccount.PreFundMortgageOut,
         FundMortgageIn = pTradingAccount.FundMortgageIn,
         FundMortgageOut = pTradingAccount.FundMortgageOut,
         FundMortgageAvailable = pTradingAccount.FundMortgageAvailable,
         MortgageableFund = pTradingAccount.MortgageableFund,
         SpecProductMargin = pTradingAccount.SpecProductMargin,
         SpecProductFrozenMargin = pTradingAccount.SpecProductFrozenMargin,
         SpecProductCommission = pTradingAccount.SpecProductCommission,
         SpecProductFrozenCommission = pTradingAccount.SpecProductFrozenCommission,
         SpecProductPositionProfit = pTradingAccount.SpecProductPositionProfit,
         SpecProductCloseProfit = pTradingAccount.SpecProductCloseProfit,
         SpecProductPositionProfitByAlg = pTradingAccount.SpecProductPositionProfitByAlg,
         SpecProductExchangeMargin = pTradingAccount.SpecProductExchangeMargin,
     };
     TradingAccountViewModel.Instance.Update(tradingAccount);
 }
Example #8
0
 public override void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     throw new NotImplementedException();
 }
Example #9
0
        public override void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            if (pRspInfo != null && pRspInfo.ErrorID != 0)
            {
                LogCenter.Error("请求查询资金账户错误:" + pRspInfo.ErrorMsg);
                return;
            }
            if (pTradingAccount == null)
            {
                LogCenter.Error("请求查询资金账户错误,返回值为空");
                return;
            }
            var tradingAccount = new TradingAccount
            {
                BrokerID                       = pTradingAccount.BrokerID,
                AccountID                      = pTradingAccount.AccountID,
                PreMortgage                    = pTradingAccount.PreMortgage,
                PreCredit                      = pTradingAccount.PreCredit,
                PreDeposit                     = pTradingAccount.PreDeposit,
                PreBalance                     = pTradingAccount.PreBalance,
                PreMargin                      = pTradingAccount.PreMargin,
                InterestBase                   = pTradingAccount.InterestBase,
                Interest                       = pTradingAccount.Interest,
                Deposit                        = pTradingAccount.Deposit,
                Withdraw                       = pTradingAccount.Withdraw,
                FrozenMargin                   = pTradingAccount.FrozenMargin,
                FrozenCash                     = pTradingAccount.FrozenCash,
                FrozenCommission               = pTradingAccount.FrozenCommission,
                CurrMargin                     = pTradingAccount.CurrMargin,
                CashIn                         = pTradingAccount.CashIn,
                Commission                     = pTradingAccount.Commission,
                CloseProfit                    = pTradingAccount.CloseProfit,
                PositionProfit                 = pTradingAccount.PositionProfit,
                Balance                        = pTradingAccount.Balance,
                Available                      = pTradingAccount.Available,
                WithdrawQuota                  = pTradingAccount.WithdrawQuota,
                Reserve                        = pTradingAccount.Reserve,
                TradingDay                     = pTradingAccount.TradingDay,
                SettlementID                   = pTradingAccount.SettlementID,
                Credit                         = pTradingAccount.Credit,
                Mortgage                       = pTradingAccount.Mortgage,
                ExchangeMargin                 = pTradingAccount.ExchangeMargin,
                DeliveryMargin                 = pTradingAccount.DeliveryMargin,
                ExchangeDeliveryMargin         = pTradingAccount.ExchangeDeliveryMargin,
                ReserveBalance                 = pTradingAccount.ReserveBalance,
                CurrencyID                     = pTradingAccount.CurrencyID,
                PreFundMortgageIn              = pTradingAccount.PreFundMortgageIn,
                PreFundMortgageOut             = pTradingAccount.PreFundMortgageOut,
                FundMortgageIn                 = pTradingAccount.FundMortgageIn,
                FundMortgageOut                = pTradingAccount.FundMortgageOut,
                FundMortgageAvailable          = pTradingAccount.FundMortgageAvailable,
                MortgageableFund               = pTradingAccount.MortgageableFund,
                SpecProductMargin              = pTradingAccount.SpecProductMargin,
                SpecProductFrozenMargin        = pTradingAccount.SpecProductFrozenMargin,
                SpecProductCommission          = pTradingAccount.SpecProductCommission,
                SpecProductFrozenCommission    = pTradingAccount.SpecProductFrozenCommission,
                SpecProductPositionProfit      = pTradingAccount.SpecProductPositionProfit,
                SpecProductCloseProfit         = pTradingAccount.SpecProductCloseProfit,
                SpecProductPositionProfitByAlg = pTradingAccount.SpecProductPositionProfitByAlg,
                SpecProductExchangeMargin      = pTradingAccount.SpecProductExchangeMargin,
            };

            TradingAccountViewModel.Instance.Update(tradingAccount);
        }
Example #10
0
 ///请求查询资金账户响应
 public void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (!IsErrorRspInfo(pRspInfo))
     {
     }
 }
Example #11
0
        /// <summary>
        /// 查询资金账户应答
        /// </summary>
        /// <param name="pTradingAccount"></param>
        /// <param name="pRspInfo"></param>
        /// <param name="nRequestID"></param>
        /// <param name="bIsLast"></param>
        void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            DebugPrintFunc(new StackTrace());

            if (bIsLast && !IsErrorRspInfo(pRspInfo))
            {
                //请求查询交易编码
                ReqQryTradingCode();

            }
        }
Example #12
0
        //资金查询响应
        private void TraderAdapter_OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount,
                                                          ThostFtdcRspInfoField pRspInfo, int nRequestId, bool bIsLast)
        {
            try
            {
                if (pTradingAccount != null)
                {
                    //查询到的资金信息保存到文件中
                    var temp =
                        string.Format(
                            "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29}",
                            pTradingAccount.TradingDay, pTradingAccount.AccountID, pTradingAccount.Available,
                            pTradingAccount.Balance,
                            pTradingAccount.BrokerID, pTradingAccount.CashIn, pTradingAccount.CloseProfit,
                            pTradingAccount.Commission, pTradingAccount.Credit, pTradingAccount.CurrMargin,
                            pTradingAccount.DeliveryMargin, pTradingAccount.Deposit,
                            pTradingAccount.ExchangeDeliveryMargin, pTradingAccount.ExchangeMargin,
                            pTradingAccount.FrozenCash, pTradingAccount.FrozenCommission, pTradingAccount.FrozenMargin,
                            pTradingAccount.Interest, pTradingAccount.InterestBase, pTradingAccount.Mortgage,
                            pTradingAccount.PositionProfit, pTradingAccount.PreBalance, pTradingAccount.PreCredit,
                            pTradingAccount.PreDeposit, pTradingAccount.PreMargin, pTradingAccount.PreMortgage,
                            pTradingAccount.Reserve, pTradingAccount.SettlementID, pTradingAccount.Withdraw,
                            pTradingAccount.WithdrawQuota);

                    var moneyFile = MyUtils.AssemblyPath + "money.csv";
                    try
                    {
                        var dicMoney = new Dictionary <string, string>();

                        if (File.Exists(moneyFile))
                        {
                            var    sr = new StreamReader(moneyFile, Encoding.UTF8);
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                dicMoney[line] = line;
                            }
                            sr.Close();

                            dicMoney[temp] = temp;

                            File.Delete(moneyFile);

                            var sw = new StreamWriter(moneyFile, true, Encoding.UTF8);
                            foreach (var s in dicMoney)
                            {
                                sw.WriteLine(s.Value);
                            }

                            sw.Close();
                        }
                        else
                        {
                            const string title =
                                "交易日,投资者帐号,可用资金,期货结算准备金,经纪公司代码,资金差额,平仓盈亏,手续费,信用额度,当前保证金总额,投资者交割保证金,入金金额,交易所交割保证金,交易所保证金,冻结的资金,冻结的手续费,冻结的保证金,利息收入,利息基数,质押金额,持仓盈亏,上次结算准备金,上次信用额度,上次存款额,上次占用的保证金,上次质押金额,基本准备金,结算编号,出金金额,可取资金";

                            var sw = new StreamWriter(moneyFile, true, Encoding.UTF8);
                            sw.WriteLine(title);
                            sw.WriteLine(temp);
                            sw.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        var errorMsg = ex.Message + ex.Source + ex.StackTrace;
                        MessageBox.Show(string.Format("错误:处理{0}出现异常,异常信息:{1}", moneyFile, errorMsg));
                    }
                    MyUtils.UpdateAccountInfo(pTradingAccount);
                }

                if (bIsLast)
                {
                    Thread.Sleep(1000);
                    ReqQryInvestorPositionDetail();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询资金回报异常:" + ex.Message);
            }
        }
Example #13
0
 public override void OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     throw new NotImplementedException();
 }
Example #14
0
 void trader_OnRspQryTradingAccount(ThostFtdcTradingAccountField pTradingAccount, ThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.SetMsg("正在查询投资者持仓……");
     try
     {
         Thread.Sleep(1000);
         trader.ReqQryInvestorPosition(new ThostFtdcQryInvestorPositionField(), requestID++);
     }
     catch (Exception exp)
     {
         this.SetMsg("投资者持仓查询失败," + exp.Message);
     }
 }