public void Connect() { lock (locker) { MdApi.MD_Connect(); } }
private void button2_Click(object sender, EventArgs e) { MdApi md = MdApi.Instance; int ret = md.Init("*****@*****.**", "Chs771005", MDMode.MD_MODE_NULL); if (ret != 0) { //登录失败 return; } //List<Instrument> insts = md.GetInstruments("SHSE", 1, 1); //insts.AddRange(md.GetInstruments("SZSE", 1, 1)); List <Tick> tickLists = new List <Tick>(); //foreach (Instrument inst in insts) //{ // List<Tick> tickList = md.GetLastNTicks(inst.symbol, 1, "2016-03-26 15:01:00"); // tickLists.AddRange(tickList); //} List <Tick> tickList = md.GetLastNTicks("SHSE.600830", 1, "2018-08-13 15:00:00"); //List<Tick> tickList = md.GetTicks("SHSE.600830", "2018-08-13 00:00:00", "2018-08-13 15:05:00"); //List<Tick> tickList = md.GetTicks("SZSE.300334", "2017-05-12 00:00:00", "2017-05-12 15:00:00"); tickLists.AddRange(tickList); DateTime startTimeUTC = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); foreach (Tick tick in tickLists) { tick.strtime = startTimeUTC.AddSeconds(tick.utc_time).ToString(); } ShowData(tickLists.OfType <object>().ToList()); this.label1.Text = tickLists.Count.ToString(); }
public virtual void Unsubscribe(string inst, string period) { lock (locker) { MdApi.MD_Unsubscribe(inst, period); } }
public void Disconnect() { lock (locker) { MdApi.MD_Disconnect(); } }
public async Task <IActionResult> UploadAndProcess(IFormFile file) { var content = new List <String>(); if (file != null && file.Length > 0) { if (SystemConstants.AcceptedExtensions.Contains(Path.GetExtension(file.FileName).ToUpperInvariant())) { using (var Reader = new System.IO.StreamReader(file.OpenReadStream())) { string inputLine = ""; while ((inputLine = await Reader.ReadLineAsync()) != null) { content.Add(inputLine); } Reader.Close(); } //Upload var res = await MdApi.PostPNLAsync(content); return(PartialView("_PartialPassengerList", res)); } else { return(BadRequest(new { Result = false, Message = "please upload txt only" })); } } return(BadRequest(new { Result = false, Message = "Empty file" })); }
public void SubscribeHistory(string inst, string period, string beginTime, string endTime) { lock (locker) { MdApi.MD_SubscribeHistory(inst, period, beginTime, endTime); } }
public void ReqQryQuotation(ref CWtpSymbolField pInstrumentID) { lock (locker) { MdApi.ReqQryQuotation(ref pInstrumentID); } }
public void ReqUserLogout(ref CWtpUserLogoutField pReqUserLogoutField) { lock (locker) { MdApi.ReqUserLogout(ref pReqUserLogoutField); } }
public void ReqQrySymbol() { lock (locker) { MdApi.ReqQrySymbol(); } }
public void ReqUserLogin(ref CWtpReqUserLoginField pReqUserLoginField) { lock (locker) { MdApi.ReqUserLogin(ref pReqUserLoginField); } }
public void RegisterFront(string pszFrontAddress) { lock (locker) { MdApi.RegisterFront(pszFrontAddress); } }
public virtual void UnsubscribeQuote(string inst, string szExchange) { lock (locker) { MdApi.MD_UnsubscribeQuote(inst, szExchange); } }
public void ReqUnSubQuotation(ref CWtpSymbolField[] pInstrumentID) { lock (locker) { MdApi.ReqUnSubQuotation(pInstrumentID, pInstrumentID.Length); } }
public void Dispose() { lock (locker) { MdApi.Release(); GC.SuppressFinalize(this); } }
public void CTP_RegMD() { MdApi.CTP_RegOnRtnDepthMarketData_Tick(OnRtnDepthMarketData_Tick_2); MdApi.CTP_RegOnRtnDepthMarketData_KLine(OnRtnDepthMarketData_KLine_2); MdApi.CTP_RegOnHistory_Tick(OnHistoryTick_2); MdApi.CTP_RegOnHistory_KLine(OnHistoryKLine_2); MdApi.CTP_RegMDOnConnect(OnConnect_2); MdApi.CTP_RegMDOnDisconnect(OnDisconnect_2); MdApi.CTP_RegMDOnRspError(OnRspError_2); }
public void WTP_RegMD() { MdApi.WTP_RegOnFrontConnected(OnConnect_2); MdApi.WTP_RegOnFrontDisconnected(OnDisconnect_2); MdApi.WTP_RegOnRspUserLogin(OnRspUserLogin_2); MdApi.WTP_RegOnRspUserLogout(OnRspUserLogout_2); MdApi.WTP_RegOnRspError(OnRspError_2); MdApi.WTP_RegOnRspQrySymbol(OnRspQrySymbol_2); MdApi.WTP_RegOnRspQryQuotation(OnRspQryQuotation_2); MdApi.WTP_RegOnRtnQuotation(OnRtnQuotation_2); }
public virtual void UnsubscribeQuote(string inst, string szExchange) { lock (locker) { MdApi.MD_UnsubscribeQuote(IntPtrKey, inst, szExchange); inst.Split(new char[2] { ';', ',' }).ToList().ForEach(x => _SubscribedQuotes.Remove(x) ); } }
private void Disconnect_MD() { lock (_lock) { if (null != Api && IntPtr.Zero != Api) { MdApi.MD_RegMsgQueue2MdApi(Api, IntPtr.Zero); MdApi.MD_ReleaseMdApi(Api); Api = IntPtr.Zero; } IsConnected = false; } }
static void Main(string[] args) { MdApi.CTP_ReadConfigFile("F:\\CTP-MATLAB\\bin\\ConfigFile.xml"); MdApi.CTP_RegMDOnConnect(OnConnect); MdApi.CTP_RegOnRtnDepthMarketData_Tick(OnRtnDepthMarketData_Tick); MdApi.MD_Connect(); TdApi.TD_Connect(); while (true) { } }
private void Connect_MD() { lock (_lock) { if (null == Api || IntPtr.Zero == Api) { Api = MdApi.MD_CreateMdApi(); MdApi.CTP_RegOnRtnDepthMarketData(m_pMsgQueue, _fnOnRtnDepthMarketData_Holder); MdApi.MD_RegMsgQueue2MdApi(Api, m_pMsgQueue); MdApi.MD_Connect(Api, tempPath, string.Join(";", server.MarketData.ToArray()), server.BrokerID, account.InvestorId, account.Password); } } }
private void Disconnect_MD() { lock (_lockMd) { if (null != m_pMdApi && IntPtr.Zero != m_pMdApi) { MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, IntPtr.Zero); MdApi.MD_ReleaseMdApi(m_pMdApi); m_pMdApi = IntPtr.Zero; } _bMdConnected = false; } }
public override void Disconnect() { lock (locker) { if (null != IntPtrKey && IntPtr.Zero != IntPtrKey) { MdApi.MD_RegMsgQueue2MdApi(IntPtrKey, IntPtr.Zero); MdApi.MD_ReleaseMdApi(IntPtrKey); IntPtrKey = IntPtr.Zero; } base.Disconnect(); } }
private void button9_Click_1(object sender, EventArgs e) { MdApi md = MdApi.Instance; int ret = md.Init("*****@*****.**", "Chs771005", MDMode.MD_MODE_NULL); if (ret != 0) { //登录失败 return; } List <StockAdjustFactor> stockAdjs = md.GetStockAdj("SZSE.300044", "2018-01-01", "2018-08-06"); ShowData(stockAdjs.OfType <object>().ToList()); }
private void button7_Click(object sender, EventArgs e) { MdApi md = MdApi.Instance; int ret = md.Init("*****@*****.**", "Chs771005", MDMode.MD_MODE_NULL); if (ret != 0) { //登录失败 return; } List <MarketIndex> marketindex = md.GetLastNMarketIndex("SHSE.600004", 3); ShowData(marketindex.OfType <object>().ToList()); }
public override void Connect() { lock (locker) { base.Connect(); IntPtrKey = MdApi.MD_CreateMdApi(); MdApi.MD_RegMsgQueue2MdApi(IntPtrKey, _MsgQueue.Queue); MdApi.MD_Connect(IntPtrKey, _TempPath, _Front.MarketDataAddress, _Front.BrokerId, _Account.InvestorId, _Account.Password); } }
private void button4_Click(object sender, EventArgs e) { MdApi md = MdApi.Instance; int ret = md.Init("*****@*****.**", "Chs771005", MDMode.MD_MODE_NULL); if (ret != 0) { //登录失败 return; } List <Instrument> insts = md.GetInstruments("SHSE", 1, 0); ShowData(insts.OfType <object>().ToList()); this.label1.Text = insts.Count.ToString(); }
public virtual void SubscribeQuote(string inst, string szExchange) { lock (locker) { MdApi.MD_SubscribeQuote(IntPtrKey, inst, szExchange); inst.Split(new char[2] { ';', ',' }).ToList().ForEach(x => { if (!string.IsNullOrWhiteSpace(x)) { _SubscribedQuotes.Add(x); } }); } }
public async Task <IActionResult> AddRecord(PassengerRecord record) { if (string.IsNullOrEmpty(record.Key) || string.IsNullOrEmpty(record.LastName)) { return(BadRequest(new { Result = false, Message = "Key & last name must not empty" })); } if (record.Key.Length != 6) { return(BadRequest(new { Result = false, Message = "key length must be 6 letters" })); } var res = await MdApi.AddRecord(record); return(PartialView("_PartialPassengerList", res)); }
//建立行情 private void Connect_MD() { lock (_lockMd) { if (_bWantMdConnect && (null == m_pMdApi || IntPtr.Zero == m_pMdApi)) { m_pMdApi = MdApi.MD_CreateMdApi(); MdApi.XSpeed_RegOnMarketData(m_pMsgQueue, _fnOnMarketData_Holder); MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, m_pMsgQueue); MdApi.MD_Connect(m_pMdApi, string.Join(";", server.MarketData.ToArray()), account.InvestorId, account.Password, 0); //向单例对象中注入操作用句柄 XSpeedAPI.GetInstance().__RegMdApi(m_pMdApi); } } }
//建立行情 private void Connect_MD() { lock (_lockMd) { if (_bWantMdConnect && (null == m_pMdApi || IntPtr.Zero == m_pMdApi)) { m_pMdApi = MdApi.MD_CreateMdApi(); MdApi.CTP_RegOnRtnDepthMarketData(m_pMsgQueue, _fnOnRtnDepthMarketData_Holder); MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, m_pMsgQueue); MdApi.MD_Connect(m_pMdApi, _newTempPath, string.Join(";", server.MarketData.ToArray()), server.BrokerID, account.InvestorId, account.Password); //向单例对象中注入操作用句柄 CTPAPI.GetInstance().__RegMdApi(m_pMdApi); } } }
/// <summary> /// 初始化 MD 对象 /// </summary> public static void initMd() { if (isInit) { return; } //本例子演示如何用行情API提取数据 md = MdApi.Instance; int ret = md.Init("18221685724", "yjb_1983"); if (ret != 0) { isInit = false; //登录失败 return; } else { isInit = true; } }