public void Basics() { Index i = new Index(""); Assert.That(i != null); Assert.That(!i.isValid); i = new Index("/SPX"); Assert.That(i.isValid); }
public Index(Index copythisidx) { Name = copythisidx.Name; last = copythisidx.Value; open = copythisidx.open; high = copythisidx.high; low = copythisidx.low; close = copythisidx.close; date = copythisidx.date; time = copythisidx.time; }
public void newIndexTick(Index itick) { if (this.InvokeRequired) this.Invoke(new IndexDelegate(newIndexTick), new object[] { itick }); else { if (!itick.isValid) return; for (int i = 0; i < index.Count; i++) if ((client[i] != null) && (index[i].Contains(itick.Name))) WMUtil.SendMsg(itick.Serialize(), TL2.TICKNOTIFY, Handle, client[i]); } }
bool SaveIndex(Index i) { if ((i == null) || (i.Name == null) || (i.Name == "") || !Index.isIdx(i.Name)) return false; if (!filedict.ContainsKey(i.Name)) { try { string fn = _path + @"/" + i.Name + i.Date + ".IDX"; filedict.Add(i.Name, new StreamWriter(fn, true)); } catch (Exception) { return false; } } try { filedict[i.Name].WriteLine(i.Serialize()); } catch (Exception) { return false; } filedict[i.Name].Flush(); return true; }
void tl_gotIndexTick(Index idx) { ta.Save(idx); }
public bool Save(Index i) { return SaveIndex(i); }
void Convert(string file) { StreamReader epf = new StreamReader(file); Stock s = eSigTick.InitEpf(epf); string symbol = s.Symbol.Replace("//", ""); if (symmap.ContainsKey(symbol)) symbol = symbol.Replace(symbol, symmap[symbol]); string filename = symbol + s.Date + ".IDX"; d("Attempting to convert: "+file + " -> " + filename); StreamWriter idx; try { idx = new StreamWriter(filename,false); } catch (Exception ex) { d(ex.Message); return; } decimal o = 0; decimal h = 0; decimal l = 100000000000; while (!epf.EndOfStream) { eSigTick et = new eSigTick(); et.sym = prefix + symbol; try { string line = epf.ReadLine(); // get our tick from EPF et.Load(line); if (et.FullQuote) continue; } catch (Exception ex) { d(ex.Message); continue; } // set o/h/l/c decimal v = et.trade; if (o==0) o = v; if (v>h) h = v; if (v<l) l = v; Index i = new Index(et.sym,v,o,h,l,v,et.date,et.time); // map to our index idx.WriteLine(i.Serialize()); // write our index } idx.Close(); epf.Close(); d("Finished converting "+filename); }
void tl_gotIndexTick(Index idx) { tl_gotTick(idx.ToTick()); }
/// <summary> /// Deserializes the specified string into an Index object. Used for reading IDX files. /// </summary> /// <param name="val">The index in string form.</param> /// <returns></returns> public static Index Deserialize(string val) { string[] r = val.Split(','); Index i = null; try { i = new Index(r[(int)iorder.sym], Convert.ToDecimal(r[(int)iorder.value]), Convert.ToDecimal(r[(int)iorder.open]), Convert.ToDecimal(r[(int)iorder.high]), Convert.ToDecimal(r[(int)iorder.low]), Convert.ToDecimal(r[(int)iorder.close]), Convert.ToInt32(r[(int)iorder.date]), Convert.ToInt32(r[(int)iorder.time])); } catch (InvalidCastException) { } return i; }
public static Index FromFile(string filename) { System.IO.StreamReader sr = new System.IO.StreamReader(filename); Index i = new Index(); i = Index.Deserialize(sr.ReadLine()); i._histfile = sr; return i; }
void IndexBox_GotIndex(Index idx) { athigh = (idx.Value == idx.High); indexticks++; }
/// <summary> /// Send this box a new Index tick. /// </summary> /// <param name="i">The latest index update.</param> public void NewIndex(Index i) { if (GotIndex!=null) GotIndex(i); }
public void Remove(Index i) { l.Remove(i); }
public void Add(Index i) { if (Index.isIdx(i.Name)) l.Add(i); }
void h_GotIndex(Index idx) { tl.newIndexTick(idx); }