Skip to content

ScottPlot4: DataGen.RandomStockPrices() produces candles with identical times #2574

@swharden

Description

@swharden

This very negatively impacts the cookbook recipes

var plt = new ScottPlot.Plot(600, 400);

// OHLCs are open, high, low, and closing prices for a time range.
OHLC[] prices = DataGen.RandomStockPrices(null, 60);
plt.AddCandlesticks(prices);

plt.SaveFig("finance_quickstart.png");

image

The problem is that start is never mutated, as recently broken by 91ebf73

OHLC[] ohlcs = new OHLC[pointCount];
DateTime start = new(1985, 09, 24);
for (int i = 0; i < ohlcs.Length; i++)
{
double basePrice = basePrices[i];
double open = rand.NextDouble() * 10 + 50;
double close = rand.NextDouble() * 10 + 50;
double high = Math.Max(open, close) + rand.NextDouble() * 10;
double low = Math.Min(open, close) - rand.NextDouble() * 10;
open += basePrice;
close += basePrice;
high += basePrice;
low += basePrice;
ohlcs[i] = new OHLC(open, high, low, close, start, TimeSpan.FromDays(1));
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions