Skip to content

Commit 38d333d

Browse files
committed
strategy parameters on order blotter
1 parent d7d8dbf commit 38d333d

File tree

7 files changed

+126
-18
lines changed

7 files changed

+126
-18
lines changed

react/opentp-client/src/common/grpcUtilities.tsx

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,61 @@ export function getGrpcErrorMessage( error : Error, prepend?: string) : string {
66
prepend = prepend + ": "
77
}
88

9+
let grpErrorCodeAsStr = error.message
910
switch (error.code) {
10-
case StatusCode.PERMISSION_DENIED:
11-
return prepend + "Permission Denied"
12-
13-
default:
14-
return prepend + error.message
11+
case StatusCode.ABORTED:
12+
grpErrorCodeAsStr = "Aborted"
13+
break
14+
case StatusCode.ALREADY_EXISTS:
15+
grpErrorCodeAsStr = "Already Exists"
16+
break
17+
case StatusCode.CANCELLED:
18+
grpErrorCodeAsStr = "Cancelled"
19+
break
20+
case StatusCode.DATA_LOSS:
21+
grpErrorCodeAsStr = "Data Loss"
22+
break
23+
case StatusCode.DEADLINE_EXCEEDED:
24+
grpErrorCodeAsStr = "Deadline Exceeded"
25+
break
26+
case StatusCode.FAILED_PRECONDITION:
27+
grpErrorCodeAsStr = "Failed Precondition"
28+
break
29+
case StatusCode.INTERNAL:
30+
grpErrorCodeAsStr = "Internal"
31+
break
32+
case StatusCode.INVALID_ARGUMENT:
33+
grpErrorCodeAsStr = "Invalid Argument"
34+
break
35+
case StatusCode.NOT_FOUND:
36+
grpErrorCodeAsStr = "Not Found"
37+
break
38+
case StatusCode.OK:
39+
grpErrorCodeAsStr = "OK"
40+
break
41+
case StatusCode.OUT_OF_RANGE:
42+
grpErrorCodeAsStr = "Out Of Range"
43+
break
44+
case StatusCode.PERMISSION_DENIED:
45+
grpErrorCodeAsStr = "Permission Denied"
46+
break
47+
case StatusCode.RESOURCE_EXHAUSTED:
48+
grpErrorCodeAsStr = "Resource Exhausted"
49+
break
50+
case StatusCode.UNAUTHENTICATED:
51+
grpErrorCodeAsStr = "Unauthenticated"
52+
break
53+
case StatusCode.UNAVAILABLE:
54+
grpErrorCodeAsStr = "Unavailable"
55+
break
56+
case StatusCode.UNIMPLEMENTED:
57+
grpErrorCodeAsStr = "Unimplemented"
58+
break
59+
case StatusCode.UNKNOWN:
60+
grpErrorCodeAsStr = "Unknown Host"
61+
break
62+
1563
}
64+
65+
return prepend + grpErrorCodeAsStr
1666
}

react/opentp-client/src/common/strategydescriptions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { Destinations } from "./destinations"
2+
13
export function getStrategyDisplayName(mic: string) : string | undefined {
24
switch(mic) {
3-
case "XVWAP":
5+
case Destinations.VWAP:
46
return "VWAP STRATEGY"
57
}
68

react/opentp-client/src/components/Container/Container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Alignment, Button, Icon, Menu, MenuItem, Navbar, Popover, Position } from "@blueprintjs/core";
22
import FlexLayout, { Layout, Model, TabNode } from "flexlayout-react";
33
import "flexlayout-react/style/dark.css";
4-
import { Error, StatusCode } from "grpc-web";
4+
import { Error } from "grpc-web";
55
import React, { ReactNode } from 'react';
66
import log from 'loglevel';
77
import { ClientConfigServiceClient } from "../../serverapi/ClientconfigserviceServiceClientPb";

react/opentp-client/src/components/Login/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class Login extends React.Component<Props, State> {
5454
}
5555

5656
if (this.serverUrl.endsWith("localhost:3000")) {
57-
this.serverUrl = "http://127.0.0.1:32054" // for local dev, change this to point at your otp services cluster
57+
this.serverUrl = "http://127.0.0.1:32509" // for local dev, change this to point at your otp services cluster
5858
}
5959

6060
log.info("Connecting to services at:" + this.serverUrl)

react/opentp-client/src/components/OrderBlotter/OrderBlotter.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export default abstract class OrderBlotter<P extends OrderBlotterProps , S exten
7979
<Column key="owner" id="owner" name="Owner" cellRenderer={this.renderOwner} />,
8080
<Column key="errorMsg" id="errorMsg" name="Error" cellRenderer={this.renderErrorMsg} />,
8181
<Column key="version" id="version" name="Version" cellRenderer={this.renderVersion} />,
82-
<Column key="createdby" id="createdby" name="Created By" cellRenderer={this.renderCreatedBy}/>
82+
<Column key="createdby" id="createdby" name="Created By" cellRenderer={this.renderCreatedBy}/>,
83+
<Column key="parameters" id="parameters" name="Parameters" cellRenderer={this.renderParameters}/>
8384
];
8485
}
8586

@@ -96,6 +97,7 @@ export default abstract class OrderBlotter<P extends OrderBlotterProps , S exten
9697
private renderDestination = (row: number) => <Cell>{Array.from(this.state.orders)[row]?.getDestination()}</Cell>;
9798
private renderVersion = (row: number) => <Cell>{Array.from(this.state.orders)[row]?.version}</Cell>;
9899
private renderOwner = (row: number) => <Cell>{Array.from(this.state.orders)[row]?.owner}</Cell>;
100+
private renderParameters = (row: number) => <Cell>{Array.from(this.state.orders)[row]?.parameters}</Cell>;
99101

100102
private renderStatusHeader = (row: number) => {
101103

react/opentp-client/src/components/OrderBlotter/OrderView.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Order, Side, OrderStatus } from '../../serverapi/order_pb';
33
import { Listing } from '../../serverapi/listing_pb';
44
import { ListingService } from '../../services/ListingService';
55
import { getStrategyDisplayName } from '../../common/strategydescriptions';
6+
import { Destinations } from '../../common/destinations';
7+
import { VwapParameters } from '../OrderTicket/Strategies/VwapParams/VwapParamsPanel';
68

79
export interface Filter {
810
id(): string
@@ -110,6 +112,7 @@ export class OrderView {
110112
owner: string;
111113
createdBy: string;
112114
errorMsg: string;
115+
parameters: string;
113116

114117
constructor(order: Order) {
115118
this.id = ""
@@ -124,6 +127,7 @@ export class OrderView {
124127
this.owner = "";
125128
this.errorMsg = "";
126129
this.createdBy = "";
130+
this.parameters = "";
127131
this.setOrder(order)
128132
}
129133

@@ -163,13 +167,30 @@ export class OrderView {
163167
this.owner = order.getOwnerid()
164168
this.errorMsg = order.getErrormessage()
165169
this.createdBy = order.getRootoriginatorref()
170+
this.parameters = this.getParametersDisplayString(order)
166171

167172
}
168173

169174
getOrder(): Order {
170175
return this.order
171176
}
172177

178+
getParametersDisplayString(order: Order): string {
179+
if (order.getDestination() !== "" && order.getExecparametersjson() !== "") {
180+
181+
182+
switch (order.getDestination()) {
183+
case Destinations.VWAP:
184+
// order.getDestination() + ":" + order.getExecparametersjson()
185+
let p = VwapParameters.fromJsonString(order.getExecparametersjson()) as VwapParameters
186+
return p.toDisplayString()
187+
}
188+
}
189+
190+
191+
return ""
192+
}
193+
173194
getStatusString(status: OrderStatus) {
174195

175196
switch (status) {
@@ -186,8 +207,8 @@ export class OrderView {
186207
}
187208

188209
getDestination(): string | undefined {
189-
if( this.listing?.getMarket()?.getMic() ) {
190-
if( this.destination === this.listing?.getMarket()?.getMic() ) {
210+
if (this.listing?.getMarket()?.getMic()) {
211+
if (this.destination === this.listing?.getMarket()?.getMic()) {
191212
return this.listing?.getMarket()?.getName()
192213
}
193214
}

react/opentp-client/src/components/OrderTicket/Strategies/VwapParams/VwapParamsPanel.tsx

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as React from "react";
22
import { Checkbox, Label, NumericInput } from "@blueprintjs/core";
33
import { TimePicker, TimePrecision } from "@blueprintjs/datetime";
44
import { StrategyPanel } from "../../OrderTicket";
5+
import { Destinations } from "../../../../common/destinations";
6+
57

68
export interface Props {
79
children?: React.ReactNode
@@ -40,17 +42,19 @@ export default class VwapParamsPanel extends React.Component<Props, State> imple
4042
}
4143

4244
getDestination(): string {
43-
return "XVWAP"
45+
return Destinations.VWAP
4446
}
4547

4648

4749
getParamsString(): string {
4850

51+
var params : VwapParameters;
4952
if (this.state.setBuckets) {
50-
return JSON.stringify(new VwapParameters(Math.floor(this.startTime.getTime() / 1000), Math.floor(this.endTime.getTime() / 1000), this.buckets))
53+
params = new VwapParameters(Math.floor(this.startTime.getTime() / 1000), Math.floor(this.endTime.getTime() / 1000), this.buckets)
5154
} else {
52-
return JSON.stringify(new VwapParameters(Math.floor(this.startTime.getTime() / 1000), Math.floor(this.endTime.getTime() / 1000)))
55+
params = new VwapParameters(Math.floor(this.startTime.getTime() / 1000), Math.floor(this.endTime.getTime() / 1000))
5356
}
57+
return params.toJsonString()
5458
}
5559

5660
render() {
@@ -88,10 +92,7 @@ export default class VwapParamsPanel extends React.Component<Props, State> imple
8892
}
8993

9094

91-
92-
93-
94-
class VwapParameters {
95+
export class VwapParameters {
9596
utcStartTimeSecs: number;
9697
utcEndTimeSecs: number;
9798
buckets?: number;
@@ -103,6 +104,38 @@ class VwapParameters {
103104
this.utcEndTimeSecs = utcEndTimeSecs;
104105
this.buckets = buckets;
105106
}
107+
108+
109+
110+
static fromJsonString(jsonString : string) : VwapParameters {
111+
let p = JSON.parse(jsonString) as VwapParameters
112+
113+
return new VwapParameters(p.utcStartTimeSecs, p.utcEndTimeSecs, p.buckets)
114+
}
115+
116+
117+
toJsonString() : string {
118+
return JSON.stringify(this)
119+
}
120+
121+
toDisplayString() : string {
122+
123+
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
124+
d.setUTCSeconds(this.utcStartTimeSecs);
125+
126+
127+
let result = "Start:" + d.toLocaleTimeString()
128+
d = new Date(0);
129+
d.setUTCSeconds(this.utcEndTimeSecs);
130+
result += " End:" + d.toLocaleTimeString()
131+
132+
if( this.buckets ) {
133+
result += " Buckets:" + this.buckets
134+
}
135+
136+
return result
137+
}
138+
106139
}
107140

108141

0 commit comments

Comments
 (0)