public void Basics() { Stock s = new Stock(""); Assert.That(s != null); Assert.That(!s.isValid); s = new Stock("TST"); Assert.That(s.isValid); }
public void BasketBasics() { MarketBasket mb = new MarketBasket(); Assert.That(mb != null); Stock i = new Stock("IBM"); mb = new MarketBasket(i); Assert.That(mb.hasStock); mb.Remove(i); Assert.That(!mb.hasStock); mb.Add(new Stock("LVS")); Assert.That(mb.Get(0).Symbol=="LVS",mb[0].ToString()); mb.Add(new Stock("IBM")); Assert.That(mb[1].Symbol=="IBM"); MarketBasket newbasket = new MarketBasket(new Stock("FDX")); newbasket.Add(mb); mb.Clear(); Assert.That(mb.Count==0); Assert.That(newbasket.Count==3); }
public void Add(Stock s) { if (s.isValid) stocks.Add(s); }
public MarketBasket(Stock firststock) { Add(firststock); }
void tw_Alerted(Stock stock) { if (emailbox.Text != "") Email.Send(emailbox.Text, emailbox.Text, "TickDelay " + stock.Symbol, "No ticks received for " + tw.DefaultWait + " seconds." + stock.ToString()); }
public Stock ToStock() { if (!HasBar()) throw new Exception("Can't generate a stock instance from an empty barlist!"); Stock s = new Stock(Symbol, this.RecentBar.Bardate); s.DayHigh = BarMath.HH(this); s.DayLow = BarMath.LL(this); s.DayOpen = this[0].Open; s.DayClose = this.RecentBar.Close; return s; }
private void downloaddata(Stock s) { downloaddata(s, true); }
Stock StockFromFileName(string filename) { string ds = System.Text.RegularExpressions.Regex.Match(filename, "([0-9]{8})[.]", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Result("$1"); string sym = filename.Replace(ds, "").Replace(".EPF",""); Stock s = new Stock(sym); s.Date = Convert.ToInt32(ds); return s; }
private bool loadfile(string path) { string f = path; if (isBOX(f)) { boxdll = f; boxlist.DropDownItems.Clear(); List<string> l = Util.GetBoxList(boxdll); if (System.IO.File.Exists(f)) if (!isRecent(f)) recent.DropDownItems.Add(f); for (int i = 0; i < l.Count; i++) boxlist.DropDownItems.Add(l[i]); status("Found " + l.Count + " boxes in DLL."); return true; } else if (isEPF(f)) { tickfile = f; sr = new System.IO.StreamReader(f); stock = eSigTick.InitEpf(sr); if (System.IO.File.Exists(f)) if (!isRecent(f)) recent.DropDownItems.Add(f); status("Loaded "+stock.Symbol+" for "+Util.ToDateTime(stock.Date)); LoadIndexFiles(stock.Date); return true; } return false; }
public fetchstate(Stock stock, bool NewChart) { s = stock; newwind = NewChart; }
private void downloaddata(Stock s, bool newChart) { if (!s.isValid) return; Uri goog = new Uri(GOOGURL + s.Symbol); fetchstate f = new fetchstate(s, newChart); try { client.DownloadStringAsync(goog, f); } catch (WebException) { return; } }
/// <summary> /// Initilize the reading of an EPF file and return the header as a Stock object. /// </summary> /// <param name="EPFfile">The EP ffile.</param> /// <returns></returns> public static Stock InitEpf(StreamReader EPFfile) { StreamReader cf = EPFfile; string symline = cf.ReadLine(); string dateline = cf.ReadLine(); Regex se = new Regex("=[a-z-A-Z]+"); Regex dse = new Regex(@"; Date=([0-9]+)/([0-9]+)/([0-9]+).*$"); MatchCollection r = se.Matches(symline, 0); string t = r[0].Value; string symbol = t.Substring(1, t.Length - 1); Stock s = new Stock(symbol.ToUpper()); string date = dateline.Contains("/") ? dse.Replace(dateline, "20$3$1$2") : Regex.Match(dateline, "[0-9]+").ToString(); s.Date = Convert.ToInt32(date); return s; }
/// <summary> /// Create an epf file header. /// </summary> /// <param name="s">The stock.</param> /// <returns></returns> public static string EPFheader(Stock s) { return EPFheader(s.Symbol,s.Date); }
/// <summary> /// Create a stock-equivalent instance from this Index. /// </summary> /// <returns></returns> public Stock ToStock() { Stock s = new Stock(StockifyIndex(Name), this.Date); return s; }
public void Remove(Stock s) { stocks.Remove(s); }
public void test_alert(Stock s) { alertssent++; Console.WriteLine(s.Symbol + " is overdue."); }
public fetchstate(Stock stock) : this(stock, true) { }
void c_FetchStock(Stock stock) { downloaddata(stock,false); }
/// <summary> /// Create a stock-equivalent instance from this Index. /// </summary> /// <returns></returns> public Stock ToStock() { Stock s = new Stock(StockifyIndex(Name), this.Date); return(s); }