MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / encodeContract

Function encodeContract

packages/ibkr/src/client/encode.ts:15–46  ·  view source on GitHub ↗
(client: EClient, contract: Contract, includeConId = true)

Source from the content-addressed store, hash-verified

13 * Returns array of makeField() strings ready to join.
14 */
15export function encodeContract(client: EClient, contract: Contract, includeConId = true): string[] {
16 const flds: string[] = []
17
18 if (includeConId) {
19 flds.push(makeField(contract.conId))
20 }
21
22 flds.push(
23 makeField(contract.symbol),
24 makeField(contract.secType),
25 makeField(contract.lastTradeDateOrContractMonth),
26 makeFieldHandleEmpty(contract.strike),
27 makeField(contract.right),
28 makeField(contract.multiplier),
29 makeField(contract.exchange),
30 )
31
32 if (client.serverVersion() >= SV.MIN_SERVER_VER_PRIMARYEXCH) {
33 flds.push(makeField(contract.primaryExchange))
34 }
35
36 flds.push(
37 makeField(contract.currency),
38 makeField(contract.localSymbol),
39 )
40
41 if (client.serverVersion() >= SV.MIN_SERVER_VER_TRADING_CLASS) {
42 flds.push(makeField(contract.tradingClass))
43 }
44
45 return flds
46}
47
48/**
49 * Encode contract fields in the "legacy" order (primaryExchange always included,

Callers

nothing calls this directly

Calls 4

makeFieldHandleEmptyFunction · 0.85
pushMethod · 0.65
makeFieldFunction · 0.50
serverVersionMethod · 0.45

Tested by

no test coverage detected