(cp: ContractProto)
| 66 | // --------------------------------------------------------------------------- |
| 67 | |
| 68 | function decodeContractFromProto(cp: ContractProto): Contract { |
| 69 | const contract = new Contract() |
| 70 | if (cp.conId !== undefined) contract.conId = cp.conId |
| 71 | if (cp.symbol !== undefined) contract.symbol = cp.symbol |
| 72 | if (cp.secType !== undefined) |
| 73 | if (cp.lastTradeDateOrContractMonth !== undefined) contract.lastTradeDateOrContractMonth = cp.lastTradeDateOrContractMonth |
| 74 | if (cp.strike !== undefined) contract.strike = cp.strike |
| 75 | if (cp.right !== undefined) contract.right = cp.right |
| 76 | if (cp.multiplier !== undefined) contract.multiplier = floatMaxString(cp.multiplier) |
| 77 | if (cp.exchange !== undefined) contract.exchange = cp.exchange |
| 78 | if (cp.currency !== undefined) contract.currency = cp.currency |
| 79 | if (cp.localSymbol !== undefined) contract.localSymbol = cp.localSymbol |
| 80 | if (cp.tradingClass !== undefined) contract.tradingClass = cp.tradingClass |
| 81 | if (cp.comboLegsDescrip !== undefined) contract.comboLegsDescrip = cp.comboLegsDescrip |
| 82 | |
| 83 | // combo legs |
| 84 | if (cp.comboLegs && cp.comboLegs.length > 0) { |
| 85 | const legs: ComboLeg[] = [] |
| 86 | for (const clp of cp.comboLegs) { |
| 87 | const leg = new ComboLeg() |
| 88 | if (clp.conId !== undefined) leg.conId = clp.conId |
| 89 | if (clp.ratio !== undefined) leg.ratio = clp.ratio |
| 90 | if (clp.action !== undefined) leg.action = clp.action |
| 91 | if (clp.exchange !== undefined) leg.exchange = clp.exchange |
| 92 | if (clp.openClose !== undefined) leg.openClose = clp.openClose |
| 93 | if (clp.shortSalesSlot !== undefined) leg.shortSaleSlot = clp.shortSalesSlot |
| 94 | if (clp.designatedLocation !== undefined) leg.designatedLocation = clp.designatedLocation |
| 95 | if (clp.exemptCode !== undefined) leg.exemptCode = clp.exemptCode |
| 96 | legs.push(leg) |
| 97 | } |
| 98 | contract.comboLegs = legs |
| 99 | } |
| 100 | |
| 101 | // delta neutral contract |
| 102 | if (cp.deltaNeutralContract !== undefined) { |
| 103 | const dnc = new DeltaNeutralContract() |
| 104 | const dnp = cp.deltaNeutralContract |
| 105 | if (dnp.conId !== undefined) dnc.conId = dnp.conId |
| 106 | if (dnp.delta !== undefined) dnc.delta = dnp.delta |
| 107 | if (dnp.price !== undefined) dnc.price = dnp.price |
| 108 | contract.deltaNeutralContract = dnc |
| 109 | } |
| 110 | |
| 111 | if (cp.lastTradeDate !== undefined) contract.lastTradeDate = cp.lastTradeDate |
| 112 | if (cp.primaryExch !== undefined) contract.primaryExchange = cp.primaryExch |
| 113 | if (cp.issuerId !== undefined) contract.issuerId = cp.issuerId |
| 114 | if (cp.description !== undefined) contract.description = cp.description |
| 115 | |
| 116 | return contract |
| 117 | } |
| 118 | |
| 119 | function decodeOrderComboLegsFromProto(cp: ContractProto): OrderComboLeg[] { |
| 120 | const result: OrderComboLeg[] = [] |
no test coverage detected