/// <summary> /// 获取股东信息 /// </summary> /// <param name="exchangeType"></param> /// <returns></returns> private StockHolderInfo GetStockHolder(int exchangeType) { StockHolderInfo holder = null; for (int i = 0; i < this.resAccountInfo.Item.Count; i++) { if (this.resAccountInfo.Item[i].exchange_type == exchangeType.ToString()) { holder = this.resAccountInfo.Item[i]; } } return(holder); }
/// <summary> /// 获取股票持仓 /// </summary> /// <returns></returns> private List <StockHolderInfo> GetStocks() { GetStockPositionRequest t = new GetStockPositionRequest { branch_no = this.resAccountInfo.branch_no, custid = this.resAccountInfo.fund_account, fund_account = this.resAccountInfo.fund_account, op_branch_no = this.resAccountInfo.branch_no, op_station = this.resAccountInfo.op_station, password = this.resAccountInfo.trdpwd, uid = this.resAccountInfo.uid }; GetStockPositionResp result = getResp <GetStockPositionResp, GetStockPositionRequest>(t); List <StockHolderInfo> list = new List <StockHolderInfo>(); foreach (GetStockPositionResp.GetStockPositionRespItem si in result.Item) { if (si.stock_code != null) { StockHolderInfo shi = new StockHolderInfo { StockAccount = si.stock_account, StockCode = si.stock_code, StockName = si.stock_name, ExchangeName = si.exchange_name, MarketValue = si.market_value, CostPrice = si.cost_price, CurrentAmount = si.current_amount, EnableAmount = si.enable_amount, IncomeAmount = si.income_balance, KeepCostPrice = si.keep_cost_price, LastPrice = si.last_price }; list.Add(shi); } } return(list); }
private void GetStocks(TradingAccount account, String[] ps) { for (int i = 1; i < ps.Length; i++) { String[] stocks = ps[i].Split(new string[] { "\t" }, StringSplitOptions.None); StockHolderInfo shi = new StockHolderInfo { StockCode = stocks[0], StockName = stocks[1], CurrentAmount = int.Parse(stocks[2]), EnableAmount = int.Parse(stocks[3]), IncomeAmount = int.Parse(stocks[4]), CostPrice = float.Parse(stocks[5]), KeepCostPrice = float.Parse(stocks[6]), LastPrice = float.Parse(stocks[7]), MarketValue = float.Parse(stocks[10]), ExchangeName = stocks[11], StockAccount = stocks[12] }; account.AddStockHolder(shi); } }
protected override TraderResult internalBuyStock(string code, float price, int num) { int exchange_type = StockUtil.GetExchangeType(code); StockHolderInfo holder = GetStockHolder(exchange_type); StockBuyRequest t = new StockBuyRequest { branch_no = this.resAccountInfo.branch_no, custid = this.resAccountInfo.fund_account, fund_account = this.resAccountInfo.fund_account, op_branch_no = this.resAccountInfo.branch_no, op_station = this.resAccountInfo.op_station, password = this.resAccountInfo.trdpwd, uid = this.resAccountInfo.uid, exchange_type = exchange_type.ToString(), stock_account = holder.stock_account, stock_code = code, entrust_amount = num, entrust_price = price }; StockBuyResp resp = getResp <StockBuyResp, StockBuyRequest>(t); TraderResult ret = new TraderResult(); if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; ret.EntrustNo = resp.Item[0].entrust_no.ToString(); } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }