Skip to content

Commit

Permalink
Allow undefined for all OrderCancel properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Nov 16, 2024
1 parent 8f4f78f commit 73bcccf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class IBApi extends EventEmitter {
let orderCancel: OrderCancel;
if (orderCancelParam == undefined)
orderCancel = {
manualOrderCancelTime: "",
manualOrderCancelTime: undefined,
extOperator: "",
manualOrderIndicator: undefined,
};
Expand Down Expand Up @@ -881,7 +881,7 @@ export class IBApi extends EventEmitter {
this.controller.schedule(() =>
this.controller.encoder.reqGlobalCancel(
orderCancel || {
manualOrderCancelTime: "",
manualOrderCancelTime: undefined,
extOperator: "",
manualOrderIndicator: undefined,
},
Expand Down
6 changes: 3 additions & 3 deletions src/api/order/orderCancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Type describing the parameters of an order cancel
*/
export interface OrderCancel {
manualOrderCancelTime: string;
extOperator: string;
manualOrderIndicator: number;
manualOrderCancelTime?: string;
extOperator?: string;
manualOrderIndicator?: number;
}
8 changes: 4 additions & 4 deletions src/core/io/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
cancelOrder(orderId: number, orderCancel: OrderCancel): void {
if (
this.serverVersion < MIN_SERVER_VER.MANUAL_ORDER_TIME &&
orderCancel.manualOrderCancelTime.length
orderCancel.manualOrderCancelTime?.length
) {
return this.emitError(
"It does not support manual order cancel time attribute",
Expand Down Expand Up @@ -568,7 +568,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
tokens.push(orderId);

if (this.serverVersion >= MIN_SERVER_VER.MANUAL_ORDER_TIME)
tokens.push(orderCancel.manualOrderCancelTime);
tokens.push(orderCancel.manualOrderCancelTime ?? "");

if (
this.serverVersion >= MIN_SERVER_VER.RFQ_FIELDS &&
Expand All @@ -580,7 +580,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
}

if (this.serverVersion >= MIN_SERVER_VER.CME_TAGGING_FIELDS) {
tokens.push(orderCancel.extOperator);
tokens.push(orderCancel.extOperator ?? "");
tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE);
}

Expand Down Expand Up @@ -2251,7 +2251,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
}

if (this.serverVersion >= MIN_SERVER_VER.CME_TAGGING_FIELDS) {
tokens.push(orderCancel.extOperator);
tokens.push(orderCancel.extOperator ?? "");
tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE);
}

Expand Down

0 comments on commit 73bcccf

Please sign in to comment.