/// <summary> /// 获取最后一根柱子的信息 /// </summary> /// <param name="pcode">商品行情编码</param> /// <param name="dtype">周期类型</param> /// <returns>获取最后一根柱子的信息(逗号隔开的行情数据)</returns> public string GetLastPillar(string pcode, datatype dtype) { string strtmp = String.Empty; TradeClient tc = new TradeClient(); try { switch (dtype) { case datatype.M1: strtmp = "M1"; break; case datatype.M5: strtmp = "M5"; break; case datatype.M15: strtmp = "M15"; break; case datatype.M30: strtmp = "M30"; break; case datatype.H1: strtmp = "H1"; break; case datatype.H4: strtmp = "H4"; break; case datatype.D1: strtmp = "D1"; break; case datatype.W1: strtmp = "W1"; break; case datatype.MN: strtmp = "MN"; break; default: break; } strtmp = tc.GetLastPillarData(strtmp, pcode); tc.Close(); } catch (Exception ex) { tc.Abort(); ComFunction.WriteErr(ex); } return(strtmp); }
/// <summary> /// 获取最后一根柱子的信息 /// </summary> /// <param name="pcode">商品行情编码</param> /// <param name="dtype">周期类型</param> /// <returns>获取最后一根柱子的信息(逗号隔开的行情数据)</returns> public string GetLastPillar(string pcode, datatype dtype) { string strtmp = String.Empty; TradeClient tc = new TradeClient(); try { switch (dtype) { case datatype.M1: strtmp = "M1"; break; case datatype.M5: strtmp = "M5"; break; case datatype.M15: strtmp = "M15"; break; case datatype.M30: strtmp = "M30"; break; case datatype.H1: strtmp = "H1"; break; case datatype.H4: strtmp = "H4"; break; case datatype.D1: strtmp = "D1"; break; case datatype.W1: strtmp = "W1"; break; case datatype.MN: strtmp = "MN"; break; default: break; } strtmp = tc.GetLastPillarData(strtmp, pcode); tc.Close(); } catch (Exception ex) { tc.Abort(); ComFunction.WriteErr(ex); } return strtmp; }
/// <summary> /// 删除节假日 /// </summary> /// <param name="ID"></param> public static void DelHoliday(string ID) { TradeClient tc = new TradeClient(); try { tc.DelHoliday(ID); tc.Close(); } catch (Exception) { tc.Abort(); } }
/// <summary> /// /// </summary> /// <param name="TdRate"></param> /// <returns></returns> public static int ModifyWaterAndRate(WcfInterface.model.TradeRate TdRate) { TradeClient tc = new TradeClient(); int result = 0; try { result = tc.SetRateAndWater(TdRate.PriceCode, TdRate.Rate, TdRate.Water); tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } return result; }
/// <summary> /// 修改节假日 /// </summary> /// <param name="Hliday"></param> public static void ModifyHoliday(WcfInterface.model.DateHoliday Hliday) { TradeClient tc = new TradeClient(); try { WcfInterface.ServiceReference1.DateHoliday dh = new ServiceReference1.DateHoliday(); dh.Desc = Hliday.Desc; dh.Endtime = Hliday.Endtime; dh.Starttime = Hliday.Starttime; dh.ID = Hliday.ID; dh.HoliName = Hliday.HoliName; dh.PriceCode = Hliday.PriceCode; tc.ModifyHoliday(dh); tc.Close(); } catch (Exception) { tc.Abort(); } }
/// <summary> /// 修改交易日 /// </summary> /// <param name="DtSet"></param> public static void ModifyDateSetEx(WcfInterface.model.DateSet DtSet) { TradeClient tc = new TradeClient(); try { WcfInterface.ServiceReference1.DateSet ds = new ServiceReference1.DateSet(); ds.Desc = DtSet.Desc; ds.Endtime = DtSet.Endtime; ds.Starttime = DtSet.Starttime; ds.Istrade = !DtSet.Istrade; ds.Weekday = DtSet.Weekday; ds.PriceCode = DtSet.PriceCode; tc.ModifyDateSet(ds); tc.Close(); } catch (Exception) { tc.Abort(); } }
/// <summary> /// 根据用户ID获取用户的盈亏 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static double GetUserYingKui(string userid) { System.Data.Common.DbDataReader dbreader = null; double yingkui = 0; TradeClient tc = new TradeClient(); try { string data = string.Empty; Dictionary<string, ProPrice> prodic = tc.GetProPrice(); foreach (var item in prodic) { data += string.Format("{0},{1}|", item.Key, item.Value.realprice); } if (data.Length > 1) { data = data.Substring(0, data.Length - 1); } else { return 0; } //@data 参数格式[行情编码,价格|行情编码,价格|行情编码,价格|行情编码,价格|行情编码,价格] //存储过程proc_GetUserYingKui计算一个用户所有订单的盈亏之和 dbreader = DbHelper.RunProcedureGetDataReader("proc_GetUserYingKui", new System.Data.Common.DbParameter[] { DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type, "@userid", DbParameterType.String, userid, ParameterDirection.Input), DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type, "@data", DbParameterType.String, data, ParameterDirection.Input) }); if (dbreader.Read()) { yingkui = System.DBNull.Value != dbreader["yingkui"] ? Convert.ToDouble(dbreader["yingkui"]) : 0; } tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } finally { if (dbreader != null) { dbreader.Close(); dbreader.Dispose(); } } return yingkui; }
/// <summary> /// 根据行情编码 获取实时价格 /// </summary> /// <param name="pcode">行情编码</param> /// <returns>实时价格</returns> public static double GetRealPrice(string pcode) { double realprice = 0; TradeClient tc = new TradeClient(); try { //WSHttpBinding binding = new WSHttpBinding(SecurityMode.None); //EndpointAddress address = new EndpointAddress(ConfigurationManager.AppSettings["wcfaddr1"]); //ChannelFactory<WcfInterface.ServiceReference1.ITrade> ttgService = new ChannelFactory<WcfInterface.ServiceReference1.ITrade>(binding, address); //realprice = ttgService.CreateChannel().GetRealprice(pcode); realprice = tc.GetRealprice(pcode); tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } return realprice; }
/// <summary> /// 获取商品时间和最新价格 /// </summary> /// <returns></returns> public static Dictionary<string, ProPrice> GetProPrice() { Dictionary<string, ProPrice> prodic = new Dictionary<string, ProPrice>(); TradeClient tc = new TradeClient(); try { prodic = tc.GetProPrice(); tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } return prodic; }
/// <summary> /// 根据周期获取最后一根柱子的信息 /// </summary> /// <param name="weekflg"></param> /// <returns></returns> public static Dictionary<string, string> GetAllLastPillar(string weekflg) { Dictionary<string, string> dic = new Dictionary<string, string>(); TradeClient tc = new TradeClient(); try { dic = tc.GetAllLastPillar(weekflg); tc.Close(); } catch (Exception ex) { tc.Abort(); throw new Exception(ex.Message, ex); } return dic; }