@vuu-ui/vuu-data-test 3.5.17 → 3.5.18-beta.1

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.17",
2
+ "version": "3.5.18-beta.1",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
@@ -9,13 +9,13 @@
9
9
  "type-defs": "node ../../scripts/build-type-defs.mjs"
10
10
  },
11
11
  "dependencies": {
12
- "@vuu-ui/vuu-data-local": "3.5.17",
13
- "@vuu-ui/vuu-utils": "3.5.17"
12
+ "@vuu-ui/vuu-data-local": "3.5.18-beta.1",
13
+ "@vuu-ui/vuu-utils": "3.5.18-beta.1"
14
14
  },
15
15
  "devDependencies": {
16
- "@vuu-ui/vuu-protocol-types": "3.5.17",
17
- "@vuu-ui/vuu-data-types": "3.5.17",
18
- "@vuu-ui/vuu-table-types": "3.5.17"
16
+ "@vuu-ui/vuu-protocol-types": "3.5.18-beta.1",
17
+ "@vuu-ui/vuu-data-types": "3.5.18-beta.1",
18
+ "@vuu-ui/vuu-table-types": "3.5.18-beta.1"
19
19
  },
20
20
  "sideEffects": false,
21
21
  "files": [
@@ -1,12 +1,63 @@
1
- import { random } from "../../data-utils.js";
2
1
  import { buildDataColumnMap } from "../../Table.js";
3
2
  import { schemas } from "../simul-schemas.js";
4
- import { instrumentsData } from "./instruments.js";
3
+ import { InstrumentColumnMap, instrumentsData } from "./instruments.js";
5
4
  import TableContainer from "../../core/table/TableContainer.js";
6
- const instrumentsExtendedData = instrumentsData.map((row)=>row.slice(0, -1).concat([
7
- 1 === random(0, 1),
8
- 1 === random(0, 1),
9
- new Date().getTime()
10
- ]));
5
+ const createRandom = (seed)=>()=>{
6
+ seed = seed + 0x6d2b79f5 | 0;
7
+ let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
8
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
9
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
10
+ };
11
+ const randomInt = (next, min, max)=>Math.floor(next() * (max - min + 1)) + min;
12
+ const toScaledDecimal = (value, decimals)=>String(Math.round(value * 10 ** decimals));
13
+ const scaledDecimalEdgeCases = (decimals)=>[
14
+ "0",
15
+ toScaledDecimal(-1234.5, decimals),
16
+ toScaledDecimal(100, decimals),
17
+ "1",
18
+ "-1",
19
+ toScaledDecimal(1.5, decimals)
20
+ ];
21
+ const scaledDecimalColumn = (seed, decimals, min, max)=>{
22
+ const next = createRandom(seed);
23
+ const edgeCases = scaledDecimalEdgeCases(decimals);
24
+ const scale = 10 ** decimals;
25
+ return (rowIndex)=>rowIndex < edgeCases.length ? edgeCases[rowIndex] : String(randomInt(next, min * scale, max * scale));
26
+ };
27
+ const nextNotional = scaledDecimalColumn(2, 2, -1000000, 10000000);
28
+ const nextClosePrice = scaledDecimalColumn(4, 4, 0, 5000);
29
+ const nextFxRate = scaledDecimalColumn(6, 6, 0.5, 2);
30
+ const nextWeight = scaledDecimalColumn(8, 8, 0, 0.05);
31
+ const nextRandom = createRandom(1);
32
+ const ONE_DAY = 86400000;
33
+ const today = new Date();
34
+ today.setHours(0, 0, 0, 0);
35
+ const startOfToday = today.getTime();
36
+ const columns = schemas.instrumentsExtended.columns;
37
+ const instrumentsExtendedData = instrumentsData.map((instrument, rowIndex)=>{
38
+ const values = {
39
+ bbg: instrument[InstrumentColumnMap.bbg],
40
+ currency: instrument[InstrumentColumnMap.currency],
41
+ description: instrument[InstrumentColumnMap.description],
42
+ exchange: instrument[InstrumentColumnMap.exchange],
43
+ isin: instrument[InstrumentColumnMap.string],
44
+ lotSize: instrument[InstrumentColumnMap.number],
45
+ ric: instrument[InstrumentColumnMap.ric],
46
+ side: nextRandom() < 0.5 ? "B" : "S",
47
+ supported: nextRandom() < 0.5,
48
+ wishlist: nextRandom() < 0.5,
49
+ lastUpdated: instrument[InstrumentColumnMap.vuuUpdatedTimestamp],
50
+ price: Math.round(100000 * nextRandom()) / 100,
51
+ notional: nextNotional(rowIndex),
52
+ closePrice: nextClosePrice(rowIndex),
53
+ fxRate: nextFxRate(rowIndex),
54
+ weight: nextWeight(rowIndex),
55
+ tradeDate: startOfToday - rowIndex % 30 * ONE_DAY,
56
+ vuuCreatedTimestamp: instrument[InstrumentColumnMap.vuuCreatedTimestamp],
57
+ vuuUpdatedTimestamp: instrument[InstrumentColumnMap.vuuUpdatedTimestamp],
58
+ vuuMsg: ""
59
+ };
60
+ return columns.map(({ name })=>values[name]);
61
+ });
11
62
  const instrumentsExtendedTable = TableContainer.createTable(schemas.instrumentsExtended, instrumentsExtendedData, buildDataColumnMap(schemas, "instrumentsExtended"));
12
63
  export { instrumentsExtendedTable };
@@ -73,6 +73,10 @@ const schemas = {
73
73
  name: "ric",
74
74
  serverDataType: "string"
75
75
  },
76
+ {
77
+ name: "side",
78
+ serverDataType: "char"
79
+ },
76
80
  {
77
81
  name: "supported",
78
82
  serverDataType: "boolean"
@@ -90,8 +94,24 @@ const schemas = {
90
94
  serverDataType: "double"
91
95
  },
92
96
  {
93
- name: "date",
94
- serverDataType: "long"
97
+ name: "notional",
98
+ serverDataType: "scaleddecimal2"
99
+ },
100
+ {
101
+ name: "closePrice",
102
+ serverDataType: "scaleddecimal4"
103
+ },
104
+ {
105
+ name: "fxRate",
106
+ serverDataType: "scaleddecimal6"
107
+ },
108
+ {
109
+ name: "weight",
110
+ serverDataType: "scaleddecimal8"
111
+ },
112
+ {
113
+ name: "tradeDate",
114
+ serverDataType: "epochtimestamp"
95
115
  },
96
116
  ...VUU_DEFAULT_COLUMNS
97
117
  ],