fix(trading): do not add candles if they are older than requested date range (#5484)
This commit is contained in:
parent
f178b85846
commit
b82615a3d8
@ -56,6 +56,7 @@ const defaultConfig = {
|
|||||||
*/
|
*/
|
||||||
export class VegaDataSource implements DataSource {
|
export class VegaDataSource implements DataSource {
|
||||||
client: ApolloClient<object>;
|
client: ApolloClient<object>;
|
||||||
|
from?: Date;
|
||||||
marketId: string;
|
marketId: string;
|
||||||
partyId: null | string;
|
partyId: null | string;
|
||||||
_decimalPlaces = 0;
|
_decimalPlaces = 0;
|
||||||
@ -158,6 +159,7 @@ export class VegaDataSource implements DataSource {
|
|||||||
*/
|
*/
|
||||||
async query(interval: PennantInterval, from: string) {
|
async query(interval: PennantInterval, from: string) {
|
||||||
try {
|
try {
|
||||||
|
this.from = new Date(from);
|
||||||
const { data } = await this.client.query<
|
const { data } = await this.client.query<
|
||||||
CandlesQuery,
|
CandlesQuery,
|
||||||
CandlesQueryVariables
|
CandlesQueryVariables
|
||||||
@ -215,7 +217,9 @@ export class VegaDataSource implements DataSource {
|
|||||||
this.decimalPlaces,
|
this.decimalPlaces,
|
||||||
this.positionDecimalPlaces
|
this.positionDecimalPlaces
|
||||||
);
|
);
|
||||||
|
if (!this.from || candle.date < this.from) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
onSubscriptionData(candle);
|
onSubscriptionData(candle);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user