From e7e1c95277523db43fc86f3281e25ba242cfc525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa?= Date: Fri, 3 Jun 2022 22:07:33 +0000 Subject: [PATCH] Add missing InstrumentFinancing to Instrument primitive --- src/primitives.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/primitives.js b/src/primitives.js index 51bdbf6..2cd9635 100644 --- a/src/primitives.js +++ b/src/primitives.js @@ -167,6 +167,10 @@ class Instrument extends Definition { this.commission = new InstrumentCommission(data['commission']); } + if (data['financing'] !== undefined) { + this.financing = new InstrumentFinancing(data['financing']); + } + } } @@ -261,6 +265,45 @@ class GuaranteedStopLossOrderLevelRestriction extends Definition { } } +const InstrumentFinancing_Properties = [ + new Property( + 'longRate', + 'longRate', + "The financing rate to be used for a long position for the instrument. The value is in decimal rather than percentage points, i.e. 5% is represented as 0.05.", + 'primitive', + 'primitives.DecimalNumber' + ), + new Property( + 'shortRate', + 'shortRate', + "The financing rate to be used for a short position for the instrument. The value is in decimal rather than percentage points, i.e. 5% is represented as 0.05.", + 'primitive', + 'primitives.DecimalNumber' + ), +]; + +class InstrumentFinancing extends Definition { + constructor(data) { + super(); + + this._summaryFormat = ""; + + this._nameFormat = ""; + + this._properties = InstrumentFinancing_Properties; + + data = data || {}; + + if (data['longRate'] !== undefined) { + this.longRate = data['longRate']; + } + + if (data['shortRate'] !== undefined) { + this.shortRate = data['shortRate']; + } + } +} + class EntitySpec { constructor(context) { this.context = context;