Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plot(plotDef?: IPlotConfig, axisMap?: IAxisMap): IPlotAPI;
}
}
const dataFramePlotDefaults: IPlotConfig = {
legend: {
show: true,
},
};
function plotDataFrame(this: IDataFrame, plotDef?: IPlotConfig, axisMap?: IAxisMap): IPlotAPI {
const serializedData = this.serialize();
return new PlotAPI(serializedData, plotDef || {}, axisMap || {}, dataFramePlotDefaults);
}
DataFrame.prototype.startPlot = startPlot;
DataFrame.prototype.endPlot = endPlot;
DataFrame.prototype.plot = plotDataFrame;
}
}
const dataFramePlotDefaults: IPlotConfig = {
legend: {
show: true,
},
};
function plotDataFrame(this: IDataFrame, plotDef?: IPlotConfig, axisMap?: IAxisMap): IPlotAPI {
const serializedData = this.serialize();
return new PlotAPI(serializedData, plotDef || {}, axisMap || {}, dataFramePlotDefaults);
}
DataFrame.prototype.startPlot = startPlot;
DataFrame.prototype.endPlot = endPlot;
DataFrame.prototype.plot = plotDataFrame;
}
/**
* Compute the percent bandwidth indicator from Bollinger Bands.
*
* %b (pronounced "percent b") is derived from the formula for stochastics and shows where price is in relation to the bands.
* %b equals 1 at the upper band and 0 at the lower band.
*
* https://en.wikipedia.org/wiki/Bollinger_Bands#Indicators_derived_from_Bollinger_Bands
*
*/
function percentB(this: IDataFrame): ISeries {
return this.deflate(band => (band.value - band.lower) / (band.upper - band.lower));
};
DataFrame.prototype.percentB = percentB;
function gaps(this: IDataFrame): ISeries {
return this.rollingWindow(2)
.select<[IndexT, number]>(window => {
const day1 = window.first().close;
const day2 = window.last().open;
return [
window.getIndex().last(),
((day2 - day1) / day1) * 100,
];
})
.withIndex(pair => pair[0])
.select(pair => pair[1]);
}
DataFrame.prototype.gaps = gaps;
}
const dataFramePlotDefaults: IPlotConfig = {
legend: {
show: true,
},
};
function plotDataFrame(this: IDataFrame, plotDef?: IPlotConfig, axisMap?: IAxisMap): IPlotAPI {
const serializedData = this.serialize();
return new PlotAPI(serializedData, plotDef || {}, axisMap || {}, dataFramePlotDefaults);
}
DataFrame.prototype.startPlot = startPlot;
DataFrame.prototype.endPlot = endPlot;
DataFrame.prototype.plot = plotDataFrame;