fix: use correct graphql candle timestamp field (#1324)

This commit is contained in:
John Walley 2022-09-19 12:21:38 +01:00 committed by GitHub
parent 2b76e7d5c8
commit 70df56f745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -10,7 +10,7 @@ export const generateCandles = (
): CandlesQuery => {
const candles: CandleFieldsFragment[] = [
{
datetime: '2022-04-06T09:15:00Z',
timestamp: '1661515200000000000',
high: '17481092',
low: '17403651',
open: '17458833',
@ -19,7 +19,7 @@ export const generateCandles = (
__typename: 'Candle',
},
{
datetime: '2022-04-06T09:30:00Z',
timestamp: '1661516100000000000',
high: '17491202',
low: '17361138',
open: '17446470',
@ -28,7 +28,7 @@ export const generateCandles = (
__typename: 'Candle',
},
{
datetime: '2022-04-06T09:45:00Z',
timestamp: '1661517000000000000',
high: '17424522',
low: '17337719',
open: '17367174',

View File

@ -1,5 +1,5 @@
fragment CandleFields on Candle {
datetime
timestamp
high
low
open

View File

@ -3,7 +3,7 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type CandleFieldsFragment = { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string };
export type CandleFieldsFragment = { __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string };
export type CandlesQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
@ -12,7 +12,7 @@ export type CandlesQueryVariables = Types.Exact<{
}>;
export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candles?: Array<{ __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } | null> | null } | null };
export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candles?: Array<{ __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string } | null> | null } | null };
export type CandlesEventsSubscriptionVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
@ -20,11 +20,11 @@ export type CandlesEventsSubscriptionVariables = Types.Exact<{
}>;
export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } };
export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string } };
export const CandleFieldsFragmentDoc = gql`
fragment CandleFields on Candle {
datetime
timestamp
high
low
open

View File

@ -199,7 +199,7 @@ function parseCandle(
decimalPlaces: number
): Candle {
return {
date: new Date(candle.datetime),
date: new Date(Number(candle.timestamp) / 1_000_000),
high: Number(addDecimal(candle.high, decimalPlaces)),
low: Number(addDecimal(candle.low, decimalPlaces)),
open: Number(addDecimal(candle.open, decimalPlaces)),