Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/namespaces/Barstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Series } from '../Series';
export class Barstate {
private _live: boolean = false;

constructor(private context: any) {}
constructor(private context: any) { }
public setLive() {
this._live = true;
}
Expand All @@ -20,20 +20,24 @@ export class Barstate {
}

public get ishistory() {
return this.context.idx < this.context.data.close.data.length - 1;
return this.context.idx < this.context.length - 1;
}

public get isrealtime() {
return this.context.idx === this.context.data.close.data.length - 1;
return this.context.idx === this.context.length - 1;
}

public get isconfirmed() {
return this.context.data.closeTime[this.context.data.closeTime.length - 1] <= new Date().getTime();
return this.context.data.closeTime.data[this.context.idx] <= new Date().getTime();
}

public get islastconfirmedhistory() {
//FIXME : this is a temporary solution to get the islastconfirmedhistory value,
//we need to implement a better way to handle it based on market data
return this.context.data.closeTime[this.context.data.closeTime.length - 1] <= new Date().getTime();
return (
// this is the last and isconfirmed
this.context.idx === this.context.length - 1 && this.isconfirmed ||
// this is the second to last and the last is not confirmed
this.context.idx === this.context.length - 2 && this.context.data.closeTime.data[this.context.length - 1] > new Date().getTime());
}
}