示例#1
0
 public void Basics()
 {
     Stock s = new Stock("");
     Assert.That(s != null);
     Assert.That(!s.isValid);
     s = new Stock("TST");
     Assert.That(s.isValid);
 }
示例#2
0
 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);
 }
示例#3
0
 public void Add(Stock s) { if (s.isValid) stocks.Add(s); }
示例#4
0
 public MarketBasket(Stock firststock)
 {
     Add(firststock);
 }
示例#5
0
 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());
 }
示例#6
0
 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;
 }
示例#7
0
 private void downloaddata(Stock s)
 {
     downloaddata(s, true);
 }
示例#8
0
 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;
 }
示例#9
0
         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;

        }
示例#10
0
 public fetchstate(Stock stock, bool NewChart) { s = stock; newwind = NewChart; }
示例#11
0
 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; }
 }
示例#12
0
 /// <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;
 }
示例#13
0
 /// <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);
 }
示例#14
0
 /// <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;
 }
示例#15
0
 public void Remove(Stock s) { stocks.Remove(s); }
示例#16
0
 public void test_alert(Stock s)
 {
     alertssent++;
     Console.WriteLine(s.Symbol + " is overdue.");
 }
示例#17
0
 public fetchstate(Stock stock) : this(stock, true) { }
示例#18
0
 void c_FetchStock(Stock stock)
 {
     downloaddata(stock,false);
 }
示例#19
0
        /// <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);
        }