fix(trading): do not add candles if they are older than requested date range (#5484)

This commit is contained in:
Bartłomiej Głownia 2023-12-13 09:06:02 +01:00 committed by GitHub
parent f178b85846
commit b82615a3d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,7 @@ const defaultConfig = {
*/
export class VegaDataSource implements DataSource {
client: ApolloClient<object>;
from?: Date;
marketId: string;
partyId: null | string;
_decimalPlaces = 0;
@ -158,6 +159,7 @@ export class VegaDataSource implements DataSource {
*/
async query(interval: PennantInterval, from: string) {
try {
this.from = new Date(from);
const { data } = await this.client.query<
CandlesQuery,
CandlesQueryVariables
@ -215,7 +217,9 @@ export class VegaDataSource implements DataSource {
this.decimalPlaces,
this.positionDecimalPlaces
);
if (!this.from || candle.date < this.from) {
return;
}
onSubscriptionData(candle);
}
});