diff --git a/src/api/api.ts b/src/api/api.ts index 98aa0583..1a4dfc71 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -387,13 +387,13 @@ export class IBApi extends EventEmitter { orderCancel = { manualOrderCancelTime: "", extOperator: "", - manualOrderIndicator: 0, + manualOrderIndicator: undefined, }; else if (typeof orderCancelParam == "string") orderCancel = { manualOrderCancelTime: orderCancelParam, extOperator: "", - manualOrderIndicator: 0, + manualOrderIndicator: undefined, }; else orderCancel = orderCancelParam; this.controller.schedule(() => @@ -883,7 +883,7 @@ export class IBApi extends EventEmitter { orderCancel || { manualOrderCancelTime: "", extOperator: "", - manualOrderIndicator: 0, + manualOrderIndicator: undefined, }, ), ); diff --git a/src/core/io/encoder.ts b/src/core/io/encoder.ts index a8582004..ef9c1397 100644 --- a/src/core/io/encoder.ts +++ b/src/core/io/encoder.ts @@ -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", @@ -546,8 +546,8 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] { if (this.serverVersion < MIN_SERVER_VER.CME_TAGGING_FIELDS) { if ( - (orderCancel?.extOperator && orderCancel?.extOperator != "") || - orderCancel?.manualOrderIndicator + orderCancel.extOperator?.length || + orderCancel.manualOrderIndicator != undefined ) { return this.emitError( "It does not support ext operator and manual order indicator parameters", @@ -581,7 +581,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] { if (this.serverVersion >= MIN_SERVER_VER.CME_TAGGING_FIELDS) { tokens.push(orderCancel.extOperator); - tokens.push(orderCancel.manualOrderIndicator); + tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE); } this.sendMsg(tokens); @@ -2230,8 +2230,8 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] { if (this.serverVersion < MIN_SERVER_VER.CME_TAGGING_FIELDS) { if ( - (orderCancel?.extOperator && orderCancel?.extOperator != "") || - orderCancel?.manualOrderIndicator + orderCancel.extOperator?.length || + orderCancel.manualOrderIndicator != undefined ) { return this.emitError( "It does not support ext operator and manual order indicator parameters", @@ -2252,7 +2252,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] { if (this.serverVersion >= MIN_SERVER_VER.CME_TAGGING_FIELDS) { tokens.push(orderCancel.extOperator); - tokens.push(orderCancel.manualOrderIndicator); + tokens.push(orderCancel.manualOrderIndicator ?? Integer_MAX_VALUE); } this.sendMsg(tokens);