using System; using System.Collections.Generic; using System.Text; using MarketData.Utils; // Filename: Stochastic.cs // Author:Sean Kessler // Date:08/2013 namespace MarketData.MarketDataModel { public class StochasticElementsByDate : Dictionary { public StochasticElementsByDate() { } } public class Stochastics : List { public static String GetHeader() { StringBuilder sb = new StringBuilder(); sb.Append("Date,Symbol,Open,High,Low,Close,LN,HN,HX,LX,%K,%D"); return sb.ToString(); } public StochasticElementsByDate GetBollingerBandElementsByDate() { StochasticElementsByDate stochasticElementsByDate = new StochasticElementsByDate(); for (int index = 0; index < Count; index++) { StochasticElement stochasticElement = this[index]; if (!stochasticElementsByDate.ContainsKey(stochasticElement.Date)) stochasticElementsByDate.Add(stochasticElement.Date, stochasticElement); } return stochasticElementsByDate; } } public class StochasticElement { private DateTime date; private String symbol; private double open; private double high; private double low; private double close; private double ln; private double hn; private double hx; private double lx; private double pd; // %D private double pk; // %K public StochasticElement() { } public DateTime Date { get { return date; } set { date = value; } } public String Symbol { get { return symbol; } set { symbol = value; } } public double Open { get { return open; } set { open = value; } } public double High { get { return high; } set { high = value; } } public double Low { get { return low; } set { low = value; } } public double Close { get { return close; } set { close = value; } } public double LN { get { return ln; } set { ln = value; } } public double HN { get { return hn; } set { hn = value; } } public double HX { get { return hx; } set { hx = value; } } public double LX { get { return lx; } set { lx = value; } } public double PD { get { return pd; } set { pd = value; } } public double PK { get { return pk; } set { pk = value; } } public bool PKInRange(double lowRange, double highRange) { if (PK >= lowRange && PK <= highRange) return true; return false; } public override String ToString() { StringBuilder sb = new StringBuilder(); sb.Append(Utility.DateTimeToStringMMSDDSYYYY(Date)).Append(","); sb.Append(Symbol).Append(","); sb.Append(Open).Append(","); sb.Append(High).Append(","); sb.Append(Low).Append(","); sb.Append(Close).Append(","); sb.Append(LN).Append(","); sb.Append(HN).Append(","); sb.Append(HX).Append(","); sb.Append(LX).Append(","); sb.Append(PK).Append(","); sb.Append(PD); return sb.ToString(); } } }