public void Subscribe(int topicID, object[] topicParams) { if (connected) { rtdServer.ConnectData(topicID, topicParams, true); } }
void Sub(string channel, string field) { Console.WriteLine($"Subscribing: topic={_topic}, exchange={channel}, field={field}"); var a = new[] { "localhost", channel, field }; Array crappyArray = a; bool newValues = false; _rtd.ConnectData(_topic++, ref crappyArray, ref newValues); }
void Sub(string instrument, string field) { Console.WriteLine("Subscribing: topic={0}, instr={1}, field={2}", _topic, instrument, field); var a = new[] { "GDAX", instrument, field }; Array crappyArray = a; bool newValues = false; _rtd.ConnectData(_topic++, ref crappyArray, ref newValues); }
public object ConnectData(int topicId, ref Array strings, ref bool newValues) { try { using (XlCall.Suspend()) { if (_rtdServer != null) { return(_rtdServer.ConnectData(topicId, ref strings, ref newValues)); } return(_ConnectData(topicId, ref strings, ref newValues)); } } catch (Exception e) { Logger.RtdServer.Error("Error in RTD server {0} ConnectData: {1}", _progId, e.ToString()); return(null); } }
void Sub(string origin, string instrument, string field) { Console.WriteLine("Subscribing: topic={0}, instr={1}, field={2}, origin={3}", _topic, instrument, field, origin); var a = new[] { origin, instrument, field }; Array crappyArray = a; topics.Add(_topic, crappyArray); bool newValues = false; _rtd.ConnectData(_topic++, ref crappyArray, ref newValues); }
public void rtddata() { string targetpath = ConfigurationManager.AppSettings["targetpathforcombo"]; string formatname = ConfigurationManager.AppSettings["format"]; CommandManager.InvalidateRequerySuggested(); try { if (File.Exists(targetpath + "\\realtimemetastock.csv")) { File.Delete(targetpath + "\\realtimemetastock.csv"); } if (!Directory.Exists(targetpath + "\\Fchart")) { Directory.CreateDirectory(targetpath + "\\Fchart"); } if (File.Exists(targetpath + "\\realtimefchart.csv")) { File.Copy(targetpath + "\\realtimefchart.csv", targetpath + "\\Fchart\\Finalrealtimefchart.csv", true); File.Delete(targetpath + "\\realtimefchart.csv"); } if (File.Exists(targetpath + "\\YahooRealTimeData.csv")) { File.Delete(targetpath + "\\YahooRealTimeData.csv"); } int countformappingsymbol = 0; List <string> mapsymbol = new List <string>(); using (var reader1 = new StreamReader("C:\\myshubhalabha\\shubha_mapping_symbol.txt")) { string line1 = null; while ((line1 = reader1.ReadLine()) != null) { mapsymbol.Add(line1); } } yahoortdata.Clear(); int flagfortotaldatacount = 0; using (var reader = new StreamReader(targetpath + "\\NESTRt.txt")) { string line = null; int RTtopiccount = 0; yahoortdata.Clear(); while ((line = reader.ReadLine()) != null) { CommandManager.InvalidateRequerySuggested(); yahoortname.Add(line); Array retval; int j = m_server.Heartbeat(); bool bolGetNewValue = true; object[] arrayForSymbol = new object[2]; // RTtopiccount++; //imp it change topic id CommandManager.InvalidateRequerySuggested(); arrayForSymbol[0] = line; arrayForSymbol[1] = "Trading Symbol"; Array sysArrParams = (Array)arrayForSymbol; m_server.ConnectData(RTtopiccount, sysArrParams, bolGetNewValue); RTtopiccount++; //imp it change topic id object[] arrayForLTT = new object[2]; CommandManager.InvalidateRequerySuggested(); arrayForLTT[0] = line; arrayForLTT[1] = "LUT"; Array sysArrParams1 = (Array)arrayForLTT; m_server.ConnectData(RTtopiccount, sysArrParams1, bolGetNewValue); RTtopiccount++; //imp it change topic id object[] arrayForLTP = new object[2]; arrayForLTP[0] = line; arrayForLTP[1] = "LTP"; Array sysArrParams2 = (Array)arrayForLTP; m_server.ConnectData(RTtopiccount, sysArrParams2, bolGetNewValue); CommandManager.InvalidateRequerySuggested(); RTtopiccount++; //imp it change topic id CommandManager.InvalidateRequerySuggested(); object[] arrayForVolume = new object[2]; arrayForVolume[0] = line; arrayForVolume[1] = "Volume Traded Today"; Array sysArrParams3 = (Array)arrayForVolume; m_server.ConnectData(RTtopiccount, sysArrParams3, bolGetNewValue); CommandManager.InvalidateRequerySuggested(); RTtopiccount++; //imp it change topic id object[] arrayForopenint = new object[2]; arrayForopenint[0] = line; arrayForopenint[1] = "Open Interest"; Array sysArrParams4 = (Array)arrayForopenint; m_server.ConnectData(RTtopiccount, sysArrParams4, bolGetNewValue); RTtopiccount++; //imp it change topic id CommandManager.InvalidateRequerySuggested(); retval = m_server.RefreshData(10); for (int count = 0; count <= 4; count++) { m_server.DisconnectData(count); } foreach (var item in retval) { yahoortdata.Add(item.ToString()); CommandManager.InvalidateRequerySuggested(); } m_server.ServerTerminate(); flagfortotaldatacount++; CommandManager.InvalidateRequerySuggested(); } CommandManager.InvalidateRequerySuggested(); string tempfilepath = targetpath + "\\RealTimeData.txt"; //log4net.Config.XmlConfigurator.Configure(); //ILog log = LogManager.GetLogger(typeof(MainWindow)); //log.Debug("Data Capturing At" + DateTime.Now.TimeOfDay); string storeinfile1 = ""; CommandManager.InvalidateRequerySuggested(); //c=c+2 we not want 1st 3rd 5th and so on values. int value = 5; int flagtocheckfirstvaluefordate = 0; for (int j = 5; j < yahoortdata.Count - 1; j = j + 10) { CommandManager.InvalidateRequerySuggested(); int c; value = j + 5; if (flagtocheckfirstvaluefordate == 0) { storeinfile1 = storeinfile1; flagtocheckfirstvaluefordate = 1; CommandManager.InvalidateRequerySuggested(); } else { storeinfile1 = storeinfile1 + " "; flagtocheckfirstvaluefordate = 1; } int flagmap = 0; for (c = j; c <= value - 1; c = c + 1) { CommandManager.InvalidateRequerySuggested(); if (flagmap == 0) { storeinfile1 = storeinfile1 + " " + mapsymbol[countformappingsymbol]; countformappingsymbol++; flagmap++; } else { storeinfile1 = storeinfile1 + " " + yahoortdata[c].ToString(); } } CommandManager.InvalidateRequerySuggested(); storeinfile1 = storeinfile1 + "\r\n"; } //if (storeinfile1.Contains(",")) //{ // storeinfile1.Replace(",", "."); //} //if count is greater than data required then dont write it in file if (yahoortdata.Count <= flagfortotaldatacount * 10) { //<TICKER>,<NAME>,<PER>,<DATE>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>,<OPENINT> using (var writer = new StreamWriter(tempfilepath)) writer.WriteLine(storeinfile1); if (formatname == "Amibroker") { //string realtimemetastock = ""; //string datastoreforami = ""; //int count = 0; //using (var reader1 = new StreamReader(tempfilepath)) //{ // string line1 = null; // while ((line1 = reader1.ReadLine()) != null) // { // string[] words = line1.Split(' '); // if (line1 != "") // { // if (count == 0) // { // realtimemetastock = realtimemetastock + "," + words[0] + "," + words[1] + "," + words[2] + "," + words[3] + "," + words[4] + "," + words[5]; // count++; // } // else // { // realtimemetastock = realtimemetastock + "," + words[1] + "," + words[2] + "," + words[3] + "," + words[4] + "," + words[5] + "," + words[6]; // } // realtimemetastock = realtimemetastock + "\r\n"; // } // } //} string filename = targetpath + "\\AmibrokerRTdata.txt"; // System.Windows.MessageBox.Show(realtimemetastock); using (var writer = new StreamWriter(filename)) writer.WriteLine(storeinfile1); } if (formatname == "Fchart") { int count = 0; using (var reader1 = new StreamReader(tempfilepath)) { string line1 = null; string realtimemetastock = ""; while ((line1 = reader1.ReadLine()) != null) { string[] words = line1.Split(' '); if (line1 != "") { //if (count == 0) //{ // realtimemetastock = words[1] + "," + words[1] + "," + "I" + "," + words[0] + "," + words[2] + "," + words[3] + "," + words[3] + "," + words[3] + "," + words[3] + "," + words[4] + "," + words[5]; // count++; //} //else //{ // realtimemetastock = words[2] + "," + words[2] + "," + "I" + "," + words[1] + "," + words[3] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[5] + "," + words[6]; //} //realtimemetastock = words[1] + "," + words[1] + "," + "I" + "," + words[2] + "," + words[3] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[5]; if (words[1] == "") { string[] timeforfchart = words[4].Split(':'); string timetostore = timeforfchart[0] + ":" + timeforfchart[1]; realtimemetastock = words[2] + "," + words[3] + "," + timetostore + "," + words[5] + "," + words[5] + "," + words[5] + "," + words[5] + "," + words[6]; } else { string[] timeforfchart = words[3].Split(':'); string timetostore = timeforfchart[0] + ":" + timeforfchart[1]; realtimemetastock = words[1] + "," + words[2] + "," + timetostore + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[5]; } string filename = targetpath + "\\realtimefchart.csv"; // System.Windows.MessageBox.Show(realtimemetastock); using (var writer = new StreamWriter(filename, true)) writer.WriteLine(realtimemetastock); } } } } if (formatname == "Metastock") { int count = 0; string filename = ""; using (var reader1 = new StreamReader(tempfilepath)) { string line1 = null; string realtimemetastock = ""; while ((line1 = reader1.ReadLine()) != null) { if (line1 != "") { string[] words = line1.Split(' '); //if (count == 0) //{ // if (words[1].Contains('-')) // { // string[] ticker =words[1].Split('-'); // words[1] = ticker[0]; // } if (words[1] == "") { realtimemetastock = words[2] + "," + words[2] + "," + "I" + "," + words[3] + "," + words[4] + "," + words[5] + "," + words[5] + "," + words[5] + "," + words[5] + "," + words[6]; } else { realtimemetastock = words[1] + "," + words[1] + "," + "I" + "," + words[2] + "," + words[3] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[5]; } // count++; //} //else //{ // if (words[2].Contains('-')) // { // string[] ticker = words[1].Split('-'); // words[2] = ticker[0]; // } // realtimemetastock = words[2] + "," + words[2] + "," + "I" + "," + words[1] + "," + words[3] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[4] + "," + words[5] + "," + words[6]; //} realtimemetastock = "<TICKER>,<NAME>,<PER>,<DATE>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOLUME>\r\n" + realtimemetastock; filename = targetpath + "\\realtimemetastock.csv"; // System.Windows.MessageBox.Show(realtimemetastock); using (var writer = new StreamWriter(filename, true)) writer.WriteLine(realtimemetastock); } } } if (!Directory.Exists(targetpath + "\\Intraday\\Metastock")) { Directory.CreateDirectory(targetpath + "\\Intraday\\Metastock"); } // commandpromptcall(filename, targetpath + "\\Intraday\\Metastock\\realtimemetastock"); try { string filepath = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString(); string processtostart = filepath.Substring(0, filepath.Length - 18) + "asc2ms.exe"; File.Copy(processtostart, targetpath + "\\asc2ms.exe", true); } catch { } System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; //startInfo.Arguments = "/C C:\\asc2ms.exe -f C:\\data\\Metastock\\M.csv -r r -o C:\\data\\Metastock\\google\\e"; startInfo.Arguments = "/C " + targetpath + "\\asc2ms.exe -f " + filename + " -r r -o " + targetpath + "\\Intraday\\Metastock\\realtimemetastock"; // startInfo.Arguments = @"/C C:\asc2ms.exe -f C:\Documents and Settings\maheshwar\My Documents\BSe\Downloads\Googleeod -r r -o C:\Documents and Settings\maheshwar\My Documents\BSe\Downloads\Googleeod\Metastock\a" ; process.StartInfo = startInfo; process.Start(); } } CommandManager.InvalidateRequerySuggested(); if (formatname == "Amibroker") { ExcelType = Type.GetTypeFromProgID("Broker.Application"); ExcelInst = Activator.CreateInstance(ExcelType); args[0] = Convert.ToInt16(0); args[1] = targetpath + "\\RealTimeData.txt"; args[2] = "ShubhaRt.format"; ExcelType.InvokeMember("Import", BindingFlags.InvokeMethod | BindingFlags.Public, null, ExcelInst, args); CommandManager.InvalidateRequerySuggested(); ExcelType.InvokeMember("RefreshAll", BindingFlags.InvokeMethod | BindingFlags.Public, null, ExcelInst, new object[1] { "" }); } } } catch (Exception ex) { } }
public void nestdata() { string chktmp = ConfigurationManager.AppSettings["txtTargetFolderforami"]; string timetorep = ""; List <string> mappingsymbolname = new List <string>(); using (var reader1 = new StreamReader(chktmp + "\\ShubhaRtmappingsymbollist.txt")) { string line1 = null; while ((line1 = reader1.ReadLine()) != null) { // MessageBox.Show(line1); mappingsymbolname.Add(line1); } } try { yahoortdata.Clear(); int countformappingsymbol = 0; int flagfortotaldatacount = 0; int predatacount = 0; //read symbol list from file to download real time data using (var reader = new StreamReader(chktmp + "\\ShubhaRtsymbollist.txt")) { string line = null; int RTtopiccount = 0; //take terminal name of perticular topic string LTT1 = ConfigurationManager.AppSettings["LTT"]; string LTP1 = ConfigurationManager.AppSettings["LTP"]; string Volume1 = ConfigurationManager.AppSettings["Volume"]; string Openinterest1 = ConfigurationManager.AppSettings["Openinterest"]; string Open1 = ConfigurationManager.AppSettings["Open"]; string High1 = ConfigurationManager.AppSettings["High"]; string Low1 = ConfigurationManager.AppSettings["Low"]; string Ask1 = ConfigurationManager.AppSettings["Ask"]; string Bid1 = ConfigurationManager.AppSettings["Bid"]; string Preset1 = ConfigurationManager.AppSettings["preset"]; string servername1 = ConfigurationManager.AppSettings["servername"]; string refreshtime1 = ConfigurationManager.AppSettings["interval"]; while ((line = reader.ReadLine()) != null) { Array retval; int i = 0; int j = m_server.Heartbeat(); bool bolGetNewValue = true; object[,] arrayForSymbol = new object[2, 9]; //inserting topic if (LTT1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = LTT1; i++; } if (LTP1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = LTP1; i++; } if (Volume1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Volume1; i++; } if (Openinterest1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Openinterest1; i++; } if (Open1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Open1; i++; } if (High1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = High1; i++; } if (Low1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Low1; i++; } if (Ask1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Ask1; i++; } if (Bid1 != "") { arrayForSymbol[0, i] = line; arrayForSymbol[1, i] = Bid1; i++; } for (int j1 = 0; j1 < i; j1++) { object[] array = new object[2]; array[0] = arrayForSymbol[0, j1]; array[1] = arrayForSymbol[1, j1]; Array sysArrParams = (Array)array; m_server.ConnectData(j1, sysArrParams, bolGetNewValue); } retval = m_server.RefreshData(10); for (int count = 0; count <= i; count++) { m_server.DisconnectData(count); } foreach (var item in retval) { yahoortdata.Add(item.ToString()); } m_server.ServerTerminate(); flagfortotaldatacount++; string[] wordsdata = line.Split('|'); if (wordsdata[1].Contains("-")) { wordsdata[1] = wordsdata[1].Substring(0, wordsdata[1].Length - 3); } string datatostore = ""; int countofarray = 0; for (int filecount = i; filecount < i + i; filecount++) { datatostore = datatostore + "," + yahoortdata[filecount]; countofarray++; } // MessageBox.Show("asdasd------------"+mappingsymbolname[1]); // string tempfilepath = chktmp + "\\" + wordsdata[1] + ".csv"; string tempfilepath = chktmp + "\\" + mappingsymbolname[countformappingsymbol].ToString() + ".csv"; countformappingsymbol++; //string tempfilepath = chktmp + "\\SHANTESH.csv"; if (LTT1 == "LUT") { string[] sepratedateandtime = datatostore.Split(' '); //MessageBox.Show(sepratedateandtime[1]); datatostore = "," + sepratedateandtime[1]; } string[] datacheck = datatostore.Split(','); if (countofarray < 4) { } else { if (datacheck[1].Length < 8) { } else { DateTime date = DateTime.Today.Date; //TimeSpan time = DateTime.Now.TimeOfDay; //DateTime dateTime = date.Add(time); string predata = ConfigurationManager.AppSettings["predata"]; // MessageBox.Show(predata[predatacount] + "====" + datatostore); if (predata != datatostore) { datacheck = datatostore.Split(','); try { if (datacheck[4] == "") { } using (var writer = new StreamWriter(tempfilepath, true)) writer.WriteLine(date.ToShortDateString() + datatostore); } catch { } } } config.AppSettings.Settings.Remove("predata"); config.AppSettings.Settings.Add("predata", datatostore); config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appSettings"); } yahoortdata.Clear(); } } } catch (Exception ex) { // MessageBox.Show(ex.Message ); } }
public void rtddata() { try { yahoortdata.Clear(); using (var reader = new StreamReader("c:\\ShubhaRtsymbollist.txt")) { string line = null; int i = 0; while ((line = reader.ReadLine()) != null) { yahoortname.Add(line); Array retval; MethodInfo method; Type type = Type.GetTypeFromProgID("now.scriprtd"); IRtdServer m_server = (IRtdServer)Activator.CreateInstance(type); int j = m_server.Heartbeat(); if (flag == 0) { bool bolGetNewValue = true; object[] array = new object[3]; array[0] = "MktWatch"; array[1] = line; array[2] = "Last Trade Time"; Array sysArrParams = (Array)array; m_server.ConnectData(i, sysArrParams, bolGetNewValue); i++; object[] array1 = new object[3]; array1[0] = "MktWatch"; array1[1] = line; array1[2] = "Best Buy Rate"; Array sysArrParams1 = (Array)array1; m_server.ConnectData(i, sysArrParams1, bolGetNewValue); i++; object[] array2 = new object[3]; array2[0] = "MktWatch"; array2[1] = line; array2[2] = "Best Buy Qty"; Array sysArrParams2 = (Array)array2; m_server.ConnectData(i, sysArrParams2, bolGetNewValue); retval = m_server.RefreshData(10); i++; //imp it change topic id foreach (var item in retval) { yahoortdata.Add(item.ToString()); } } } string tempfilepath = "C:\\YahooRealTimeData.txt"; log4net.Config.XmlConfigurator.Configure(); ILog log = LogManager.GetLogger(typeof(MainWindow)); log.Debug("Data Capturing At" + DateTime.Now.TimeOfDay); using (var writer = new StreamWriter(tempfilepath)) for (int c = 1; c <= yahoortdata.Count - 1; c = c + 2) { writer.WriteLine(yahoortdata[c].ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }