mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add ampl and change percentage
This commit is contained in:
parent
ec86d49135
commit
e5251400a4
|
@ -648,10 +648,12 @@ const createLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
||||||
const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
const createOHLCLegendUpdater = (legend: HTMLDivElement, prefix: string) => {
|
||||||
return (param: any, time : any) => {
|
return (param: any, time : any) => {
|
||||||
if (param) {
|
if (param) {
|
||||||
const change = param.close - param.open
|
const change = Math.round((param.close - param.open) * 100.0) / 100.0
|
||||||
const t = new Date(time * 1000)
|
const changePercentage = Math.round((param.close - param.open) / param.close * 10000.0) / 100.0;
|
||||||
|
const ampl = Math.round((param.high - param.low) / param.low * 10000.0) / 100.0;
|
||||||
|
const t = new Date(time * 1000);
|
||||||
const dateStr = moment(t).format("MMM Do YY hh:mm:ss A Z");
|
const dateStr = moment(t).format("MMM Do YY hh:mm:ss A Z");
|
||||||
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} T: ${dateStr}`;
|
legend.innerHTML = prefix + ` O: ${param.open} H: ${param.high} L: ${param.low} C: ${param.close} CHG: ${change} (${changePercentage}%) AMP: ${ampl}% T: ${dateStr}`;
|
||||||
} else {
|
} else {
|
||||||
legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -';
|
legend.innerHTML = prefix + ' O: - H: - L: - C: - T: -';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user