(client: EClient, contract: Contract, includeConId = true)
| 13 | * Returns array of makeField() strings ready to join. |
| 14 | */ |
| 15 | export 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, |
nothing calls this directly
no test coverage detected