public void Create(DoubleSeries series) { foreach (PadTemplate padTemplate in this.padTemplates.Values) { padTemplate.Create(series); } }
private void chartToolStrip1_TimeFrameChanged(ChartTimeFrame timeFrame) { BarSeries barSeries = new BarSeries(); ((TimeSeries)barSeries).DataSeries = ((TimeSeries)this.instrument.GetDailySeries()).DataSeries; BarSeries series = null; switch (timeFrame) { case ChartTimeFrame.Day: series = barSeries; series.Name = ((FIXInstrument)this.instrument).Symbol + " - Daily"; break; case ChartTimeFrame.Week: series = barSeries.Compress(604800L); series.Name = ((FIXInstrument)this.instrument).Symbol + " - Weely"; break; case ChartTimeFrame.Month: series = barSeries.Compress(2419200L); series.Name = ((FIXInstrument)this.instrument).Symbol + " - Monthly"; break; case ChartTimeFrame.Year: series = barSeries.Compress(29030400L); series.Name = ((FIXInstrument)this.instrument).Symbol + " - Annual"; break; } this.UpdateMe(series); }
public AddIndicatorForm(System.Type indicatorType, int padCount, DoubleSeries series, List <Indicator> indicatorList, int selectedPad, Color color) { this.InitializeComponent(); this.padNumber = padCount; this.sq_indicator = Activator.CreateInstance(indicatorType) as Indicator; this.indicator = Activator.CreateInstance(System.Type.GetType("OpenQuant.API.Indicators." + indicatorType.Name + ", OpenQuant.API"), true) as Indicator; this.sq_indicator = this.indicator.GetType().GetField("indicator", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField).GetValue((object)this.indicator) as Indicator; this.txtName.Text = ((TimeSeries)this.sq_indicator).Name; ((TimeSeries)this.sq_indicator).Color = color; this.propertyGrid1.SelectedObject = (object)this.indicator; for (int index = 0; index < this.padNumber; ++index) { this.cbxPads.Items.Add((object)index); } this.cbxSeries.Items.Add((object)new SeriesItem(series)); using (List <Indicator> .Enumerator enumerator = indicatorList.GetEnumerator()) { while (enumerator.MoveNext()) { this.cbxSeries.Items.Add((object)new SeriesItem((DoubleSeries)enumerator.Current)); } } this.cbxPads.SelectedIndex = selectedPad; this.cbxSeries.SelectedIndex = 0; if (selectedPad != -1 && this.sq_indicator.Type == EIndicatorType.Price) { return; } this.cbxNewPad.Checked = true; }
public RoundTrip(Position Position, Instrument Instrument, PositionSide TradePosition, double Amount, double EntryPrice, double ExitPrice, DateTime EntryDateTime, DateTime ExitDateTime, RoundTripStatus Status) : base() { this.position = Position; this.instrument = Instrument; this.tradePosition = TradePosition; this.amount = Amount; this.entryPrice = EntryPrice; this.exitPrice = ExitPrice; this.entryDateTime = EntryDateTime; this.exitDateTime = ExitDateTime; this.entryCost = 0.0; this.exitCost = 0.0; this.entryValue = EntryPrice * Amount; this.exitValue = ExitPrice * Amount; this.roundTripLowPrice = EntryPrice; this.roundTripHighPrice = EntryPrice; this.status = Status; if (this.status != RoundTripStatus.Opened) { return; } this.series = new DoubleSeries(); this.series.Add(EntryDateTime, this.entryPrice); this.Connect(); }
public AccumulateQuotes(string Name, int WindowSizeTime, int WindowSizeCount, double BBMultiplier, bool CalcTrade, Color color) : base(Name, color, WindowSizeTime, WindowSizeCount) { this.CalcTrade = CalcTrade; ms = new TimeSpan(0, 0, 0, 0, 1); this.BBMultiplier = BBMultiplier; // see page 157 in Bollinger on Bollinger Bands slopeAvg = new AccumulateValues("slope(avg) " + Name, color, WindowSizeTime / 4); //dsSlopeAvg = slopeAvg.dsSlope; dsSlopeAvg = new DoubleSeries("slope(avg) " + Name); dsSlopeAvg.Color = color; slopeAvg.dsSlope.ItemAdded += new ItemAddedEventHandler(slopeItemAddedEventHandler); accelAvg = new AccumulateValues("accel(avg) " + Name, color, WindowSizeTime / 16); dsAccelAvg = new DoubleSeries("accel(avg) " + Name); dsAccelAvg.Color = color; accelAvg.dsSlope.ItemAdded += new ItemAddedEventHandler(accelItemAddedEventHandler); dsBBUpper = new DoubleSeries("bbu " + Name); dsBBUpper.Color = color; dsBBLower = new DoubleSeries("bbl " + Name); dsBBLower.Color = color; dsB = new DoubleSeries("%b " + Name); dsB.Color = color; dsBandwidth = new DoubleSeries("bbw " + Name); dsBandwidth.Color = color; }
public SimpleSeriesItem(string name, DoubleSeries parentSeries) : base() { this.enabled = true; this.parentSeries = parentSeries; this.name = name; this.series = parentSeries; this.fillSeries = true; }
protected override void OnInit() { Add(new OutputDescriptor(Color.FromKnownColor(KnownColor.Gray), "bull_power")); Add(new OutputDescriptor(Color.FromKnownColor(KnownColor.Gray), "bear_power")); ds_bull_power = new DoubleSeries(this); ds_bear_power = new DoubleSeries(this); }
public void CreateSeries() { dsOpen = new DoubleSeries("open "); dsDayCl = new DoubleSeries("day cls " + daycl.ToString("#.00")); dsDayPv = new DoubleSeries("day pv " + dayPv.ToString("#.00")); dsDayR1 = new DoubleSeries("day r1 " + dayR1.ToString("#.00")); dsDayR2 = new DoubleSeries("day r2 " + dayR2.ToString("#.00")); dsDayR3 = new DoubleSeries("day r3 " + dayR3.ToString("#.00")); dsDayS1 = new DoubleSeries("day s1 " + dayS1.ToString("#.00")); dsDayS2 = new DoubleSeries("day s2 " + dayS2.ToString("#.00")); dsDayS3 = new DoubleSeries("day s3 " + dayS3.ToString("#.00")); dsWeekCl = new DoubleSeries("week cls " + weekcl.ToString("#.00")); dsWeekPv = new DoubleSeries("week pv " + weekPv.ToString("#.00")); dsWeekR1 = new DoubleSeries("week r1" + weekR1.ToString("#.00")); dsWeekR2 = new DoubleSeries("week r2 " + weekR2.ToString("#.00")); dsWeekR3 = new DoubleSeries("week r3 " + weekR3.ToString("#.00")); dsWeekS1 = new DoubleSeries("week s1 " + weekS1.ToString("#.00")); dsWeekS2 = new DoubleSeries("week s2 " + weekS2.ToString("#.00")); dsWeekS3 = new DoubleSeries("week s3 " + weekS3.ToString("#.00")); dsMonCl = new DoubleSeries("mon cls " + moncl.ToString("#.00")); dsMonPv = new DoubleSeries("mon pv " + monPv.ToString("#.00")); dsMonR1 = new DoubleSeries("mon r1 " + monR1.ToString("#.00")); dsMonR2 = new DoubleSeries("mon r2 " + monR2.ToString("#.00")); dsMonR3 = new DoubleSeries("mon r3 " + monR3.ToString("#.00")); dsMonS1 = new DoubleSeries("mon s1 " + monS1.ToString("#.00")); dsMonS2 = new DoubleSeries("mon s2 " + monS2.ToString("#.00")); dsMonS3 = new DoubleSeries("mon s3 " + monS3.ToString("#.00")); dsSma20Day = new DoubleSeries("sma 20 " + sma20day.ToString("#.00")); dsSma200Day = new DoubleSeries("sma 200 " + sma200day.ToString("#.00")); dsOpen.Color = Color.Violet; dsDayCl.Color = Color.Black; dsDayPv.Color = Color.Green; dsDayR1.Color = Color.Blue; dsDayR2.Color = Color.Red; dsDayR3.Color = Color.Orange; dsDayS1.Color = Color.Blue; dsDayS2.Color = Color.Red; dsDayS3.Color = Color.Beige; dsWeekCl.Color = Color.Black; dsWeekPv.Color = Color.Green; dsWeekR1.Color = Color.Blue; dsWeekS1.Color = Color.Blue; dsMonCl.Color = Color.Black; dsMonPv.Color = Color.Green; dsMonR1.Color = Color.Blue; dsMonS1.Color = Color.Blue; dsSma20Day.Color = Color.DarkSlateBlue; dsSma200Day.Color = Color.DarkSeaGreen; }
private DoubleSeries GenerateSeriesByType() { var series = new DoubleSeries(); double startPhase = 0.12; switch (_dataType) { case GeneratedDataType.Eeg: series = DataManager.Instance.GenerateEEG(PointCount, ref startPhase, 15); break; case GeneratedDataType.ClusteredPoints: series = DataManager.Instance.GetClusteredPoints(12, 45, 1, PointCount); break; case GeneratedDataType.DampedSinewave: series = DataManager.Instance.GetDampedSinewave(15, 2, PointCount); break; case GeneratedDataType.ExponentialCurve: series = DataManager.Instance.GetExponentialCurve(15, PointCount); break; case GeneratedDataType.FourierSeries: series = DataManager.Instance.GetFourierSeries(15, 2, PointCount); break; case GeneratedDataType.FourierSeriesZoomed: series = DataManager.Instance.GetFourierSeriesZoomed(15, 2, 1, 10, PointCount); break; case GeneratedDataType.LissajousCurve: series = DataManager.Instance.GetLissajousCurve(0.23, 0.64, 0.87, PointCount); break; case GeneratedDataType.RandomDoubleSeries: series = DataManager.Instance.GetRandomDoubleSeries(PointCount); break; case GeneratedDataType.Sinewave: series = DataManager.Instance.GetSinewave(0.12, 0.4, PointCount); break; case GeneratedDataType.Spiral: series = DataManager.Instance.GenerateSpiral(0, 0, 100, PointCount); break; case GeneratedDataType.SquirlyWave: series = DataManager.Instance.GetSquirlyWave(); break; case GeneratedDataType.StraightLine: series = DataManager.Instance.GetStraightLine(12, 5, PointCount); break; } return(series); }
public void Create(DoubleSeries series) { this.indicator = Activator.CreateInstance(this.indicatorType) as Indicator; foreach (KeyValuePair <string, object> keyValuePair in this.properties) { this.indicatorType.GetProperty(keyValuePair.Key).SetValue(this.indicator, keyValuePair.Value, (object[])null); } this.indicator.Input = series; }
public DSView(Pad pad, DoubleSeries series, Color color, EIndexOption option, SmoothingMode smoothing) : base(pad) { this.mainSeries = series; this.option = option; this.KNRy1kSrcC = color; this.IXfyvDxxVL = smoothing; this.ToolTipFormat = "toool"; // this.ToolTipFormat = this.toolTipFormat.Replace(FJDHryrxb1WIq5jBAt.mT707pbkgT(2828), pad.Chart.LabelDigitsCount.ToString()); }
public void Create(DoubleSeries series) { this.table.Clear(); foreach (IndicatorTemplateItem indicatorTemplateItem1 in this.indicatorTemplateList) { foreach (IndicatorTemplateItem indicatorTemplateItem2 in indicatorTemplateItem1.GetIndicatorTemplates(series)) { this.table[indicatorTemplateItem2.Indicator] = indicatorTemplateItem2; } } }
private static void FillDataSeries(HlDataSeries <double, double> dataSeries, DoubleSeries sourceData, double scale) { var random = new Random(42); var xData = sourceData.XData; var yData = sourceData.YData; for (var i = 0; i < sourceData.Count; i++) { dataSeries.Append(xData[i], yData[i] + scale, random.NextDouble() * 0.2, random.NextDouble() * 0.2); } }
public List <IndicatorTemplateItem> GetIndicatorTemplates(DoubleSeries series) { List <IndicatorTemplateItem> list = new List <IndicatorTemplateItem>(); this.Create(series); list.Add(this); foreach (IndicatorTemplateItem indicatorTemplateItem in this.children) { list.AddRange((IEnumerable <IndicatorTemplateItem>)indicatorTemplateItem.GetIndicatorTemplates((DoubleSeries)this.indicator)); } return(list); }
public Trigger(Strategy strategy, TriggerType type, DoubleSeries series, double level, Signal signal) { this.fStrategy = strategy; this.fType = type; this.fSeries = series; this.fLevel = level; this.fSignal = signal; this.fStatus = TriggerStatus.Active; this.fCreationTime = Clock.Now; this.fCompletionTime = DateTime.MinValue; this.fStrategy.AddTrigger(this); this.Connect(); }
public override DoubleSeries GetNegativeSeries() { DoubleSeries ds = new DoubleSeries(); for (int i = this.fFirstIndex; i < this.fLastIndex; ++i) { if (this[i] < 0.0) { ds.Add(this.GetDateTime(i), this[i]); } } return(ds); }
protected override void OnUpdateChart(ICollection <IDataObject> objects) { DoubleSeries doubleSeries = new DoubleSeries("Trade"); using (IEnumerator <IDataObject> enumerator = ((IEnumerable <IDataObject>)objects).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { Trade trade = (Trade)enumerator.Current; doubleSeries.Add(trade.DateTime, trade.Price); } } ((TimeSeries)doubleSeries).Draw(Color.Black); }
private IDataSeries <double, double> GenerateDataSeries(AxisAlignment axisAlignment, int index) { var dataSeries = new XyDataSeries <double, double>(); dataSeries.SeriesName = string.Format("Series {0}", index); double gradient = axisAlignment == AxisAlignment.Right ? index : -index; double start = axisAlignment == AxisAlignment.Right ? 0.0 : 14000; DoubleSeries straightLineData = DataManager.Instance.GetStraightLine(gradient, start, SeriesPointCount); dataSeries.Append(straightLineData.XData, straightLineData.YData); return(dataSeries); }
public static double Value(TimeSeries input, int index, int length1, int length2) { if (index < length1 - 1 + input.FirstIndex || index < length2 - 1 + input.FirstIndex) { return(double.NaN); } DoubleSeries doubleSeries = new DoubleSeries(); for (int index1 = index; index1 > index - Math.Max(length1, length2); --index1) { doubleSeries.Add(input.GetDateTime(index1), input[index1, BarData.Volume]); } return(SMA.Value((TimeSeries)doubleSeries, length1 - 1, length1, BarData.Close) - SMA.Value((TimeSeries)doubleSeries, length2 - 1, length2, BarData.Close)); }
public Performance(Portfolio portfolio) { this.enabled = true; this.equitySeries = new DoubleSeries("Equity"); this.coreEquitySeries = new DoubleSeries("CoreEquity"); this.pnlSeries = new DoubleSeries("PnL"); this.drawdownSeries = new DoubleSeries("Drawdown"); this.drawdownPercentSeries = new DoubleSeries("DrawdownPercent"); this.InjBy1lkoo = double.NaN; this.MrYBqYV87G = double.NaN; this.portfolio = portfolio; this.CalculatePnL = true; this.CalculateDrawdown = true; this.portfolio.ValueChanged += new PositionEventHandler(this.RLrBXT2waX); }
protected void Init(string name, SeriesTesterItem parentSeriesItem, string title, bool fillSeries) { this.isUpdating = false; this.lastDateTime = DateTime.MinValue; this.series = new DoubleSeries(); this.series.Name = name; this.series.Title = title; this.parentComponent = parentSeriesItem; this.parentSeries = parentSeriesItem.Series; if (this.parentSeries != null) { this.parentSeries.ItemAdded += new ItemAddedEventHandler(this.syrQYCdiq); } this.FillSeries = fillSeries; }
public static double Value(TimeSeries input, int index, int length1, int length2) { if (index < length2 - 1 + input.FirstIndex) { return(double.NaN); } DoubleSeries doubleSeries = new DoubleSeries(); for (int index1 = 0; index1 <= index; ++index1) { doubleSeries.Add(input.GetDateTime(index1), input[index1, BarData.High] - input[index1, BarData.Low]); } EMA ema = new EMA((TimeSeries)doubleSeries, length1, BarData.Close); return((ema[index] - ema[index - length2 + 1]) / ema[index - length2 + 1] * 100.0); }
protected override void OnInit() { IsEntry = true; IsStop = false; IsTarget = false; Add(new OutputDescriptor(new Pen(this.Plot0Color, this.Plot0Width), OutputSerieDrawStyle.Line, "Occurred")); Add(new OutputDescriptor(new Pen(this.Plot0Color, this.Plot1Width), OutputSerieDrawStyle.Line, "Entry")); ds_bull_power = new DoubleSeries(this); ds_bear_power = new DoubleSeries(this); IsOverlay = false; CalculateOnClosedBar = true; this.RequiredBarsCount = 20; }
private void FillSeries(HlcDataSeries <double, double> hlcDataSeries, DoubleSeries sourceData, double scale) { var xData = sourceData.XData; var yData = sourceData.YData.Select(x => x * scale).ToArray(); // Generate some random error data. Errors must be absolute values, // e.g. if a series has a Y-value of 5.0, and YError of =/-10% then you must enter YErrorHigh=5.5, YErrorLow=4.5 into the HlcDataSeries var random = new FasterRandom(); var yErrorHigh = yData.Select(y => y + random.NextDouble() * 0.2); var yErrorLow = yData.Select(y => y - random.NextDouble() * 0.2); // HlcDataSeries requires X, Y, High, Low. // For Error bars the High, Low becomes the High Low error, // while X,Y is the location of the error hlcDataSeries.Append(xData, yData, yErrorHigh, yErrorLow); }
public static double Value(TimeSeries input, int index, int length, BarData option) { if (index < 1 + input.FirstIndex) { return(double.NaN); } DoubleSeries doubleSeries = new DoubleSeries(); for (int firstIndex = input.FirstIndex; firstIndex <= index; ++firstIndex) { doubleSeries.Add(input.GetDateTime(firstIndex), input[firstIndex, option]); } EMA ema = new EMA((TimeSeries) new EMA((TimeSeries) new EMA((TimeSeries)doubleSeries, length, option), length, option), length, option); return((ema[index - input.FirstIndex] - ema[index - 1 - input.FirstIndex]) / ema[index - 1 - input.FirstIndex] * 100.0); }
public DoubleSeries GetRandomWalkSeries(int count) { var doubleSeries = new DoubleSeries(count); // Generate a slightly positive biased random walk // y[i] = y[i-1] + random, // where random is in the range -0.5, +0.5 for(int i = 0; i < count; i++) { double next = _last + (_random.NextDouble() - 0.5 + _bias); _last = next; doubleSeries.Add(new XYPoint() { X = _i++, Y = next}); } return doubleSeries; }
protected override void Init() { this.Name = "DX" + (object)this.fLength; this.Title = "DX"; this.Clear(); this.fCalculate = true; if (this.fInput == null) { return; } if (TimeSeries.fNameOption == ENameOption.Long) { this.Name = this.fInput.Name + this.Name; } this.fPDM = new DoubleSeries(); this.fMDM = new DoubleSeries(); }
protected override void OnUpdateChart(ICollection <IDataObject> objects) { DoubleSeries doubleSeries1 = new DoubleSeries("Bid"); DoubleSeries doubleSeries2 = new DoubleSeries("Ask"); using (IEnumerator <IDataObject> enumerator = ((IEnumerable <IDataObject>)objects).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { Quote quote = (Quote)enumerator.Current; doubleSeries1.Add(quote.DateTime, quote.Bid); doubleSeries2.Add(quote.DateTime, quote.Ask); } } ((TimeSeries)doubleSeries1).Draw(Color.Blue); ((TimeSeries)doubleSeries2).Draw(Color.Red); }
public Accumulation( string Name, Color color, int WindowSizeSeconds, int WindowSizeCount) : base(WindowSizeSeconds, WindowSizeCount) { this.color = color; rs = new RunningStats(); dsSlope = new DoubleSeries("b1 " + Name); dsSlope.Color = color; dsRR = new DoubleSeries("rr " + Name); dsRR.Color = color; dsAvg = new DoubleSeries("avg " + Name); dsAvg.SecondColor = Color.Purple; dsAvg.Color = color; }
public ATSStop(Position position, DateTime time) { this.fPosition = position; this.fInstrument = position.Instrument; this.fQty = position.Qty; this.fSide = position.Side; this.fType = StopType.Time; this.fCreationTime = Clock.Now; this.fCompletionTime = time; this.fStopPrice = this.fInstrument.Price(); this.series = new DoubleSeries(); if (this.fType == StopType.Trailing) { this.series.Add(this.fCreationTime, this.GetStopPrice()); } if (this.fCompletionTime > this.fCreationTime) { Clock.AddReminder(new ReminderEventHandler(this.OnClock), this.fCompletionTime, null); } }
public Trigger(Strategy strategy, TriggerType type, DoubleSeries series, double level, Signal signal) : base() { this.pEXA4yCenN = Color.Brown; this.pZXAJFXyGb = Color.Green; this.YCKA0R33mr = Color.DarkGray; this.yXsAvQ0snw = true; this.wuIAEWD0JW = true; this.HKDAVnUw46 = "fdsdf"; this.nquAKcUOSY = strategy; this.k5kAXvwmyK = type; this.fISADbUH9Z = series; this.J3YAFHAWt0 = level; this.eiNALoFbZL = signal; this.lh4APrSwVL = TriggerStatus.Active; this.a9QA39LDVd = Clock.Now; this.gixAsE4W2J = DateTime.MinValue; this.nquAKcUOSY.YFmhKSovu(this); this.ULWAhR6fQR(); }
public TimeSeries(string name, string title) { this.series = new DoubleSeries(name, title); }
public DoubleSeries GetDampedSinewave(int pad, double amplitude, double phase, double dampingFactor, int pointCount, int freq = 10) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < pad; i++) { double time = 10 * i / (double)pointCount; doubleSeries.Add(new XYPoint() { X = time }); } for (int i = pad, j = 0; i < pointCount; i++, j++) { var xyPoint = new XYPoint(); double time = 10 * i / (double)pointCount; double wn = 2 * Math.PI / (pointCount / (double)freq); xyPoint.X = time; xyPoint.Y = amplitude * Math.Sin(j * wn + phase); doubleSeries.Add(xyPoint); amplitude *= (1.0 - dampingFactor); } return doubleSeries; }
public DoubleSeries GenerateEEG(int count, ref double startPhase, double phaseStep) { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); var time = i / (double)count; xyPoint.X = time; //double mod = 0.2 * Math.Sin(startPhase); xyPoint.Y = //mod * Math.Sin(startPhase / 4.9) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); startPhase += phaseStep; } return doubleSeries; }
internal TimeSeries(DoubleSeries series) { this.series = series; }
public DoubleSeries GetButterflyCurve(int count=2000) { // From http://en.wikipedia.org/wiki/Butterfly_curve_%28transcendental%29 // x = sin(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12)) // y = cos(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12)) var temp = 0.01; var doubleSeries = new DoubleSeries(count); for (int i = 0; i < count; i++) { var t = i*temp; double multiplier = Math.Pow(Math.E, Math.Cos(t)) - 2*Math.Cos(4*t) - Math.Pow(Math.Sin(t/12), 5); double x = Math.Sin(t)*multiplier; double y = Math.Cos(t) * multiplier; doubleSeries.Add(new XYPoint {X = x, Y = y}); } return doubleSeries; }
public DoubleSeries GetAcousticChannel(int channelNumber) { if (channelNumber > 7) throw new InvalidOperationException("Only channels 0-7 allowed"); if (_acousticPlotData.Count != 0) { return _acousticPlotData[channelNumber]; } // e.g. resource format: Abt.Controls.SciChart.Example.Resources.EURUSD_Daily.csv var csvResource = string.Format("{0}.{1}", ResourceDirectory, "AcousticPlots.csv"); var ch0 = new DoubleSeries(100000); var ch1 = new DoubleSeries(100000); var ch2 = new DoubleSeries(100000); var ch3 = new DoubleSeries(100000); var ch4 = new DoubleSeries(100000); var ch5 = new DoubleSeries(100000); var ch6 = new DoubleSeries(100000); var ch7 = new DoubleSeries(100000); var assembly = typeof(DataManager).Assembly; using (var stream = assembly.GetManifestResourceStream(csvResource)) using (var streamReader = new StreamReader(stream)) { string line = streamReader.ReadLine(); line = streamReader.ReadLine(); while (line != null) { // Line Format: // Date, Open, High, Low, Close, Volume // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 var tokens = line.Split(','); double x = double.Parse(tokens[0], NumberFormatInfo.InvariantInfo); double y0 = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo); double y1 = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo); double y2 = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo); double y3 = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo); double y4 = double.Parse(tokens[5], NumberFormatInfo.InvariantInfo); double y5 = double.Parse(tokens[6], NumberFormatInfo.InvariantInfo); double y6 = double.Parse(tokens[7], NumberFormatInfo.InvariantInfo); double y7 = double.Parse(tokens[8], NumberFormatInfo.InvariantInfo); ch0.Add(new XYPoint() { X = x, Y = y0 }); ch1.Add(new XYPoint() { X = x, Y = y1 }); ch2.Add(new XYPoint() { X = x, Y = y2 }); ch3.Add(new XYPoint() { X = x, Y = y3 }); ch4.Add(new XYPoint() { X = x, Y = y4 }); ch5.Add(new XYPoint() { X = x, Y = y5 }); ch6.Add(new XYPoint() { X = x, Y = y6 }); ch7.Add(new XYPoint() { X = x, Y = y7 }); line = streamReader.ReadLine(); } } _acousticPlotData.AddRange(new[] { ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7}); return _acousticPlotData[channelNumber]; }
private void Draw(DoubleSeries series, int padNumber) { this.Draw(series, padNumber, DrawStyle.Line); }
private void Draw(DoubleSeries series, int padNumber, DrawStyle stype) { Dictionary<SmartQuant.Instruments.Instrument, Dictionary<DoubleSeries, Tuple<int, DrawStyle>>> dictionary; if (Map.DrawTable.ContainsKey(this.strategyName)) { dictionary = (Map.DrawTable[this.strategyName] as Dictionary<SmartQuant.Instruments.Instrument, Dictionary<DoubleSeries, Tuple<int, DrawStyle>>>); } else { dictionary = new Dictionary<SmartQuant.Instruments.Instrument, Dictionary<DoubleSeries, Tuple<int, DrawStyle>>>(); Map.DrawTable[this.strategyName] = dictionary; } Dictionary<DoubleSeries, Tuple<int, DrawStyle>> dictionary2; if (dictionary.ContainsKey(this.sq_Instrument)) { dictionary2 = dictionary[this.sq_Instrument]; } else { dictionary2 = new Dictionary<DoubleSeries, Tuple<int, DrawStyle>>(); dictionary[this.sq_Instrument] = dictionary2; } dictionary2[series] = new Tuple<int, DrawStyle>(padNumber, stype); this.maxPadNumber = Math.Max(this.maxPadNumber, padNumber); }
public DoubleSeries GetFourierSeries(double amplitude, double phaseShift, int count = 5000) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); double time = 10 * i / (double)count; double wn = 2 * Math.PI / (count / 10); xyPoint.X = time; xyPoint.Y = Math.PI * amplitude * (Math.Sin(i * wn + phaseShift) + 0.33 * Math.Sin(i * 3 * wn + phaseShift) + 0.20 * Math.Sin(i * 5 * wn + phaseShift) + 0.14 * Math.Sin(i * 7 * wn + phaseShift) + 0.11 * Math.Sin(i * 9 * wn + phaseShift) + 0.09 * Math.Sin(i * 11 * wn + phaseShift)); doubleSeries.Add(xyPoint); } return doubleSeries; }
public DoubleSeries GetClusteredPoints(double xCentre, double yCentre, double deviation, int count) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < count; i++) { double x = GetGaussianRandomNumber(xCentre, deviation); double y = GetGaussianRandomNumber(yCentre, deviation); doubleSeries.Add(new XYPoint() { X = x, Y = y}); } return doubleSeries; }
public DoubleSeries GetStraightLine(double gradient, double yIntercept, int pointCount) { var doubleSeries = new DoubleSeries(pointCount); for (int i = 0; i <= pointCount; i++) { double x = i + 1; double y = gradient * x + yIntercept; doubleSeries.Add(new XYPoint() { X = x, Y = y }); } return doubleSeries; }
public DoubleSeries GetSquirlyWave() { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); const int COUNT = 1000; for (int i = 0; i < COUNT; i++) { var xyPoint = new XYPoint(); var time = i / (double)COUNT; xyPoint.X = time; xyPoint.Y = time * Math.Sin(2 * Math.PI * i / (double)COUNT) + 0.2 * Math.Sin(2 * Math.PI * i / (COUNT / 7.9)) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); } return doubleSeries; }
public DoubleSeries GetRandomDoubleSeries(int pointCount) { var doubleSeries = new DoubleSeries(); double amplitude = _random.NextDouble() + 0.5; double freq = Math.PI * (_random.NextDouble() + 0.5) * 10; double offset = _random.NextDouble() - 0.5; for(int i = 0; i < pointCount; i++) { doubleSeries.Add(new XYPoint() { X=i, Y=offset + amplitude*Math.Sin(freq*i) }); } return doubleSeries; }
public DoubleSeries GetLissajousCurve(double alpha, double beta, double delta, int count=200) { // From http://en.wikipedia.org/wiki/Lissajous_curve // x = Asin(at + d), y = Bsin(bt) var doubleSeries = new DoubleSeries(count); for (int i = 0; i < count; i++) { double x = Math.Sin(alpha*i*0.1 + delta); double y = Math.Sin(beta*i*0.1); doubleSeries.Add(new XYPoint() {X = x, Y = y}); } return doubleSeries; }
public DoubleSeries GetFourierSeriesZoomed(double amplitude, double phaseShift, double xStart, double xEnd, int count = 5000) { var data = GetFourierSeries(amplitude, phaseShift, count); int index0 = 0; int index1 = 0; for (int i = 0; i < count; i++) { if (data.XData[i] > xStart && index0 == 0) index0 = i; if (data.XData[i] > xEnd && index1 == 0) { index1 = i; break; } } var result = new DoubleSeries(); var xData = data.XData.Skip(index0).Take(index1 - index0).ToArray(); var yData = data.YData.Skip(index0).Take(index1 - index0).ToArray(); for (int i = 0; i < xData.Length; i++) { result.Add(new XYPoint() {X = xData[i], Y = yData[i]}); } return result; }
public DoubleSeries GenerateSpiral(double xCentre, double yCentre, double maxRadius, int count) { var doubleSeries = new DoubleSeries(); double radius = 0; double x, y; double deltaRadius = maxRadius/count; for (int i = 0; i < count; i++) { double sinX = Math.Sin(2*Math.PI*i*0.05); double cosX = Math.Cos(2*Math.PI*i*0.05); x = xCentre + radius * sinX; y = yCentre + radius*cosX; doubleSeries.Add(new XYPoint() { X = x, Y = y}); radius += deltaRadius; } return doubleSeries; }
public DoubleSeries GetExponentialCurve(double power, int pointCount) { var doubleSeries = new DoubleSeries(pointCount); double x = 0.00001; const double fudgeFactor = 1.4; for(int i = 0; i < pointCount; i++) { x *= fudgeFactor; double y = Math.Pow((double)i + 1, power); doubleSeries.Add(new XYPoint() {X = x, Y = y}); } return doubleSeries; }