(cp: ContractProtoType)
| 40 | // --------------------------------------------------------------------------- |
| 41 | |
| 42 | function decodeContractFromProto(cp: ContractProtoType): Contract { |
| 43 | const contract = new Contract() |
| 44 | if (cp.conId !== undefined) contract.conId = cp.conId |
| 45 | if (cp.symbol !== undefined) contract.symbol = cp.symbol |
| 46 | if (cp.secType !== undefined) |
| 47 | if (cp.lastTradeDateOrContractMonth !== undefined) contract.lastTradeDateOrContractMonth = cp.lastTradeDateOrContractMonth |
| 48 | if (cp.strike !== undefined) contract.strike = cp.strike |
| 49 | if (cp.right !== undefined) contract.right = cp.right |
| 50 | if (cp.multiplier !== undefined) contract.multiplier = String(cp.multiplier) |
| 51 | if (cp.exchange !== undefined) contract.exchange = cp.exchange |
| 52 | if (cp.currency !== undefined) contract.currency = cp.currency |
| 53 | if (cp.localSymbol !== undefined) contract.localSymbol = cp.localSymbol |
| 54 | if (cp.tradingClass !== undefined) contract.tradingClass = cp.tradingClass |
| 55 | if (cp.comboLegsDescrip !== undefined) contract.comboLegsDescrip = cp.comboLegsDescrip |
| 56 | |
| 57 | if (cp.comboLegs && cp.comboLegs.length > 0) { |
| 58 | contract.comboLegs = cp.comboLegs.map((clp) => { |
| 59 | const leg = new ComboLeg() |
| 60 | if (clp.conId !== undefined) leg.conId = clp.conId |
| 61 | if (clp.ratio !== undefined) leg.ratio = clp.ratio |
| 62 | if (clp.action !== undefined) leg.action = clp.action |
| 63 | if (clp.exchange !== undefined) leg.exchange = clp.exchange |
| 64 | if (clp.openClose !== undefined) leg.openClose = clp.openClose |
| 65 | if (clp.shortSalesSlot !== undefined) leg.shortSaleSlot = clp.shortSalesSlot |
| 66 | if (clp.designatedLocation !== undefined) leg.designatedLocation = clp.designatedLocation |
| 67 | if (clp.exemptCode !== undefined) leg.exemptCode = clp.exemptCode |
| 68 | return leg |
| 69 | }) |
| 70 | } |
| 71 | |
| 72 | if (cp.deltaNeutralContract !== undefined) { |
| 73 | const dnc = new DeltaNeutralContract() |
| 74 | if (cp.deltaNeutralContract.conId !== undefined) dnc.conId = cp.deltaNeutralContract.conId |
| 75 | if (cp.deltaNeutralContract.delta !== undefined) dnc.delta = cp.deltaNeutralContract.delta |
| 76 | if (cp.deltaNeutralContract.price !== undefined) dnc.price = cp.deltaNeutralContract.price |
| 77 | contract.deltaNeutralContract = dnc |
| 78 | } |
| 79 | |
| 80 | if (cp.lastTradeDate !== undefined) contract.lastTradeDate = cp.lastTradeDate |
| 81 | if (cp.primaryExch !== undefined) contract.primaryExchange = cp.primaryExch |
| 82 | if (cp.issuerId !== undefined) contract.issuerId = cp.issuerId |
| 83 | if (cp.description !== undefined) contract.description = cp.description |
| 84 | |
| 85 | return contract |
| 86 | } |
| 87 | |
| 88 | function decodeExecutionFromProto(ep: ExecutionProtoType): Execution { |
| 89 | const execution = new Execution() |
no outgoing calls
no test coverage detected