protected override TraderResult internalCancelStock(int entrust_no) { StockCancelRequest t = new StockCancelRequest { 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 = "", entrust_no = entrust_no.ToString() }; StockCancelResp resp = getResp <StockCancelResp, StockCancelRequest>(t); TraderResult ret = new TraderResult(); if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; ret.EntrustNo = resp.Item[0].entrust_no; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }
public void GetTodayEntrusterList() { GetTodayEntrusterRequest t = new GetTodayEntrusterRequest { 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 = "" }; //string entrusterParams = StockUtil.Base64Encode(URLHelper.GetDataWithOutEncode<GetTodayEntrusterRequest>(t1), this.GB2312); //string entrusterUrl = "https://tradegw.htsc.com.cn/?" + entrusterParams; //string resp = StockUtil.Base64Decode(this.httpClient.DownloadString(entrusterUrl), this.GB2312); //GetTodayEntrustResp ret = JsonConvert.DeserializeObject<GetTodayEntrustResp>(resp); GetTodayEntrustResp ret = getResp <GetTodayEntrustResp, GetTodayEntrusterRequest>(t); TraderResult result = new TraderResult(); result.Result = ret; if (ret.cssweb_code == SuccessCode) { result.Code = TraderResultEnum.SUCCESS; } // return result; }
protected override TraderResult internalBuyStock(string code, float price, int num) { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
protected override TraderResult internalBuyStock(string code, float price, int num) { const int BUY_TXT_CODE = 0x0408; const int BUY_TXT_PRICE = 0x0409; const int BUY_TXT_NUM = 0x040A; const int BUY_BTN_OK = 0x3EE; ClickBuyTreeViewItem(); // 设定代码,价格,数量 IntPtr hPanel = GetDetailPanel(); IntPtr hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_CODE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, StockUtil.GetShortCode(code)); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_PRICE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, price.ToString()); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_NUM); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, num.ToString()); // 点击买入按钮 hCtrl = Win32API.GetDlgItem(hPanel, BUY_BTN_OK); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONDOWN, 0, 0); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONUP, 0, 0); ClickQueryDrcjTreeViewItem(); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
protected override TraderResult internalGetTodayTradeList() { GetTodayTradeRequest t = new GetTodayTradeRequest { 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 = "" }; GetTodayTradeResponse resp = getResp <GetTodayTradeResponse, GetTodayTradeRequest>(t); TraderResult ret = new TraderResult(); ret.Result = resp; if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }
protected override TraderResult internalGetTodayTradeList() { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
protected override TraderResult internalGetTradingAccountInfo() { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
private void button4_Click_1(object sender, EventArgs e) { if (xiadan == null) { xiadan = XiaDan.Instance; } TraderResult result = this.xiadan.GetCashInfo(); }
protected override TraderResult internalSellStock(string code, float price, int num) { Console.WriteLine(String.Format("卖出股票:{0}, 卖出价格:{1}: 卖出数量: {2}, 时间: {3}", code, price, num, DateTime.Now)); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; result.EntrustNo = new Random().Next(); return result; }
protected override TraderResult internalSellStock(string code, float price, int num) { Console.WriteLine(String.Format("卖出股票:{0}, 卖出价格:{1}: 卖出数量: {2}, 时间: {3}", code, price, num, DateTime.Now)); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; result.EntrustNo = new Random().Next(); return(result); }
private void CancelEntrustJob() { // 1、获取成交列表 TraderResult ret = this.GetTodayTradeList(); TradingList list = (TradingList)ret.Result; // 2、从委托列表中移除已成交的部分 // foreach (var item in list) //{ //} }
protected override TraderResult internalGetTradingAccountInfo() { List <TradingAccount.StockHolderInfo> shis = GetStocks(); TradingAccount account = new TradingAccount(); account.AddStockHolder(shis); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; result.Result = account; return(result); }
protected override TraderResult internalGetTodayTradeList() { GetTodayTradeRequest t = new GetTodayTradeRequest { 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 = "" }; GetTodayTradeResponse resp = getResp <GetTodayTradeResponse, GetTodayTradeRequest>(t); TraderResult ret = new TraderResult(); if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; TradingList tradingList = new TradingList(); foreach (GetTodayTradeResponse.GetTodayTradeRespItem item in resp.Item) { tradingList.Add(new TradingList.TradingItem { StockName = item.stock_name, StockCode = item.stock_code, SerialNo = item.serial_no, BusinessAmount = item.business_amount, BusinessPrice = item.business_price, BusinessBalance = item.business_balance, EntrustNo = item.entrust_no, Remark = item.remark, StockAccount = item.stock_code, ExchangeType = item.exchange_type, bs_name = item.bs_name, Date = item.date }); } ret.Result = tradingList; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }
public TraderResult CancelStock(string entrustNo) { LogHelper.WriteLog(this.GetType(), "BaseStrategy.CancelStock"); TraderResult result = trader.CancelStock(entrustNo); switch (result.Code) { case TraderResultEnum.ERROR: MessageBox.Show(result.Message); break; case TraderResultEnum.SUCCESS: AddEntrustNo(result.EntrustNo); break; } return(result); }
public TraderResult BuyStock(string code, float price, int num) { LogHelper.WriteLog(this.GetType(), "BaseStrategy.BuyStock"); TraderResult result = trader.BuyStock(code, price, num); switch (result.Code) { case TraderResultEnum.ERROR: MessageBox.Show(result.Message); break; case TraderResultEnum.SUCCESS: AddEntrustNo(result.EntrustNo); break; } return(result); }
public virtual TraderResult SellStock(string code, float price, int amount) { LogHelper.Instance.WriteLog(null, String.Format("开始卖出股票{0}, {1}股,单价{2}", code, amount, price), true); TraderResult result = trader.SellStock(code, price, amount); LogHelper.Instance.WriteLog(null, String.Format("成功卖出股票{0}, {1}股,单价{2}", code, amount, price), true); switch (result.Code) { case TraderResultEnum.ERROR: MessageBox.Show(result.Message); break; case TraderResultEnum.SUCCESS: AddEntrustNo(result.EntrustNo); break; } return(result); }
public TraderResult CancelStock(int entrustNo) { LogHelper.Instance.WriteLog(this.GetType(), "BaseStrategy.CancelStock"); TraderResult result = trader.CancelStock(entrustNo); switch (result.Code) { case TraderResultEnum.ERROR: MessageBox.Show(result.Message); break; case TraderResultEnum.SUCCESS: AddEntrustNo(result.EntrustNo); break; } WSClient.Instance.SendMessage(String.Format("CancelStock(entrustNo {0})", entrustNo)); return(result); }
public virtual TraderResult BuyStock(string code, float price, int num) { LogHelper.Instance.WriteLog(this.GetType(), "BaseStrategy.BuyStock"); TraderResult result = trader.BuyStock(code, price, num); switch (result.Code) { case TraderResultEnum.ERROR: MessageBox.Show(result.Message); break; case TraderResultEnum.SUCCESS: AddEntrustNo(result.EntrustNo); break; } WSClient.Instance.SendMessage(String.Format("BuyStock(code {0}, price {1}, num {2})", code, price, num)); return(result); }
public static async Task <TraderResult> GetSellerProduct(string url) { TraderResult objData = new TraderResult(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(url); var result = await client.GetAsync(url); var place = result.Content.ReadAsStringAsync().Result; objData = JsonConvert.DeserializeObject <TraderResult>(await result.Content.ReadAsStringAsync()); } } catch (Exception ex) { } return(objData); }
protected override TraderResult internalBuyStock(string code, float price, int num) { int exchange_type = StockUtil.GetExchangeType(code); AccountInfoItem 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 = StockUtil.GetShortCode(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; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }
protected override TraderResult internalSellStock(string code, float price, int num) { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return result; }
protected override TraderResult internalSellStock(string code, float price, int num) { ClickSellTreeViewItem(); const int BUY_TXT_CODE = 0x0408; const int BUY_TXT_PRICE = 0x0409; const int BUY_TXT_NUM = 0x040A; const int BUY_BTN_OK = 0x3EE; // 设定代码,价格,数量 IntPtr hPanel = GetDetailPanel(); IntPtr hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_CODE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, StockUtil.GetShortCode(code)); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_PRICE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, price.ToString()); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_NUM); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, num.ToString()); // 点击卖出按钮 hCtrl = Win32API.GetDlgItem(hPanel, BUY_BTN_OK); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONDOWN, 0, 0); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONUP, 0, 0); ClickQueryDrcjTreeViewItem(); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return result; }
protected override TraderResult internalGetTradingAccountInfo() { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return result; }
protected override TraderResult internalGetTodayTradeList() { TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return result; }