@vuu-ui/vuu-data-test 2.1.19-beta.1 → 2.1.19-beta.2

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 (61) hide show
  1. package/package.json +8 -9
  2. package/src/ArrayProxy.js +38 -0
  3. package/src/RuntimeVisualLink.js +45 -0
  4. package/src/SessionTable.js +49 -0
  5. package/src/Table.js +96 -0
  6. package/src/TickingArrayDataSource.js +208 -0
  7. package/src/UpdateGenerator.js +72 -0
  8. package/src/basket/BasketModule.js +272 -0
  9. package/src/basket/basket-schemas.js +355 -0
  10. package/src/basket/index.js +2 -0
  11. package/src/basket/reference-data/constituents.js +76 -0
  12. package/src/basket/reference-data/ftse100.js +686 -0
  13. package/src/basket/reference-data/hsi.js +1047 -0
  14. package/src/basket/reference-data/nasdaq100.js +812 -0
  15. package/src/basket/reference-data/prices.js +43 -0
  16. package/src/basket/reference-data/sp500.js +315 -0
  17. package/src/core/module/ModuleContainer.js +21 -0
  18. package/src/core/module/VuuModule.js +476 -0
  19. package/src/core/table/TableContainer.js +97 -0
  20. package/src/data-utils.js +53 -0
  21. package/src/index.js +13 -0
  22. package/src/local-datasource-provider/LocalDatasourceProvider.js +44 -0
  23. package/src/makeSuggestions.js +20 -0
  24. package/src/rowUpdates.js +0 -0
  25. package/src/schemas.js +19 -0
  26. package/src/session-table-utils.js +16 -0
  27. package/src/simul/SimulModule.js +175 -0
  28. package/src/simul/index.js +2 -0
  29. package/src/simul/reference-data/accounts.js +23 -0
  30. package/src/simul/reference-data/algos.js +9 -0
  31. package/src/simul/reference-data/currencies.js +8 -0
  32. package/src/simul/reference-data/index.js +5 -0
  33. package/src/simul/reference-data/instrument-prices.js +48 -0
  34. package/src/simul/reference-data/instruments-extended.js +12 -0
  35. package/src/simul/reference-data/instruments.js +67 -0
  36. package/src/simul/reference-data/isin-generator/convert-string-to-base-ten-number.js +2 -0
  37. package/src/simul/reference-data/isin-generator/fixtures/alphabet.js +27 -0
  38. package/src/simul/reference-data/isin-generator/fixtures/alphanumeric-values.js +7 -0
  39. package/src/simul/reference-data/isin-generator/fixtures/base-ten-numbers.js +13 -0
  40. package/src/simul/reference-data/isin-generator/generate-cusip-check-code.js +17 -0
  41. package/src/simul/reference-data/isin-generator/generate-cusip-without-check-code.js +8 -0
  42. package/src/simul/reference-data/isin-generator/generate-cusip.js +8 -0
  43. package/src/simul/reference-data/isin-generator/generate-random-alphanumeric.js +3 -0
  44. package/src/simul/reference-data/isin-generator/generate-random-base-ten-number.js +2 -0
  45. package/src/simul/reference-data/isin-generator/generate-random-string-of-alphanumeric-chars.js +7 -0
  46. package/src/simul/reference-data/isin-generator/generate-random-string-of-base-ten-chars.js +7 -0
  47. package/src/simul/reference-data/isin-generator/index.js +280 -0
  48. package/src/simul/reference-data/isin-generator/is-odd.js +2 -0
  49. package/src/simul/reference-data/locations.js +45 -0
  50. package/src/simul/reference-data/lotsizes.js +24 -0
  51. package/src/simul/reference-data/orderStatus.js +6 -0
  52. package/src/simul/reference-data/orders.js +64 -0
  53. package/src/simul/reference-data/parent-child-orders.js +117 -0
  54. package/src/simul/reference-data/priceStrategies.js +8 -0
  55. package/src/simul/reference-data/prices.js +78 -0
  56. package/src/simul/reference-data/sides.js +5 -0
  57. package/src/simul/simul-schemas.js +428 -0
  58. package/src/test/TestModule.js +95 -0
  59. package/src/test/index.js +1 -0
  60. package/src/test/test-schemas.js +74 -0
  61. package/src/vuu-row-generator.js +71 -0
@@ -0,0 +1,20 @@
1
+ const checkPattern = (value, pattern)=>new RegExp(`^${pattern}`, "i").test(value);
2
+ const getUniqueValues = (data, columnIndex, pattern = "")=>{
3
+ const uniqueValues = [];
4
+ const set = new Set();
5
+ for (const row of data){
6
+ const value = row[columnIndex];
7
+ if (void 0 !== value && !set.has(value)) {
8
+ set.add(value);
9
+ uniqueValues.push(value);
10
+ }
11
+ }
12
+ uniqueValues.sort();
13
+ return pattern ? uniqueValues.filter((value)=>checkPattern(value.toString(), pattern)).slice(0, 10) : uniqueValues.slice(0, 10);
14
+ };
15
+ const makeSuggestions = (data, columnIndex, pattern)=>new Promise((resolve)=>{
16
+ const uniqueValues = getUniqueValues(data, columnIndex, pattern);
17
+ const result = uniqueValues.length > 20 ? uniqueValues?.slice(0, 20).map((v)=>v.toString()) : uniqueValues.map((v)=>v.toString());
18
+ setTimeout(()=>resolve(result), 100);
19
+ });
20
+ export { makeSuggestions };
File without changes
package/src/schemas.js ADDED
@@ -0,0 +1,19 @@
1
+ import { schemas } from "./basket/basket-schemas.js";
2
+ import { schemas as simul_schemas_js_schemas } from "./simul/simul-schemas.js";
3
+ import { schemas as test_schemas_js_schemas } from "./test/test-schemas.js";
4
+ const schemas_schemas = {
5
+ ...schemas,
6
+ ...simul_schemas_js_schemas,
7
+ ...test_schemas_js_schemas
8
+ };
9
+ const allSchemas = {
10
+ ...schemas,
11
+ ...simul_schemas_js_schemas,
12
+ ...test_schemas_js_schemas
13
+ };
14
+ const getAllSchemas = ()=>schemas_schemas;
15
+ const getSchema = (tableName)=>{
16
+ if (allSchemas[tableName]) return allSchemas[tableName];
17
+ throw Error(`getSchema no schema for table ${tableName}`);
18
+ };
19
+ export { getAllSchemas, getSchema, schemas_schemas as schemas };
@@ -0,0 +1,16 @@
1
+ import { Table, buildDataColumnMapFromSchema } from "./Table.js";
2
+ import { metadataKeys } from "@vuu-ui/vuu-utils";
3
+ const { KEY: KEY } = metadataKeys;
4
+ const createSessionTableFromSelectedRows = (table, selectedRowIds)=>{
5
+ const sessionData = [];
6
+ for(let i = 0; i < selectedRowIds.length; i++)for(let j = 0; j < table.data.length; j++)if (table.data[j][KEY] === selectedRowIds[i]) sessionData.push(table.data[j]);
7
+ return new Table(table.schema, sessionData, buildDataColumnMapFromSchema(table.schema));
8
+ };
9
+ const sessionTableSchema = (schema)=>({
10
+ ...schema,
11
+ columns: schema.columns.concat({
12
+ name: "vuuMsg",
13
+ serverDataType: "string"
14
+ })
15
+ });
16
+ export { createSessionTableFromSelectedRows, sessionTableSchema };
@@ -0,0 +1,175 @@
1
+ import { VuuModule } from "../core/module/VuuModule.js";
2
+ import { instrumentsTable } from "./reference-data/instruments.js";
3
+ import { instrumentsExtendedTable } from "./reference-data/instruments-extended.js";
4
+ import { ordersTable } from "./reference-data/orders.js";
5
+ import { childOrdersTable, parentOrdersTable, startGeneratingNewOrders, stopGeneratingNewOrders } from "./reference-data/parent-child-orders.js";
6
+ import { pricesTable } from "./reference-data/prices.js";
7
+ import { schemas } from "./simul-schemas.js";
8
+ import TableContainer from "../core/table/TableContainer.js";
9
+ const undefinedTables = {
10
+ childOrders: void 0,
11
+ instruments: void 0,
12
+ instrumentsExtended: void 0,
13
+ instrumentPrices: void 0,
14
+ orders: void 0,
15
+ parentOrders: void 0,
16
+ prices: void 0
17
+ };
18
+ class SimulModule extends VuuModule {
19
+ constructor(){
20
+ super("SIMUL");
21
+ }
22
+ #schemas = schemas;
23
+ #tables = {
24
+ childOrders: childOrdersTable,
25
+ instruments: instrumentsTable,
26
+ instrumentsExtended: instrumentsExtendedTable,
27
+ instrumentPrices: TableContainer.createJoinTable({
28
+ module: "SIMUL",
29
+ table: "instrumentPrices"
30
+ }, {
31
+ module: "SIMUL",
32
+ table: "instruments"
33
+ }, {
34
+ module: "SIMUL",
35
+ table: "prices"
36
+ }, "ric"),
37
+ orders: ordersTable,
38
+ parentOrders: parentOrdersTable,
39
+ prices: pricesTable
40
+ };
41
+ get menus() {
42
+ return {
43
+ childOrders: void 0,
44
+ instruments: {
45
+ name: "ROOT",
46
+ menus: [
47
+ {
48
+ context: "selected-rows",
49
+ filter: "",
50
+ name: "Add Instruments To Order",
51
+ rpcName: "ADD_INSTRUMENTS_TO_ORDER"
52
+ },
53
+ {
54
+ context: "selected-rows",
55
+ filter: "",
56
+ name: "Edit Row (server)",
57
+ rpcName: "EDIT_ROW"
58
+ },
59
+ {
60
+ context: "selected-rows",
61
+ filter: "",
62
+ name: "Edit Rows (server)",
63
+ rpcName: "beginEditSession"
64
+ }
65
+ ]
66
+ },
67
+ instrumentsExtended: void 0,
68
+ instrumentPrices: void 0,
69
+ orders: {
70
+ name: "ROOT",
71
+ menus: [
72
+ {
73
+ context: "row",
74
+ filter: 'status in ["New","Partial Exec"]',
75
+ name: "Cancel Order",
76
+ rpcName: "CANCEL_ORDER"
77
+ }
78
+ ]
79
+ },
80
+ parentOrders: void 0,
81
+ prices: void 0
82
+ };
83
+ }
84
+ get schemas() {
85
+ return this.#schemas;
86
+ }
87
+ get editServices() {}
88
+ get menuServices() {
89
+ return {
90
+ ...undefinedTables,
91
+ orders: [
92
+ {
93
+ rpcName: "CANCEL_ORDER",
94
+ service: this.cancelOrder
95
+ }
96
+ ]
97
+ };
98
+ }
99
+ get services() {
100
+ return {
101
+ ...undefinedTables,
102
+ instruments: [
103
+ {
104
+ rpcName: "DELETE_ROW",
105
+ service: this.deleteRow
106
+ }
107
+ ],
108
+ parentOrders: [
109
+ {
110
+ rpcName: "startGeneratingNewOrders",
111
+ service: this.startOrders
112
+ },
113
+ {
114
+ rpcName: "stopGeneratingNewOrders",
115
+ service: this.stopOrders
116
+ }
117
+ ]
118
+ };
119
+ }
120
+ get tables() {
121
+ return this.#tables;
122
+ }
123
+ get visualLinks() {
124
+ return {
125
+ ...undefinedTables,
126
+ childOrders: [
127
+ {
128
+ fromColumn: "parentOrderId",
129
+ toColumn: "id",
130
+ toTable: "parentOrders"
131
+ }
132
+ ],
133
+ parentOrders: [
134
+ {
135
+ fromColumn: "ric",
136
+ toColumn: "ric",
137
+ toTable: "instruments"
138
+ }
139
+ ]
140
+ };
141
+ }
142
+ cancelOrder = async (rpcRequest)=>{
143
+ const { rowKey, vpId } = rpcRequest;
144
+ const table = this.tables.orders;
145
+ const row = table.findByKey(rowKey);
146
+ row[table.map.status] = "Cancelled";
147
+ table.updateRow(row);
148
+ return {
149
+ action: {
150
+ type: "SHOW_NOTIFICATION_ACTION",
151
+ message: `Order id: ${rowKey}`,
152
+ title: "Order cancelled"
153
+ },
154
+ rpcName: "CANCEL_ORDER",
155
+ type: "VIEW_PORT_MENU_RESP",
156
+ vpId
157
+ };
158
+ };
159
+ startOrders = async ()=>{
160
+ startGeneratingNewOrders();
161
+ return {
162
+ type: "SUCCESS_RESULT",
163
+ data: void 0
164
+ };
165
+ };
166
+ stopOrders = async ()=>{
167
+ stopGeneratingNewOrders();
168
+ return {
169
+ type: "SUCCESS_RESULT",
170
+ data: void 0
171
+ };
172
+ };
173
+ }
174
+ const simulModule = new SimulModule();
175
+ export { SimulModule, simulModule };
@@ -0,0 +1,2 @@
1
+ export { isSimulTable, schemas as simulSchemas } from "./simul-schemas.js";
2
+ export { simulModule } from "./SimulModule.js";
@@ -0,0 +1,23 @@
1
+ const accounts = [
2
+ "Account 01",
3
+ "Account 02",
4
+ "Account 03",
5
+ "Account 04",
6
+ "Account 105",
7
+ "Account 06",
8
+ "Account 07",
9
+ "Account 08",
10
+ "Account 09",
11
+ "Account 10",
12
+ "Account 11",
13
+ "Account 12",
14
+ "Account 13",
15
+ "Account 14",
16
+ "Account 15",
17
+ "Account 16",
18
+ "Account 17",
19
+ "Account 18",
20
+ "Account 19",
21
+ "Account 20"
22
+ ];
23
+ export { accounts };
@@ -0,0 +1,9 @@
1
+ const algos = [
2
+ "DARKLIQ",
3
+ "IS",
4
+ "SURESHOT",
5
+ "VWAP",
6
+ "LITLIQ",
7
+ "TWAP"
8
+ ];
9
+ export { algos };
@@ -0,0 +1,8 @@
1
+ const currencies = [
2
+ "CAD",
3
+ "GBX",
4
+ "USD",
5
+ "EUR",
6
+ "GBP"
7
+ ];
8
+ export { currencies };
@@ -0,0 +1,5 @@
1
+ export * from "./currencies.js";
2
+ export * from "./instruments.js";
3
+ export * from "./instrument-prices.js";
4
+ export * from "./prices.js";
5
+ export * from "./locations.js";
@@ -0,0 +1,48 @@
1
+ import { instrumentsData } from "./instruments.js";
2
+ import { pricesData } from "./prices.js";
3
+ const InstrumentPricesColumnMap = {
4
+ ask: 0,
5
+ askSize: 1,
6
+ bbg: 2,
7
+ bid: 3,
8
+ bidSize: 4,
9
+ close: 5,
10
+ currency: 6,
11
+ description: 7,
12
+ exchange: 8,
13
+ isin: 9,
14
+ last: 10,
15
+ lotSize: 11,
16
+ open: 12,
17
+ phase: 13,
18
+ ric: 14,
19
+ scenario: 15,
20
+ vuuCreatedTimestamp: 16,
21
+ vuuUpdatedTimestamp: 17
22
+ };
23
+ const instrumentPrices = [];
24
+ for(let i = 0; i < instrumentsData.length; i++){
25
+ const [bbg, currency, description, exchange, isin, lotSize, ric] = instrumentsData[i];
26
+ const [ask, askSize, bid, bidSize, close, last, open, phase, , scenario] = pricesData[i];
27
+ instrumentPrices.push([
28
+ ask,
29
+ askSize,
30
+ bbg,
31
+ bid,
32
+ bidSize,
33
+ close,
34
+ currency,
35
+ description,
36
+ exchange,
37
+ isin,
38
+ last,
39
+ lotSize,
40
+ open,
41
+ phase,
42
+ ric,
43
+ scenario,
44
+ 0,
45
+ 0
46
+ ]);
47
+ }
48
+ export { InstrumentPricesColumnMap, instrumentPrices };
@@ -0,0 +1,12 @@
1
+ import { random } from "../../data-utils.js";
2
+ import { buildDataColumnMap } from "../../Table.js";
3
+ import { schemas } from "../simul-schemas.js";
4
+ import { instrumentsData } from "./instruments.js";
5
+ 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
+ ]));
11
+ const instrumentsExtendedTable = TableContainer.createTable(schemas.instrumentsExtended, instrumentsExtendedData, buildDataColumnMap(schemas, "instrumentsExtended"));
12
+ export { instrumentsExtendedTable };
@@ -0,0 +1,67 @@
1
+ import { isinGenerator } from "./isin-generator/index.js";
2
+ import TableContainer from "../../core/table/TableContainer.js";
3
+ import { currencies } from "./currencies.js";
4
+ import { locations, suffixes } from "./locations.js";
5
+ import { lotsizes } from "./lotsizes.js";
6
+ import { random } from "../../data-utils.js";
7
+ import { buildDataColumnMap } from "../../Table.js";
8
+ import { schemas } from "../simul-schemas.js";
9
+ import { Clock } from "@vuu-ui/vuu-utils";
10
+ const { createTable: createTable } = TableContainer;
11
+ const today = new Date();
12
+ const clock = new Clock({
13
+ year: today.getFullYear(),
14
+ month: today.getMonth() + 1,
15
+ day: today.getDate(),
16
+ hours: 7,
17
+ minutes: 0,
18
+ seconds: 0,
19
+ milliseconds: 0
20
+ });
21
+ const InstrumentColumnMap = {
22
+ bbg: 0,
23
+ currency: 1,
24
+ description: 2,
25
+ exchange: 3,
26
+ string: 4,
27
+ number: 5,
28
+ ric: 6,
29
+ vuuCreatedTimestamp: 7,
30
+ vuuUpdatedTimestamp: 8
31
+ };
32
+ const instrumentsData = [];
33
+ const chars1 = Array.from("ABCEFGHKMN");
34
+ const chars2 = Array.from("ABCEFGHKMN");
35
+ const chars3 = Array.from("OPQRTUVWYZ");
36
+ const chars4 = Array.from("OPQRTUVWYZ");
37
+ let count = 0;
38
+ for (const char1 of chars1)for (const char2 of chars2)for (const char3 of chars3)for (const char4 of chars4){
39
+ const suffix = suffixes[count % 8];
40
+ const ric = char1 + char2 + char3 + char4 + "." + suffix;
41
+ const bbg = char1 + char2 + char3 + char4 + " " + suffix;
42
+ const description = `${ric} description`;
43
+ const currency = currencies[random(0, 4)];
44
+ const isin = isinGenerator();
45
+ const lotSize = lotsizes[random(0, lotsizes.length - 1)];
46
+ const exchange = locations[suffix][1];
47
+ const timestamp = clock.now;
48
+ instrumentsData.push([
49
+ bbg,
50
+ currency,
51
+ description,
52
+ exchange,
53
+ String(isin),
54
+ lotSize,
55
+ ric,
56
+ timestamp,
57
+ timestamp
58
+ ]);
59
+ count++;
60
+ clock.advance(random(0, 10000));
61
+ }
62
+ const getRic = (defaultRic)=>{
63
+ const row = instrumentsData.at(random(0, instrumentsData.length));
64
+ return row?.[InstrumentColumnMap.ric] ?? defaultRic;
65
+ };
66
+ const instrumentsTable = createTable(schemas.instruments, instrumentsData, buildDataColumnMap(schemas, "instruments"));
67
+ export { InstrumentColumnMap, getRic, instrumentsData, instrumentsTable };
@@ -0,0 +1,2 @@
1
+ const convertStringToBaseTenNumber = (value)=>parseInt(value, 10);
2
+ export { convertStringToBaseTenNumber };
@@ -0,0 +1,27 @@
1
+ const alphabet = [
2
+ "A",
3
+ "B",
4
+ "C",
5
+ "D",
6
+ "E",
7
+ "F",
8
+ "G",
9
+ "H",
10
+ "J",
11
+ "K",
12
+ "L",
13
+ "M",
14
+ "N",
15
+ "P",
16
+ "Q",
17
+ "R",
18
+ "S",
19
+ "T",
20
+ "U",
21
+ "V",
22
+ "W",
23
+ "X",
24
+ "Y",
25
+ "Z"
26
+ ];
27
+ export { alphabet };
@@ -0,0 +1,7 @@
1
+ import { alphabet } from "./alphabet.js";
2
+ import { baseTenNumbers } from "./base-ten-numbers.js";
3
+ const alphanumeric = [
4
+ ...alphabet,
5
+ ...baseTenNumbers
6
+ ];
7
+ export { alphanumeric };
@@ -0,0 +1,13 @@
1
+ const baseTenNumbers = [
2
+ 0,
3
+ 1,
4
+ 2,
5
+ 3,
6
+ 4,
7
+ 5,
8
+ 6,
9
+ 7,
10
+ 8,
11
+ 9
12
+ ];
13
+ export { baseTenNumbers };
@@ -0,0 +1,17 @@
1
+ import { convertStringToBaseTenNumber } from "./convert-string-to-base-ten-number.js";
2
+ import { isOdd } from "./is-odd.js";
3
+ const generateCusipCheckCode = (cusip)=>{
4
+ const cusipLength = cusip.length;
5
+ let currentValue;
6
+ let total = 0;
7
+ for(let i = 0; i < cusipLength; i++){
8
+ currentValue = cusip[i];
9
+ const currentNumberToBaseTen = convertStringToBaseTenNumber(currentValue);
10
+ let currentNumberOrPosition = isNaN(currentNumberToBaseTen) ? currentValue.charCodeAt(0) - "A".charCodeAt(0) + 10 : parseInt(currentValue);
11
+ if (isOdd(i)) currentNumberOrPosition *= 2;
12
+ total = total + Math.floor(currentNumberOrPosition / 10) + currentNumberOrPosition % 10;
13
+ }
14
+ const check = (10 - total % 10) % 10;
15
+ return check;
16
+ };
17
+ export { generateCusipCheckCode };
@@ -0,0 +1,8 @@
1
+ import { generateRandomStringOfAlphanumericChars } from "./generate-random-string-of-alphanumeric-chars.js";
2
+ import { generateRandomStringOfBaseTenChars } from "./generate-random-string-of-base-ten-chars.js";
3
+ const generateCusipWithoutCheckCode = ()=>{
4
+ const randomBaseTenString = generateRandomStringOfBaseTenChars();
5
+ const randomAlphanumericString = generateRandomStringOfAlphanumericChars();
6
+ return randomBaseTenString + randomAlphanumericString;
7
+ };
8
+ export { generateCusipWithoutCheckCode };
@@ -0,0 +1,8 @@
1
+ import { generateCusipCheckCode } from "./generate-cusip-check-code.js";
2
+ import { generateCusipWithoutCheckCode } from "./generate-cusip-without-check-code.js";
3
+ const generateCusip = ()=>{
4
+ const cusip = generateCusipWithoutCheckCode();
5
+ const check = generateCusipCheckCode(cusip);
6
+ return cusip + check;
7
+ };
8
+ export { generateCusip };
@@ -0,0 +1,3 @@
1
+ import { alphanumeric } from "./fixtures/alphanumeric-values.js";
2
+ const generateRandomAlphanumeric = ()=>alphanumeric[Math.floor(Math.random() * alphanumeric.length)];
3
+ export { generateRandomAlphanumeric };
@@ -0,0 +1,2 @@
1
+ const generateRandomBaseTenNumber = ()=>Math.floor(10 * Math.random());
2
+ export { generateRandomBaseTenNumber };
@@ -0,0 +1,7 @@
1
+ import { generateRandomAlphanumeric } from "./generate-random-alphanumeric.js";
2
+ const generateRandomStringOfAlphanumericChars = ()=>{
3
+ let string = "";
4
+ for(let i = 0; i < 2; i++)string += generateRandomAlphanumeric();
5
+ return string;
6
+ };
7
+ export { generateRandomStringOfAlphanumericChars };
@@ -0,0 +1,7 @@
1
+ import { generateRandomBaseTenNumber } from "./generate-random-base-ten-number.js";
2
+ const generateRandomStringOfBaseTenChars = ()=>{
3
+ let string = "";
4
+ for(let i = 0; i < 6; i++)string += generateRandomBaseTenNumber();
5
+ return string;
6
+ };
7
+ export { generateRandomStringOfBaseTenChars };