Skip to content

Commit

Permalink
Merge pull request #1542 from finos/linked-table-view
Browse files Browse the repository at this point in the history
Linked table view
  • Loading branch information
heswell authored Nov 20, 2024
2 parents f13f2b7 + 4b95cc6 commit 717655a
Show file tree
Hide file tree
Showing 21 changed files with 824 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class ArrayDataSource
sort,
title,
viewport,
visualLink,
}: ArrayDataSourceConstructorProps) {
super();
if (!data || !columnDescriptors) {
Expand All @@ -159,6 +160,7 @@ export class ArrayDataSource
);
}

console.log({ visualLink });
this.columnDescriptors = columnDescriptors;
this.dataMap = dataMap;
this.key = keyColumn
Expand Down
14 changes: 11 additions & 3 deletions vuu-ui/packages/vuu-data-test/src/RuntimeVisualLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ export class RuntimeVisualLink {
handleParentSelectEvent: RowSelectionEventHandler = (selection) => {
if (this.#childDataSource) {
const selectedValues = this.pickUniqueSelectedValues(selection);
this.#childDataSource.baseFilter = {
filter: `${this.#childColumnName} in ["${selectedValues.join('","')}"]`,
};
if (selectedValues.length === 0) {
this.#childDataSource.baseFilter = undefined;
} else if (selectedValues.length === 1) {
this.#childDataSource.baseFilter = {
filter: `${this.#childColumnName} = "${selectedValues[0]}"`,
};
} else {
this.#childDataSource.baseFilter = {
filter: `${this.#childColumnName} in ["${selectedValues.join('","')}"]`,
};
}
}
};

Expand Down
22 changes: 22 additions & 0 deletions vuu-ui/packages/vuu-data-test/src/simul/reference-data/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const accounts = [
"Account 01",
"Account 02",
"Account 03",
"Account 04",
"Account 105",
"Account 06",
"Account 07",
"Account 08",
"Account 09",
"Account 10",
"Account 11",
"Account 12",
"Account 13",
"Account 14",
"Account 15",
"Account 16",
"Account 17",
"Account 18",
"Account 19",
"Account 20",
];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const algos = ["DARKLIQ", "IS", "SURESHOT", "VWAP", "LITLIQ", "TWAP"];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const orderStatus = ["NEW", "CANCELLED", "FILLED"];
12 changes: 6 additions & 6 deletions vuu-ui/packages/vuu-data-test/src/simul/reference-data/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getRic } from "./instruments";
import { random } from "../../data-utils";
import { buildDataColumnMap, Table } from "../../Table";
import { schemas } from "../simul-schemas";
import { sides } from "./sides";

export type status = string;
export type ccy = string;
Expand All @@ -15,7 +16,6 @@ export type ric = string;
export type side = string;
export type trader = string;

const SIDE = ["BUY", "SELL"];
const traders = ["Trader A", "Trader B", "Trader C"];
const orderStatus = [
"Filled",
Expand All @@ -39,7 +39,7 @@ export type OrdersDataRow = [
quantity,
ric,
side,
trader
trader,
];

export const OrderColumnMap = {
Expand Down Expand Up @@ -70,10 +70,10 @@ for (let i = 0; i < 100; i++) {
const filledQuantity = isComplete(status)
? quantity
: status === "New"
? 0
: random(0, quantity);
? 0
: random(0, quantity);
const ric = getRic("AAP.L");
const side = SIDE[random(0, 1)];
const side = sides[random(0, sides.length - 1)];
const trader = traders[random(0, traders.length - 1)];

ordersData.push([
Expand All @@ -95,7 +95,7 @@ for (let i = 0; i < 100; i++) {
export const ordersTable = new Table(
schemas.orders,
ordersData,
buildDataColumnMap(schemas, "orders")
buildDataColumnMap(schemas, "orders"),
);

export { ordersData };
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { VuuRowDataItemType } from "@finos/vuu-protocol-types";
import { random } from "../../data-utils";
import { buildDataColumnMap, Table } from "../../Table";
import { schemas } from "../simul-schemas";
import { accounts } from "./accounts";
import { instrumentsData } from "./instruments";
import { orderStatus as statusValues } from "./orderStatus";
import { sides } from "./sides";
import { algos } from "./algos";

const childOrderData: VuuRowDataItemType[][] = [];
const parentOrderData: VuuRowDataItemType[][] = [];

const instrumentMap = buildDataColumnMap(schemas, "instruments");

const PARENT_ORDER_COUNT = 100_000;
const CHILD_ORDER_COUNT = 500_000;

const avgChildOrderPerOrder = Math.round(
CHILD_ORDER_COUNT / PARENT_ORDER_COUNT,
);
const childMaxMultiple = 10;

const start = performance.now();

let childOrderId = 0;

for (let i = 0; i < PARENT_ORDER_COUNT; i++) {
const now = +new Date();
const instrument = instrumentsData[random(0, instrumentsData.length - 1)];

const orderQuantity = 1000 * random(1, 100);
const orderStatus = statusValues[random(0, statusValues.length - 1)];
const filledQty =
orderStatus === "FILLED"
? orderQuantity
: orderStatus === "NEW"
? 0
: orderQuantity - random(100, orderQuantity);
const openQty = orderQuantity - filledQty;

const account = accounts[random(0, accounts.length - 1)];
const algo = algos[random(0, algos.length - 1)];
const averagePrice = 0;
const ccy = "GBP";
const exchange = instrument[instrumentMap.exchange];
const parentOrderIdAsInt = i;
const parentOrderId = `${parentOrderIdAsInt}`;
const lastUpdate = now;
const price = 100;
const quantity = orderQuantity;
const ric = instrument[instrumentMap.ric];
const side = sides[random(0, sides.length - 1)];
const status = orderStatus;
const volLimit = 100;

const childOrderCount = random(
0,
avgChildOrderPerOrder * random(1, childMaxMultiple),
);

let remainingQty = orderQuantity;
for (let j = 0; j < childOrderCount; j++) {
// console.log(`create child`);

const childOrderQuantity = Math.round(remainingQty / (childOrderCount - j));
remainingQty -= childOrderQuantity;
const childOrderStatus = statusValues[random(0, statusValues.length - 1)];
const childFilledQty =
orderStatus === "FILLED"
? childOrderQuantity
: childOrderStatus === "NEW"
? 0
: childOrderQuantity - random(100, childOrderQuantity);
const childOpenQty = childOrderQuantity - childFilledQty;

const averagePrice = 0;
const childIdAsInt = childOrderId++;
const childId = `${childIdAsInt}`;
const lastUpdate = 0;
const price = 100;
const strategy = 0;

const row: VuuRowDataItemType[] = [
account,
averagePrice,
ccy,
exchange,
childFilledQty,
childId,
childIdAsInt,
lastUpdate,
childOpenQty,
parentOrderId,
price,
childOrderQuantity,
ric,
side,
childOrderStatus,
strategy,
volLimit,
];

childOrderData.push(row);
}

const row: VuuRowDataItemType[] = [
account,
algo,
averagePrice,
ccy,
childOrderCount,
exchange,
filledQty,
parentOrderId,
parentOrderIdAsInt,
lastUpdate,
openQty,
price,
quantity,
ric,
side,
status,
volLimit,
];

parentOrderData.push(row);
}
const end = performance.now();

console.log(
`took ${end - start} to create ${parentOrderData.length} orders and ${childOrderData.length} child orders`,
);

export const parentOrdersTable = new Table(
schemas.parentOrders,
parentOrderData,
buildDataColumnMap(schemas, "parentOrders"),
);

export const childOrdersTable = new Table(
schemas.childOrders,
childOrderData,
buildDataColumnMap(schemas, "childOrders"),
);

export { childOrderData, parentOrderData };
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const sides = ["BUY", "SELL"];
Loading

0 comments on commit 717655a

Please sign in to comment.