@oanda/labs-crowd-view-widget 1.0.27 → 1.0.29

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +236 -0
  2. package/codegen.ts +5 -2
  3. package/dist/main/CrowdViewWidget/components/Chart/Chart.js +1 -1
  4. package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  5. package/dist/main/CrowdViewWidget/components/Chart/getOption.js +9 -1
  6. package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
  7. package/dist/main/CrowdViewWidget/components/Chart/getPriceCandlesMock.js +36 -0
  8. package/dist/main/CrowdViewWidget/components/Chart/getPriceCandlesMock.js.map +1 -0
  9. package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
  10. package/dist/main/CrowdViewWidget/components/Chart/utils.js +13 -1
  11. package/dist/main/CrowdViewWidget/components/Chart/utils.js.map +1 -1
  12. package/dist/main/gql/mock/getPriceCandles.js +33 -0
  13. package/dist/main/gql/mock/getPriceCandles.js.map +1 -0
  14. package/dist/main/gql/mock/schema.graphqls +62 -0
  15. package/dist/main/gql/types/gql.js +1 -0
  16. package/dist/main/gql/types/gql.js.map +1 -1
  17. package/dist/main/gql/types/graphql.js +238 -1
  18. package/dist/main/gql/types/graphql.js.map +1 -1
  19. package/dist/module/CrowdViewWidget/components/Chart/Chart.js +2 -2
  20. package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
  21. package/dist/module/CrowdViewWidget/components/Chart/getOption.js +10 -2
  22. package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
  23. package/dist/module/CrowdViewWidget/components/Chart/getPriceCandlesMock.js +29 -0
  24. package/dist/module/CrowdViewWidget/components/Chart/getPriceCandlesMock.js.map +1 -0
  25. package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
  26. package/dist/module/CrowdViewWidget/components/Chart/utils.js +13 -1
  27. package/dist/module/CrowdViewWidget/components/Chart/utils.js.map +1 -1
  28. package/dist/module/gql/mock/getPriceCandles.js +28 -0
  29. package/dist/module/gql/mock/getPriceCandles.js.map +1 -0
  30. package/dist/module/gql/mock/schema.graphqls +62 -0
  31. package/dist/module/gql/types/gql.js +1 -0
  32. package/dist/module/gql/types/gql.js.map +1 -1
  33. package/dist/module/gql/types/graphql.js +237 -0
  34. package/dist/module/gql/types/graphql.js.map +1 -1
  35. package/dist/types/CrowdViewWidget/components/Chart/getPriceCandlesMock.d.ts +2 -0
  36. package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +1 -0
  37. package/dist/types/gql/mock/getPriceCandles.d.ts +2 -0
  38. package/dist/types/gql/types/gql.d.ts +10 -0
  39. package/dist/types/gql/types/graphql.d.ts +84 -2
  40. package/package.json +3 -3
  41. package/src/CrowdViewWidget/components/Chart/Chart.tsx +2 -1
  42. package/src/CrowdViewWidget/components/Chart/getOption.ts +14 -1
  43. package/src/CrowdViewWidget/components/Chart/getPriceCandlesMock.ts +43 -0
  44. package/src/CrowdViewWidget/components/Chart/types.ts +1 -0
  45. package/src/CrowdViewWidget/components/Chart/utils.ts +12 -0
  46. package/src/gql/mock/getPriceCandles.ts +29 -0
  47. package/src/gql/mock/schema.graphqls +62 -0
  48. package/src/gql/types/gql.ts +8 -0
  49. package/src/gql/types/graphql.ts +224 -2
@@ -53,6 +53,7 @@ export declare enum AssetClassName {
53
53
  Cryptocurrency = "CRYPTOCURRENCY",
54
54
  Currency = "CURRENCY",
55
55
  EquityShares = "EQUITY_SHARES",
56
+ Etfs = "ETFS",
56
57
  Indices = "INDICES",
57
58
  Rates = "RATES"
58
59
  }
@@ -60,6 +61,20 @@ export declare enum BookType {
60
61
  Order = "ORDER",
61
62
  Position = "POSITION"
62
63
  }
64
+ export type Candle = {
65
+ __typename?: 'Candle';
66
+ close: Scalars['Float']['output'];
67
+ high: Scalars['Float']['output'];
68
+ low: Scalars['Float']['output'];
69
+ open: Scalars['Float']['output'];
70
+ };
71
+ export type CandlesData = {
72
+ __typename?: 'CandlesData';
73
+ candle: Candle;
74
+ time: Scalars['String']['output'];
75
+ timeSpan: TimeSpan;
76
+ unixTime: Scalars['Int']['output'];
77
+ };
63
78
  export type CorrelationHeatmap = {
64
79
  __typename?: 'CorrelationHeatmap';
65
80
  baseInstrument: Instrument;
@@ -133,6 +148,20 @@ export declare enum Division {
133
148
  Opt = "OPT",
134
149
  Otms = "OTMS"
135
150
  }
151
+ export type ExtendedInstrument = {
152
+ __typename?: 'ExtendedInstrument';
153
+ displayName: Scalars['String']['output'];
154
+ name: Scalars['String']['output'];
155
+ tradeMode: TradeMode;
156
+ };
157
+ export declare enum Granularity {
158
+ Day_1 = "DAY_1",
159
+ Hour_1 = "HOUR_1",
160
+ Hour_4 = "HOUR_4",
161
+ Minute_5 = "MINUTE_5",
162
+ Minute_15 = "MINUTE_15",
163
+ Minute_30 = "MINUTE_30"
164
+ }
136
165
  export type Heatmap = {
137
166
  __typename?: 'Heatmap';
138
167
  instrument: Instrument;
@@ -154,8 +183,9 @@ export declare enum InstrumentDataSource {
154
183
  }
155
184
  export type InstrumentTableResult = {
156
185
  __typename?: 'InstrumentTableResult';
157
- instruments: Array<Instrument>;
186
+ instruments: Array<ExtendedInstrument>;
158
187
  totalCount: Scalars['Int']['output'];
188
+ updatedAt: Scalars['String']['output'];
159
189
  };
160
190
  export type Matrix = {
161
191
  __typename?: 'Matrix';
@@ -186,6 +216,7 @@ export type Query = {
186
216
  correlationMatrix: CorrelationMatrix;
187
217
  currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
188
218
  currencyStrength?: Maybe<Array<CurrencyStrength>>;
219
+ getPriceCandles: Array<CandlesData>;
189
220
  isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
190
221
  mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
191
222
  orderPositionBooks: Array<Maybe<OrderPositionData>>;
@@ -216,6 +247,12 @@ export type QueryCorrelationMatrixArgs = {
216
247
  export type QueryCurrencyPowerBalanceArgs = {
217
248
  timeUnit: CurrencyPowerBalanceTimeUnit;
218
249
  };
250
+ export type QueryGetPriceCandlesArgs = {
251
+ division?: InputMaybe<Division>;
252
+ granularity: Granularity;
253
+ instrument: Scalars['String']['input'];
254
+ timeSpan: TimeSpan;
255
+ };
219
256
  export type QueryIsAllowedPartnerArgs = {
220
257
  url: Scalars['String']['input'];
221
258
  };
@@ -235,13 +272,14 @@ export type QueryResolveInstrumentsByDivisionArgs = {
235
272
  instruments: Array<InputMaybe<Scalars['String']['input']>>;
236
273
  };
237
274
  export type QueryResolveInstrumentsWithFiltersArgs = {
238
- assetClass?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
275
+ assetClass?: InputMaybe<Array<InputMaybe<AssetClassName>>>;
239
276
  count?: InputMaybe<Scalars['Int']['input']>;
240
277
  dataSource?: InputMaybe<InstrumentDataSource>;
241
278
  division: Division;
242
279
  instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
243
280
  offset?: InputMaybe<Scalars['Int']['input']>;
244
281
  searchPattern?: InputMaybe<Scalars['String']['input']>;
282
+ tradeModes?: InputMaybe<Array<InputMaybe<TradeMode>>>;
245
283
  };
246
284
  export type QuerySentimentArgs = {
247
285
  division?: InputMaybe<Division>;
@@ -316,6 +354,19 @@ export type TimeCorrelation = {
316
354
  timeUnit: CorrelationTimeUnit;
317
355
  value?: Maybe<Scalars['Float']['output']>;
318
356
  };
357
+ export declare enum TimeSpan {
358
+ Day_1 = "DAY_1",
359
+ Day_2 = "DAY_2",
360
+ Hour_1 = "HOUR_1",
361
+ Hour_12 = "HOUR_12",
362
+ Month_1 = "MONTH_1",
363
+ Month_3 = "MONTH_3",
364
+ Month_6 = "MONTH_6",
365
+ Week_1 = "WEEK_1",
366
+ Week_2 = "WEEK_2",
367
+ Week_3 = "WEEK_3",
368
+ Year_1 = "YEAR_1"
369
+ }
319
370
  export type TopicalInstrument = {
320
371
  __typename?: 'TopicalInstrument';
321
372
  assetClass?: Maybe<AssetClassName>;
@@ -336,6 +387,14 @@ export declare enum TopicalSort {
336
387
  Popular = "POPULAR",
337
388
  Volatile = "VOLATILE"
338
389
  }
390
+ export declare enum TradeMode {
391
+ TradeCloseonly = "TRADE_CLOSEONLY",
392
+ TradeDisabled = "TRADE_DISABLED",
393
+ TradeFull = "TRADE_FULL",
394
+ TradeLongonly = "TRADE_LONGONLY",
395
+ TradeShortonly = "TRADE_SHORTONLY",
396
+ TradeUndefined = "TRADE_UNDEFINED"
397
+ }
339
398
  export declare enum ValueAtRiskBars {
340
399
  C100 = "C100",
341
400
  C200 = "C200",
@@ -413,6 +472,28 @@ export type GetOrderPositionBooksQuery = {
413
472
  } | null>;
414
473
  } | null>;
415
474
  };
475
+ export type GetPriceCandlesQueryVariables = Exact<{
476
+ division?: InputMaybe<Division>;
477
+ instrument: Scalars['String']['input'];
478
+ granularity: Granularity;
479
+ timeSpan: TimeSpan;
480
+ }>;
481
+ export type GetPriceCandlesQuery = {
482
+ __typename?: 'Query';
483
+ getPriceCandles: Array<{
484
+ __typename?: 'CandlesData';
485
+ time: string;
486
+ unixTime: number;
487
+ timeSpan: TimeSpan;
488
+ candle: {
489
+ __typename?: 'Candle';
490
+ high: number;
491
+ low: number;
492
+ open: number;
493
+ close: number;
494
+ };
495
+ }>;
496
+ };
416
497
  export type ValidateInstrumentsQueryVariables = Exact<{
417
498
  instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
418
499
  division?: InputMaybe<Division>;
@@ -426,4 +507,5 @@ export type ValidateInstrumentsQuery = {
426
507
  } | null> | null;
427
508
  };
428
509
  export declare const GetOrderPositionBooksDocument: DocumentNode<GetOrderPositionBooksQuery, GetOrderPositionBooksQueryVariables>;
510
+ export declare const GetPriceCandlesDocument: DocumentNode<GetPriceCandlesQuery, GetPriceCandlesQueryVariables>;
429
511
  export declare const ValidateInstrumentsDocument: DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-crowd-view-widget",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Labs Crowd View Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.209",
15
+ "@oanda/labs-widget-common": "^1.0.211",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "graphql": "16.8.1"
18
18
  },
@@ -20,5 +20,5 @@
20
20
  "@graphql-codegen/cli": "5.0.0",
21
21
  "@graphql-codegen/client-preset": "4.1.0"
22
22
  },
23
- "gitHead": "3ea75a8eb6299695ea5b697b801040f06fcddb44"
23
+ "gitHead": "ecce179e47e442c6d1dac02607b4ae851f175740"
24
24
  }
@@ -5,7 +5,7 @@ import {
5
5
  Theme,
6
6
  useLayoutProvider,
7
7
  } from '@oanda/labs-widget-common';
8
- import { BarChart, CustomChart } from 'echarts/charts';
8
+ import { BarChart, CandlestickChart, CustomChart } from 'echarts/charts';
9
9
  import {
10
10
  DataZoomInsideComponent,
11
11
  GraphicComponent,
@@ -28,6 +28,7 @@ echarts.use([
28
28
  DataZoomInsideComponent,
29
29
  CustomChart,
30
30
  TooltipComponent,
31
+ CandlestickChart,
31
32
  ]);
32
33
 
33
34
  echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
@@ -1,4 +1,8 @@
1
- import { getGridLines, getLineCommons } from '@oanda/labs-widget-common';
1
+ import {
2
+ colorPalette,
3
+ getGridLines,
4
+ getLineCommons,
5
+ } from '@oanda/labs-widget-common';
2
6
  import * as echarts from 'echarts/core';
3
7
 
4
8
  import {
@@ -60,6 +64,7 @@ export const getOption: GetOptionType = ({
60
64
  xAxisData,
61
65
  ordersPositionsChartData,
62
66
  ordersPositionsBucketWidth,
67
+ candlesSeriesData,
63
68
  }) => {
64
69
  return {
65
70
  animation: false,
@@ -108,6 +113,14 @@ export const getOption: GetOptionType = ({
108
113
  },
109
114
  },
110
115
  series: [
116
+ {
117
+ type: 'candlestick',
118
+ data: candlesSeriesData,
119
+ itemStyle: {
120
+ color: colorPalette.raspberryLight,
121
+ color0: colorPalette.bottleGreenLight,
122
+ },
123
+ },
111
124
  {
112
125
  type: 'custom',
113
126
  name: 'heatmap',
@@ -0,0 +1,43 @@
1
+ import type { Candle } from '../../../gql/types/graphql';
2
+
3
+ export const getPriceCandlesMock = (
4
+ count: number,
5
+ min: number = 1.3,
6
+ max: number = 2.1
7
+ ): Candle[] => {
8
+ const buffer = 0.02;
9
+ const safeMin = min + buffer;
10
+ const safeMax = max - buffer;
11
+
12
+ const initialClose = +(Math.random() * (safeMax - safeMin) + safeMin).toFixed(
13
+ 5
14
+ );
15
+
16
+ return Array.from({ length: count }).reduce<Candle[]>((acc) => {
17
+ const prevClose =
18
+ acc.length === 0 ? initialClose : acc[acc.length - 1].close;
19
+ const isBullish = Math.random() > 0.5;
20
+
21
+ const bodySize = +(Math.random() * 0.05 + 0.015).toFixed(5);
22
+ const wickSize = +(Math.random() * 0.015 + 0.005).toFixed(5);
23
+
24
+ const open = prevClose;
25
+ let close = isBullish ? open + bodySize : open - bodySize;
26
+ close = Math.max(safeMin, Math.min(safeMax, Number(close)));
27
+
28
+ const high = Math.min(
29
+ max,
30
+ Math.max(Number(open), Number(close)) + wickSize
31
+ );
32
+ const low = Math.max(min, Math.min(Number(open), Number(close)) - wickSize);
33
+
34
+ acc.push({
35
+ open: +open.toFixed(5),
36
+ close: +close.toFixed(5),
37
+ low: +low.toFixed(5),
38
+ high: +high.toFixed(5),
39
+ });
40
+
41
+ return acc;
42
+ }, []);
43
+ };
@@ -14,6 +14,7 @@ interface ChartOptionsProps {
14
14
  number,
15
15
  ][];
16
16
  ordersPositionsBucketWidth: number;
17
+ candlesSeriesData: [number, number, number, number][];
17
18
  }
18
19
 
19
20
  export type GetOptionType = (props: ChartOptionsProps) => EChartsOption;
@@ -1,5 +1,6 @@
1
1
  import type { GetOrderPositionBooksQuery } from '../../../gql/types/graphql';
2
2
  import { colorMap } from '../../config';
3
+ import { getPriceCandlesMock } from './getPriceCandlesMock';
3
4
  import type { TransformDataForChartType } from './types';
4
5
 
5
6
  export const getRectColor = (sentiment: number) => {
@@ -69,9 +70,20 @@ export const transformDataForChart: TransformDataForChartType = (data) => {
69
70
  )
70
71
  .filter((item) => Math.abs(item[2]) > 0.15);
71
72
 
73
+ const mockedCandles = getPriceCandlesMock(ordersPositionsChartData.length);
74
+
75
+ const candlesSeriesData: [number, number, number, number][] =
76
+ mockedCandles.map(({ close, open, low, high }) => [
77
+ +close.toFixed(5),
78
+ +open.toFixed(5),
79
+ +low.toFixed(5),
80
+ +high.toFixed(5),
81
+ ]);
82
+
72
83
  return {
73
84
  xAxisData,
74
85
  ordersPositionsChartData,
75
86
  ordersPositionsBucketWidth: mockedData[0]!.bucketWidth,
87
+ candlesSeriesData,
76
88
  };
77
89
  };
@@ -0,0 +1,29 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ const getPriceCandles = gql`
4
+ query GetPriceCandles(
5
+ $division: Division
6
+ $instrument: String!
7
+ $granularity: Granularity!
8
+ $timeSpan: TimeSpan!
9
+ ) {
10
+ getPriceCandles(
11
+ division: $division
12
+ instrument: $instrument
13
+ granularity: $granularity
14
+ timeSpan: $timeSpan
15
+ ) {
16
+ time
17
+ unixTime
18
+ candle {
19
+ high
20
+ low
21
+ open
22
+ close
23
+ }
24
+ timeSpan
25
+ }
26
+ }
27
+ `;
28
+
29
+ export { getPriceCandles };
@@ -0,0 +1,62 @@
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
+ }
@@ -15,6 +15,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
15
15
  const documents = {
16
16
  '\n query GetOrderPositionBooks(\n $instrument: String!\n $bookType: BookType!\n $recentHours: Int\n ) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n':
17
17
  types.GetOrderPositionBooksDocument,
18
+ '\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':
19
+ types.GetPriceCandlesDocument,
18
20
  '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n':
19
21
  types.ValidateInstrumentsDocument,
20
22
  };
@@ -39,6 +41,12 @@ export function graphql(source: string): unknown;
39
41
  export function graphql(
40
42
  source: '\n query GetOrderPositionBooks(\n $instrument: String!\n $bookType: BookType!\n $recentHours: Int\n ) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n'
41
43
  ): (typeof documents)['\n query GetOrderPositionBooks(\n $instrument: String!\n $bookType: BookType!\n $recentHours: Int\n ) {\n orderPositionBooks(\n instrument: $instrument\n bookType: $bookType\n recentHours: $recentHours\n ) {\n bucketWidth\n price\n time\n buckets {\n price\n longCountPercent\n shortCountPercent\n }\n }\n }\n'];
44
+ /**
45
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
46
+ */
47
+ export function graphql(
48
+ source: '\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'
49
+ ): (typeof documents)['\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'];
42
50
  /**
43
51
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
44
52
  */