Skip to content

Commit

Permalink
Upgrade to server v176
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Sep 20, 2023
1 parent f2ba080 commit 86d574f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export interface IBApiCreationOptions {
}

/** Maximum supported version. */
export const MAX_SUPPORTED_SERVER_VERSION =
MIN_SERVER_VER.WSH_EVENT_DATA_FILTERS;
export const MAX_SUPPORTED_SERVER_VERSION = MIN_SERVER_VER.BOND_ISSUERID;

/** Minimum supported version. */
export const MIN_SERVER_VER_SUPPORTED = 38;
Expand Down
10 changes: 10 additions & 0 deletions src/api/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ export interface Contract {
/** Identifier of the security type. */
secId?: string;

/** Description of the contract. */
description?: string;

/** IssuerId of the contract. */
issuerId?: string;

/*
Combo
*/

/** Description of the combo legs. */
comboLegsDescription?: string;

Expand Down
5 changes: 5 additions & 0 deletions src/core/io/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,11 @@ export class Decoder {
derivativeSecTypes[j] = this.readStr() as SecType;
}

if (this.serverVersion >= MIN_SERVER_VER.BOND_ISSUERID) {
contract.description = this.readStr();
contract.issuerId = this.readStr();
}

contractDescriptions[i] = {
contract: contract,
derivativeSecTypes: derivativeSecTypes,
Expand Down
13 changes: 13 additions & 0 deletions src/core/io/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,16 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
}
}

if (this.serverVersion < MIN_SERVER_VER.BOND_ISSUERID) {
if (contract.issuerId) {
return this.emitError(
"It does not support issuerId parameter in reqContractDetails.",
ErrorCode.UPDATE_TWS,
reqId,
);
}
}

const version = 8;

// send req mkt data msg
Expand Down Expand Up @@ -1939,6 +1949,9 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
args.push(contract.secId);
}

if (this.serverVersion >= MIN_SERVER_VER.BOND_ISSUERID)
args.push(contract.issuerId);

this.sendMsg(args);
}

Expand Down

0 comments on commit 86d574f

Please sign in to comment.