Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createDataFrame() {
// @formatter:off
return new DataFrame([
{high: 5663.99, low: 5639.25, open: 5658.11, close: 5647.88, volume: 0.67, timestamp: moment("2019-05-06T10:00:00.000Z")},
{high: 5660, low: 5608.04, open: 5627.37, close: 5658.11, volume: 10.623, timestamp: moment("2019-05-06T02:00:00.000Z")},
{high: 5638, low: 5613.12, open: 5621.01, close: 5627.3766, volume: 20, timestamp: moment("2019-05-06T01:00:00.000Z")},
]);
// @formatter:on
}
async function main(): Promise {
const df = new DataFrame({
columns: {
versicolor_x: versicolor_x,
versicolor_y: versicolor_y,
setosa_x: setosa_x,
setosa_y: setosa_y,
},
});
//console.log(df.head(10).toString());
const plot = df.plot()
.chartType(ChartType.Scatter)
.y()
.addSeries("versicolor_y")
.label("Versicolor")
//todo: .color("blue")
async function main(): Promise {
const df = new DataFrame({
columns: {
versicolor_x: versicolor_x,
versicolor_y: versicolor_y,
},
});
//console.log(df.toString());
const plot = df.plot({ chartType: ChartType.Scatter }, { x: "versicolor_x", y: "versicolor_y" });
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
async function main(): Promise {
const df = new DataFrame({
columns: {
date: x,
data1: data1,
data2: data2
},
})
.parseDates("date", "YYYY-MM-DD");
//console.log(df.toString());
const plot = df.plot({}, { x: "date", y: [ "data1", "data2" ]});
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
async function main(): Promise {
const df = new DataFrame({
columns: {
data1: data1,
data2: data2,
data3: data3,
},
});
//console.log(df.toString());
const plot = df.plot()
.chartType(ChartType.Bar);
await plot.renderImage(path.join(outputPath, "image.png"), { openImage: false });
await plot.exportWeb(path.join(outputPath, "web"), { overwrite: true, openBrowser: false });
}
function bucket(optimizationIterationResults: IDataFrame, numBuckets: number, searchDirection: OptimizeSearchDirection): IDataFrame {
if (optimizationIterationResults.none()) {
return new DataFrame();
}
const totalValues = optimizationIterationResults.count();
const parameterValues = optimizationIterationResults.deflate(iterationResult => iterationResult.parameterValue).bake();
const min = parameterValues.min();
const max = parameterValues.max();
const range = max - min;
return optimizationIterationResults
.select(iterationResult => {
const bucketIndex = Math.floor(((iterationResult.parameterValue - min) / range) * (numBuckets-1));
return {
bucketIndex: bucketIndex,
iterationResult: iterationResult,
};
})
.groupBy(bucket => bucket.bucketIndex)
if (numTrades === 0) {
return new Series>();
}
const random = new MersenneTwister(0);
const samples: IDataFrame[] = [];
for (let iterationIndex = 0; iterationIndex < numIterations; ++iterationIndex) {
const sample: ITrade[] = [];
for (var tradeIndex = 0; tradeIndex < numSamples; ++tradeIndex) {
var tradeCopyIndex = getRandomInt(random, 0, numTrades-1);
sample.push(tradesArray[tradeCopyIndex]);
}
samples.push(new DataFrame(sample));
}
return new Series>(samples);
}