Skip to content

Commit

Permalink
Option support for contract-details tool
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Nov 11, 2023
1 parent c369995 commit 3a2e3ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tools/common/ib-api-next-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class IBApiNextApp {
["symbol=<name>", "The symbol name."],
["currency=<currency>", "The contract currency."],
["exchange=<name>", "The destination exchange name."],
["localsymbol=<name>", "The symbol's local symbol."],
];

public static readonly DEFAULT_OPT_CONTRACT_OPTIONS: [string, string][] = [
Expand All @@ -52,6 +53,7 @@ export class IBApiNextApp {
],
["strike=<number>", "The option's strike price."],
["right=<P|C>", " The option type. Valid values are P, PUT, C, CALL."],
["multiplier=<number>", "The option's multiplier."],
];

protected logLevel: LogLevel;
Expand Down Expand Up @@ -267,11 +269,13 @@ export class IBApiNextApp {
conId: (this.cmdLineArgs.conid as number) ?? undefined,
secType: this.cmdLineArgs.sectype as SecType,
symbol: this.cmdLineArgs.symbol as string,
localSymbol: this.cmdLineArgs.localsymbol as string,
currency: (this.cmdLineArgs.currency as string) ?? "USD",
exchange: (this.cmdLineArgs.exchange as string) ?? "SMART",
lastTradeDateOrContractMonth: this.cmdLineArgs.expiry as string,
strike: (this.cmdLineArgs.strike as number) ?? undefined,
right: this.cmdLineArgs.right as OptionType,
multiplier: (this.cmdLineArgs.multiplier as number) ?? undefined,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/contract-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DESCRIPTION_TEXT =
"Requests contract details from TWS and prints it to console.";
const USAGE_TEXT = "Usage: contract-details.js <options>";
const OPTION_ARGUMENTS: [string, string][] = [
...IBApiNextApp.DEFAULT_CONTRACT_OPTIONS,
...IBApiNextApp.DEFAULT_OPT_CONTRACT_OPTIONS,
];
const EXAMPLE_TEXT =
"contract-details.ts -symbol=AMZN -sectype=STK -currency=USD";
Expand Down

0 comments on commit 3a2e3ca

Please sign in to comment.