// private string CreateInstumentUpdateSql() // { // string cmdText = string.Format(@"update {0}.contracts set contract_name = @contract_name, //open_date = @open_date,expire_date = @expire_date,start_deliv_date = @start_deliv_date,end_deliv_date = @end_deliv_date, //volume_multiple = @volume_multiple,is_trading = @is_trading,varieties = @varieties,price_tick = @price_tick, //exchange_long_margin_ratio = @exchange_long_margin_ratio,exchange_short_margin_ratio = @exchange_short_margin_ratio, //product_class = @product_class,underlying_instrument = @underlying_instrument, //max_market_order_volume = @max_market_order_volume,min_market_order_volume = @min_market_order_volume, //max_limit_order_volume = @max_limit_order_volume,min_limit_order_volume = @min_limit_order_volume //WHERE contract = @contract AND exchange = @exchange;", m_alphaDBName); // return cmdText; // } // private string CreateDailyWorkStateInsertSql() // { // string cmdText = string.Format(@"insert into {0}.daily_work_state(working_day,instrument_download) //values(CURDATE(),1);", m_alphaDBName); // return cmdText; // } // private string CreateDailyWorkStateUpdateSql() // { // string cmdText = string.Format(@"update {0}.daily_work_state set instrument_download = 1 //where working_day = CURDATE();", m_alphaDBName); // return cmdText; // } /// <summary> /// 读取配置信息。 /// </summary> /// <returns></returns> private bool ReadConfig() { try { string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; Debug.Assert(!string.IsNullOrEmpty(exePath)); Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); if (!config.HasFile) { throw new ApplicationException("Not found the specific configuration file."); } CtpOrderDriverSection ctpSection = config.GetSection("CtpOrderDriver") as CtpOrderDriverSection; m_ctpDriverConfig = ctpSection.CtpOrderDriver; m_ctpAccountConfig = ctpSection.CtpAccount; m_dbConStr = ConfigurationManager.ConnectionStrings["MarketDataDB"].ConnectionString; m_alphaDBName = ConfigurationManager.AppSettings["AlphaDBName"]; } catch (Exception ex) { string error = "Not found the specific configuration file," + ex.Message; Console.WriteLine(error); m_eventLogger.WriteError(error); return(false); } return(true); }
private Dictionary <string, List <USeInstrument> > QueryAllInstrument() { string text = string.Empty; CtpOrderQuerier ctpApp = new CtpOrderQuerier(); try { CtpOrderDriverSection section = ReadConfig(); ctpApp.Connect(section.CtpOrderDriver.Address, section.CtpOrderDriver.Port, section.CtpOrderDriver.LoginTimeOut, section.CtpOrderDriver.QueryTimeOut); ctpApp.Login(section.CtpAccount.ID, section.CtpAccount.Password, section.CtpAccount.BrokerID); List <InstrumentField> fileldList = ctpApp.QueryInstument(); Dictionary <string, List <USeInstrument> > dic = new Dictionary <string, List <USeInstrument> >(); foreach (InstrumentField field in fileldList) { if (field.ProductClass != ProductClass.Futures) { continue; } List <USeInstrument> instrumentList = null; if (dic.TryGetValue(field.ProductID, out instrumentList) == false) { instrumentList = new List <USeInstrument>(); dic.Add(field.ProductID, instrumentList); } USeInstrument instrument = new USeInstrument(field.InstrumentID, field.InstrumentID, USeMarket.SHFE); instrumentList.Add(instrument); } ctpApp.Disconnect(); return(dic); } catch (Exception ex) { ctpApp.Disconnect(); throw ex; } }
/// <summary> /// 读取配置信息。 /// </summary> /// <returns></returns> private CtpOrderDriverSection ReadConfig() { try { string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; Debug.Assert(!string.IsNullOrEmpty(exePath)); Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); if (!config.HasFile) { throw new ApplicationException("Not found the specific configuration file."); } CtpOrderDriverSection ctpSection = config.GetSection("CtpOrderDriver") as CtpOrderDriverSection; return(ctpSection); } catch (Exception ex) { return(null); } }