コード例 #1
0
        /// <summary>
        /// 获取实时卖价和买价
        /// </summary>
        /// <returns>获取实际价格(黄金,白银,铂金,钯金)</returns>
        public ProductRealPrice GetProductRealPrice()
        {
            TradeClient      tc         = new TradeClient();
            ProductRealPrice PRealPrice = new ProductRealPrice();

            try
            {
                PRealPrice = ComFunction.GetProductRealPrice();
                PRealPrice.au_realprice = tc.GetRealprice("XAUUSD");
                PRealPrice.ag_realprice = tc.GetRealprice("XAGUSD");
                PRealPrice.pt_realprice = tc.GetRealprice("XPTUSD");
                PRealPrice.pd_realprice = tc.GetRealprice("XPDUSD");
                PRealPrice.agb_price    = PRealPrice.ag_realprice - PRealPrice.agb_price;
                PRealPrice.aub_price    = PRealPrice.au_realprice - PRealPrice.aub_price;
                PRealPrice.ptb_price    = PRealPrice.pt_realprice - PRealPrice.ptb_price;
                PRealPrice.pdb_price    = PRealPrice.pd_realprice - PRealPrice.pdb_price;
            }
            catch (Exception ex)
            {
                tc.Abort();
                ComFunction.WriteErr(ex);
            }
            return(PRealPrice);
        }
コード例 #2
0
        /// <summary>
        /// 获取实时价
        /// </summary>
        /// <param name="pcode">商品行情编码</param>
        /// <returns>获取实际价格</returns>
        public double GetRealPrice(string pcode)
        {
            TradeClient tc    = new TradeClient();
            double      price = 0;

            try
            {
                price = tc.GetRealprice(pcode);
            }
            catch (Exception ex)
            {
                tc.Abort();
                ComFunction.WriteErr(ex);
            }
            return(price);
        }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
 /// <summary>
 /// 获取实时卖价和买价
 /// </summary>
 /// <returns>获取实际价格(黄金,白银,铂金,钯金)</returns>
 public ProductRealPrice GetProductRealPrice()
 {
     TradeClient tc = new TradeClient();
     ProductRealPrice PRealPrice = new ProductRealPrice();
     try
     {
         PRealPrice = ComFunction.GetProductRealPrice();
         PRealPrice.au_realprice = tc.GetRealprice("XAUUSD");
         PRealPrice.ag_realprice = tc.GetRealprice("XAGUSD");
         PRealPrice.pt_realprice = tc.GetRealprice("XPTUSD");
         PRealPrice.pd_realprice = tc.GetRealprice("XPDUSD");
         PRealPrice.agb_price = PRealPrice.ag_realprice - PRealPrice.agb_price;
         PRealPrice.aub_price = PRealPrice.au_realprice - PRealPrice.aub_price;
         PRealPrice.ptb_price = PRealPrice.pt_realprice - PRealPrice.ptb_price;
         PRealPrice.pdb_price = PRealPrice.pd_realprice - PRealPrice.pdb_price;
     }
     catch (Exception ex)
     {
         tc.Abort();
         ComFunction.WriteErr(ex);
     }
     return PRealPrice;
 }
コード例 #5
0
 /// <summary>
 /// 获取实时价
 /// </summary>
 /// <param name="pcode">商品行情编码</param>
 /// <returns>获取实际价格</returns>
 public double GetRealPrice(string pcode)
 {
     TradeClient tc = new TradeClient();
     double price = 0;
     try
     {
         price = tc.GetRealprice(pcode);
     }
     catch (Exception ex)
     {
         tc.Abort();
         ComFunction.WriteErr(ex);
     }
     return price;
 }