Ejemplo n.º 1
0
        public void Basics()
        {
            Index i = new Index("");
            Assert.That(i != null);
            Assert.That(!i.isValid);
            i = new Index("/SPX");
            Assert.That(i.isValid);

        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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]);
     }
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 void tl_gotIndexTick(Index idx)
 {
     ta.Save(idx);
 }
Ejemplo n.º 6
0
 public bool Save(Index i) { return SaveIndex(i); }
Ejemplo n.º 7
0
		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);
		}
Ejemplo n.º 8
0
 void tl_gotIndexTick(Index idx)
 {
     tl_gotTick(idx.ToTick());
 }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 void IndexBox_GotIndex(Index idx)
 {
     athigh = (idx.Value == idx.High);
     indexticks++;
 }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
 public void Remove(Index i) { l.Remove(i); }
Ejemplo n.º 14
0
 public void Add(Index i) { if (Index.isIdx(i.Name)) l.Add(i); }
Ejemplo n.º 15
0
 void h_GotIndex(Index idx)
 {
     tl.newIndexTick(idx);
 }