@oanda/labs-instruments-price-chart-widget 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -0
- package/codegen.ts +2 -5
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +6 -2
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/Main.js +32 -16
- package/dist/main/InstrumentsPriceChartWidget/Main.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js +4 -2
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/components/TimeZoneLabel.js +29 -0
- package/dist/main/InstrumentsPriceChartWidget/components/TimeZoneLabel.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js +50 -11
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js +13 -13
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/components/types.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/config.js +14 -7
- package/dist/main/InstrumentsPriceChartWidget/config.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/render.js +10 -2
- package/dist/main/InstrumentsPriceChartWidget/render.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/types.js.map +1 -1
- package/dist/main/InstrumentsPriceChartWidget/utils.js +12 -0
- package/dist/main/InstrumentsPriceChartWidget/utils.js.map +1 -0
- package/dist/main/gql/{mock/getPriceCandles.js → priceCandles.js} +9 -8
- package/dist/main/gql/priceCandles.js.map +1 -0
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +53 -24
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/translations/sources/en.json +2 -1
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +6 -2
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/Main.js +33 -17
- package/dist/module/InstrumentsPriceChartWidget/Main.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js +4 -2
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/components/TimeZoneLabel.js +21 -0
- package/dist/module/InstrumentsPriceChartWidget/components/TimeZoneLabel.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js +47 -9
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js +14 -14
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/components/types.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/config.js +14 -7
- package/dist/module/InstrumentsPriceChartWidget/config.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/render.js +11 -3
- package/dist/module/InstrumentsPriceChartWidget/render.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/types.js.map +1 -1
- package/dist/module/InstrumentsPriceChartWidget/utils.js +4 -0
- package/dist/module/InstrumentsPriceChartWidget/utils.js.map +1 -0
- package/dist/module/gql/{mock/getPriceCandles.js → priceCandles.js} +9 -8
- package/dist/module/gql/priceCandles.js.map +1 -0
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +52 -23
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/translations/sources/en.json +2 -1
- package/dist/types/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.d.ts +1 -1
- package/dist/types/InstrumentsPriceChartWidget/Main.d.ts +1 -1
- package/dist/types/InstrumentsPriceChartWidget/components/Chart.d.ts +1 -1
- package/dist/types/InstrumentsPriceChartWidget/components/TimeZoneLabel.d.ts +2 -0
- package/dist/types/InstrumentsPriceChartWidget/components/formatters.d.ts +5 -1
- package/dist/types/InstrumentsPriceChartWidget/components/types.d.ts +6 -4
- package/dist/types/InstrumentsPriceChartWidget/config.d.ts +5 -3
- package/dist/types/InstrumentsPriceChartWidget/types.d.ts +5 -1
- package/dist/types/InstrumentsPriceChartWidget/utils.d.ts +3 -0
- package/dist/types/gql/priceCandles.d.ts +2 -0
- package/dist/types/gql/types/gql.d.ts +4 -3
- package/dist/types/gql/types/graphql.d.ts +31 -27
- package/package.json +5 -3
- package/src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx +7 -1
- package/src/InstrumentsPriceChartWidget/Main.tsx +45 -19
- package/src/InstrumentsPriceChartWidget/components/Chart.tsx +2 -1
- package/src/InstrumentsPriceChartWidget/components/TimeZoneLabel.tsx +24 -0
- package/src/InstrumentsPriceChartWidget/components/formatters.ts +72 -13
- package/src/InstrumentsPriceChartWidget/components/getOption.ts +20 -21
- package/src/InstrumentsPriceChartWidget/components/types.ts +6 -4
- package/src/InstrumentsPriceChartWidget/config.ts +16 -7
- package/src/InstrumentsPriceChartWidget/render.tsx +12 -2
- package/src/InstrumentsPriceChartWidget/types.ts +5 -1
- package/src/InstrumentsPriceChartWidget/utils.ts +16 -0
- package/src/gql/{mock/getPriceCandles.ts → priceCandles.ts} +8 -7
- package/src/gql/types/gql.ts +4 -4
- package/src/gql/types/graphql.ts +62 -37
- package/src/translations/sources/en.json +2 -1
- package/test/Main.test.tsx +6 -2
- package/test/mocks/chartMock.ts +201 -37
- package/dist/main/InstrumentsPriceChartWidget/getPriceCandlesMock.js +0 -83
- package/dist/main/InstrumentsPriceChartWidget/getPriceCandlesMock.js.map +0 -1
- package/dist/main/gql/mock/getPriceCandles.js.map +0 -1
- package/dist/main/gql/mock/schema.graphqls +0 -62
- package/dist/module/InstrumentsPriceChartWidget/getPriceCandlesMock.js +0 -76
- package/dist/module/InstrumentsPriceChartWidget/getPriceCandlesMock.js.map +0 -1
- package/dist/module/gql/mock/getPriceCandles.js.map +0 -1
- package/dist/module/gql/mock/schema.graphqls +0 -62
- package/dist/types/InstrumentsPriceChartWidget/getPriceCandlesMock.d.ts +0 -9
- package/dist/types/gql/mock/getPriceCandles.d.ts +0 -2
- package/src/InstrumentsPriceChartWidget/getPriceCandlesMock.tsx +0 -75
- package/src/gql/mock/schema.graphqls +0 -62
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { TimeSpan } from '../gql/types/graphql';
|
|
2
|
-
const generateMockPriceCandles = function () {
|
|
3
|
-
let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;
|
|
4
|
-
let timeSpan = arguments.length > 1 ? arguments[1] : undefined;
|
|
5
|
-
const rawCandles = generateMockCandleData(count);
|
|
6
|
-
return rawCandles.map(_ref => {
|
|
7
|
-
let {
|
|
8
|
-
high,
|
|
9
|
-
low,
|
|
10
|
-
timestamp,
|
|
11
|
-
open,
|
|
12
|
-
close
|
|
13
|
-
} = _ref;
|
|
14
|
-
return {
|
|
15
|
-
__typename: 'CandlesData',
|
|
16
|
-
time: new Date(timestamp).toISOString(),
|
|
17
|
-
unixTime: Math.floor(timestamp / 1000),
|
|
18
|
-
candle: {
|
|
19
|
-
__typename: 'Candle',
|
|
20
|
-
high,
|
|
21
|
-
low,
|
|
22
|
-
open,
|
|
23
|
-
close
|
|
24
|
-
},
|
|
25
|
-
timeSpan
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const generateMockCandleData = function () {
|
|
30
|
-
let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 30;
|
|
31
|
-
const now = Date.now();
|
|
32
|
-
const candleInterval = 30 * 60 * 1000;
|
|
33
|
-
let currentPrice = 1.045;
|
|
34
|
-
const spikeIndex = Math.floor(count * 0.6);
|
|
35
|
-
return Array.from({
|
|
36
|
-
length: count
|
|
37
|
-
}, (_, i) => {
|
|
38
|
-
let trend = i < spikeIndex ? 0.0005 : -0.001;
|
|
39
|
-
if (i === spikeIndex) {
|
|
40
|
-
trend = 0.03;
|
|
41
|
-
}
|
|
42
|
-
if (i > spikeIndex + 3) {
|
|
43
|
-
trend = 0;
|
|
44
|
-
}
|
|
45
|
-
currentPrice += trend;
|
|
46
|
-
currentPrice = Math.max(1.03, Math.min(1.09, currentPrice));
|
|
47
|
-
const noise = (Math.random() - 0.5) * 0.0005;
|
|
48
|
-
currentPrice += noise;
|
|
49
|
-
const open = currentPrice;
|
|
50
|
-
const high = open + Math.random() * 0.0008;
|
|
51
|
-
const close = open + (Math.random() - 0.5) * 0.0005;
|
|
52
|
-
const low = open - Math.random() * 0.0008;
|
|
53
|
-
const finalHigh = Math.max(open, close, high);
|
|
54
|
-
const finalLow = Math.min(open, close, low);
|
|
55
|
-
return {
|
|
56
|
-
timestamp: now - (count - i) * candleInterval,
|
|
57
|
-
high: finalHigh,
|
|
58
|
-
open,
|
|
59
|
-
close,
|
|
60
|
-
low: finalLow
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
export const getPriceCandlesMock = _ref2 => {
|
|
65
|
-
let {
|
|
66
|
-
division
|
|
67
|
-
} = _ref2;
|
|
68
|
-
return {
|
|
69
|
-
loading: false,
|
|
70
|
-
error: undefined,
|
|
71
|
-
data: {
|
|
72
|
-
getPriceCandles: generateMockPriceCandles(30, TimeSpan.Day_1)
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=getPriceCandlesMock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPriceCandlesMock.js","names":["TimeSpan","generateMockPriceCandles","count","arguments","length","undefined","timeSpan","rawCandles","generateMockCandleData","map","_ref","high","low","timestamp","open","close","__typename","time","Date","toISOString","unixTime","Math","floor","candle","now","candleInterval","currentPrice","spikeIndex","Array","from","_","i","trend","max","min","noise","random","finalHigh","finalLow","getPriceCandlesMock","_ref2","division","loading","error","data","getPriceCandles","Day_1"],"sources":["../../../src/InstrumentsPriceChartWidget/getPriceCandlesMock.tsx"],"sourcesContent":["import { type CandlesData, TimeSpan } from '../gql/types/graphql';\nimport type { MainProps } from './types';\n\nconst generateMockPriceCandles = (\n count = 30,\n timeSpan: TimeSpan\n): CandlesData[] => {\n const rawCandles = generateMockCandleData(count);\n\n return rawCandles.map(({ high, low, timestamp, open, close }) => ({\n __typename: 'CandlesData',\n time: new Date(timestamp).toISOString(),\n unixTime: Math.floor(timestamp / 1000),\n candle: {\n __typename: 'Candle',\n high,\n low,\n open,\n close,\n },\n timeSpan,\n }));\n};\n\nconst generateMockCandleData = (count: number = 30) => {\n const now = Date.now();\n const candleInterval = 30 * 60 * 1000;\n\n let currentPrice = 1.045;\n const spikeIndex = Math.floor(count * 0.6);\n\n return Array.from({ length: count }, (_, i) => {\n let trend = i < spikeIndex ? 0.0005 : -0.001;\n\n if (i === spikeIndex) {\n trend = 0.03;\n }\n\n if (i > spikeIndex + 3) {\n trend = 0;\n }\n\n currentPrice += trend;\n\n currentPrice = Math.max(1.03, Math.min(1.09, currentPrice));\n\n const noise = (Math.random() - 0.5) * 0.0005;\n currentPrice += noise;\n\n const open = currentPrice;\n const high = open + Math.random() * 0.0008;\n const close = open + (Math.random() - 0.5) * 0.0005;\n const low = open - Math.random() * 0.0008;\n\n const finalHigh = Math.max(open, close, high);\n const finalLow = Math.min(open, close, low);\n\n return {\n timestamp: now - (count - i) * candleInterval,\n high: finalHigh,\n open,\n close,\n low: finalLow,\n };\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const getPriceCandlesMock = ({ division }: MainProps) => ({\n loading: false,\n error: undefined,\n data: {\n getPriceCandles: generateMockPriceCandles(30, TimeSpan.Day_1),\n },\n});\n"],"mappings":"AAAA,SAA2BA,QAAQ,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EAAoB,CAAC,GAAAD,KAAA;EAAA,OAAM;IAC/DE,OAAO,EAAE,KAAK;IACdC,KAAK,EAAEtC,SAAS;IAChBuC,IAAI,EAAE;MACJC,eAAe,EAAE5C,wBAAwB,CAAC,EAAE,EAAED,QAAQ,CAAC8C,KAAK;IAC9D;EACF,CAAC;AAAA,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPriceCandles.js","names":["gql","getPriceCandles"],"sources":["../../../../src/gql/mock/getPriceCandles.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nconst getPriceCandles = gql`\n query GetPriceCandles(\n $division: Division\n $instrument: String!\n $granularity: Granularity!\n $timeSpan: TimeSpan!\n ) {\n getPriceCandles(\n division: $division\n instrument: $instrument\n granularity: $granularity\n timeSpan: $timeSpan\n ) {\n time\n unixTime\n candle {\n high\n low\n open\n close\n }\n timeSpan\n }\n }\n`;\n\nexport { getPriceCandles };\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,MAAMC,eAAe,GAAGD,GAAG;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,SAASC,eAAe","ignoreList":[]}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
enum TimeSpan {
|
|
2
|
-
HOUR_1
|
|
3
|
-
HOUR_12
|
|
4
|
-
DAY_1
|
|
5
|
-
DAY_2
|
|
6
|
-
WEEK_1
|
|
7
|
-
WEEK_2
|
|
8
|
-
WEEK_3
|
|
9
|
-
MONTH_1
|
|
10
|
-
MONTH_3
|
|
11
|
-
MONTH_6
|
|
12
|
-
YEAR_1
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enum Granularity {
|
|
16
|
-
MINUTE_5
|
|
17
|
-
MINUTE_15
|
|
18
|
-
MINUTE_30
|
|
19
|
-
HOUR_1
|
|
20
|
-
HOUR_4
|
|
21
|
-
DAY_1
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
enum Division {
|
|
25
|
-
OAP
|
|
26
|
-
OAU
|
|
27
|
-
OC
|
|
28
|
-
OCAN
|
|
29
|
-
OEL
|
|
30
|
-
OGM
|
|
31
|
-
OJ
|
|
32
|
-
OPT
|
|
33
|
-
OTMS
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Candle {
|
|
37
|
-
high: Float!
|
|
38
|
-
low: Float!
|
|
39
|
-
open: Float!
|
|
40
|
-
close: Float!
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type Instrument {
|
|
44
|
-
name: String!
|
|
45
|
-
displayName: String!
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type CandlesData {
|
|
49
|
-
time: String!
|
|
50
|
-
unixTime: Int!
|
|
51
|
-
candle: Candle!
|
|
52
|
-
timeSpan: TimeSpan!
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type Query {
|
|
56
|
-
getPriceCandles(
|
|
57
|
-
division: Division
|
|
58
|
-
instrument: String!
|
|
59
|
-
granularity: Granularity!
|
|
60
|
-
timeSpan: TimeSpan!
|
|
61
|
-
): [CandlesData!]!
|
|
62
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type CandlesData } from '../gql/types/graphql';
|
|
2
|
-
import type { MainProps } from './types';
|
|
3
|
-
export declare const getPriceCandlesMock: ({ division }: MainProps) => {
|
|
4
|
-
loading: boolean;
|
|
5
|
-
error: undefined;
|
|
6
|
-
data: {
|
|
7
|
-
getPriceCandles: CandlesData[];
|
|
8
|
-
};
|
|
9
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { type CandlesData, TimeSpan } from '../gql/types/graphql';
|
|
2
|
-
import type { MainProps } from './types';
|
|
3
|
-
|
|
4
|
-
const generateMockPriceCandles = (
|
|
5
|
-
count = 30,
|
|
6
|
-
timeSpan: TimeSpan
|
|
7
|
-
): CandlesData[] => {
|
|
8
|
-
const rawCandles = generateMockCandleData(count);
|
|
9
|
-
|
|
10
|
-
return rawCandles.map(({ high, low, timestamp, open, close }) => ({
|
|
11
|
-
__typename: 'CandlesData',
|
|
12
|
-
time: new Date(timestamp).toISOString(),
|
|
13
|
-
unixTime: Math.floor(timestamp / 1000),
|
|
14
|
-
candle: {
|
|
15
|
-
__typename: 'Candle',
|
|
16
|
-
high,
|
|
17
|
-
low,
|
|
18
|
-
open,
|
|
19
|
-
close,
|
|
20
|
-
},
|
|
21
|
-
timeSpan,
|
|
22
|
-
}));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const generateMockCandleData = (count: number = 30) => {
|
|
26
|
-
const now = Date.now();
|
|
27
|
-
const candleInterval = 30 * 60 * 1000;
|
|
28
|
-
|
|
29
|
-
let currentPrice = 1.045;
|
|
30
|
-
const spikeIndex = Math.floor(count * 0.6);
|
|
31
|
-
|
|
32
|
-
return Array.from({ length: count }, (_, i) => {
|
|
33
|
-
let trend = i < spikeIndex ? 0.0005 : -0.001;
|
|
34
|
-
|
|
35
|
-
if (i === spikeIndex) {
|
|
36
|
-
trend = 0.03;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (i > spikeIndex + 3) {
|
|
40
|
-
trend = 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
currentPrice += trend;
|
|
44
|
-
|
|
45
|
-
currentPrice = Math.max(1.03, Math.min(1.09, currentPrice));
|
|
46
|
-
|
|
47
|
-
const noise = (Math.random() - 0.5) * 0.0005;
|
|
48
|
-
currentPrice += noise;
|
|
49
|
-
|
|
50
|
-
const open = currentPrice;
|
|
51
|
-
const high = open + Math.random() * 0.0008;
|
|
52
|
-
const close = open + (Math.random() - 0.5) * 0.0005;
|
|
53
|
-
const low = open - Math.random() * 0.0008;
|
|
54
|
-
|
|
55
|
-
const finalHigh = Math.max(open, close, high);
|
|
56
|
-
const finalLow = Math.min(open, close, low);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
timestamp: now - (count - i) * candleInterval,
|
|
60
|
-
high: finalHigh,
|
|
61
|
-
open,
|
|
62
|
-
close,
|
|
63
|
-
low: finalLow,
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
69
|
-
export const getPriceCandlesMock = ({ division }: MainProps) => ({
|
|
70
|
-
loading: false,
|
|
71
|
-
error: undefined,
|
|
72
|
-
data: {
|
|
73
|
-
getPriceCandles: generateMockPriceCandles(30, TimeSpan.Day_1),
|
|
74
|
-
},
|
|
75
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
enum TimeSpan {
|
|
2
|
-
HOUR_1
|
|
3
|
-
HOUR_12
|
|
4
|
-
DAY_1
|
|
5
|
-
DAY_2
|
|
6
|
-
WEEK_1
|
|
7
|
-
WEEK_2
|
|
8
|
-
WEEK_3
|
|
9
|
-
MONTH_1
|
|
10
|
-
MONTH_3
|
|
11
|
-
MONTH_6
|
|
12
|
-
YEAR_1
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
enum Granularity {
|
|
16
|
-
MINUTE_5
|
|
17
|
-
MINUTE_15
|
|
18
|
-
MINUTE_30
|
|
19
|
-
HOUR_1
|
|
20
|
-
HOUR_4
|
|
21
|
-
DAY_1
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
enum Division {
|
|
25
|
-
OAP
|
|
26
|
-
OAU
|
|
27
|
-
OC
|
|
28
|
-
OCAN
|
|
29
|
-
OEL
|
|
30
|
-
OGM
|
|
31
|
-
OJ
|
|
32
|
-
OPT
|
|
33
|
-
OTMS
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Candle {
|
|
37
|
-
high: Float!
|
|
38
|
-
low: Float!
|
|
39
|
-
open: Float!
|
|
40
|
-
close: Float!
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type Instrument {
|
|
44
|
-
name: String!
|
|
45
|
-
displayName: String!
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type CandlesData {
|
|
49
|
-
time: String!
|
|
50
|
-
unixTime: Int!
|
|
51
|
-
candle: Candle!
|
|
52
|
-
timeSpan: TimeSpan!
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type Query {
|
|
56
|
-
getPriceCandles(
|
|
57
|
-
division: Division
|
|
58
|
-
instrument: String!
|
|
59
|
-
granularity: Granularity!
|
|
60
|
-
timeSpan: TimeSpan!
|
|
61
|
-
): [CandlesData!]!
|
|
62
|
-
}
|