Moved viewmodels to viewmodel directory. Moved day count basis lookup to a directory and began using the lookup to generate view.

This commit is contained in:
Clinton Alexander 2016-07-12 16:03:54 +01:00
parent a8051e9413
commit 4628fe426c
11 changed files with 163 additions and 126 deletions

View File

@ -1,6 +1,16 @@
"use strict"
define(['utils/dayCountBasisLookup'], (dayCountBasisLookup) => {
define(['utils/dayCountBasisLookup', 'viewmodel/FixedRate'], (dayCountBasisLookup, fixedRateViewModel) => {
let calculationModel = {
expression: "( fixedLeg.notional.quantity * (fixedLeg.fixedRate.ratioUnit.value)) -(floatingLeg.notional.quantity * (calculation.fixingSchedule.get(context.getDate('currentDate')).rate.ratioUnit.value))",
floatingLegPaymentSchedule: {
},
fixedLegPaymentSchedule: {
}
};
let Deal = function(dealViewModel) {
let now = new Date();
let tradeId = `T${now.getUTCFullYear()}-${now.getUTCMonth()}-${now.getUTCDate()}.${now.getUTCHours()}:${now.getUTCMinutes()}:${now.getUTCSeconds()}:${now.getUTCMilliseconds()}`

View File

@ -12,115 +12,6 @@ function formatDateForAngular(dateStr) {
return new Date(parts[0], parts[1], parts[2]);
}
let fixedLegModel = {
fixedRatePayer: "Bank A",
notional: {
quantity: 2500000000
},
paymentFrequency: "Annual",
effectiveDateAdjustment: null,
terminationDateAdjustment: null,
fixedRate: "1.676",
dayCountBasis: "30/360",
//dayCountBasisDay: "D30",
//dayCountBasisYear: "Y360",
rollConvention: "Following",
dayInMonth: 10,
paymentRule: "InArrears",
paymentDelay: "0",
paymentCalendar: "London",
interestPeriodAdjustment: "Adjusted"
};
let floatingLegModel = {
floatingRatePayer: "Bank B",
notional: {
quantity: 2500000000
},
paymentFrequency: "Quarterly",
effectiveDate: new Date(2016, 3, 11),
effectiveDateAdjustment: null,
terminationDate: new Date(2026, 3, 11),
terminationDateAdjustment: null,
dayCountBasis: "30/360",
//dayCountBasisDay: "D30",
//dayCountBasisYear: "Y360",
rollConvention: "Following",
fixingRollConvention: "Following",
dayInMonth: 10,
resetDayInMonth: 10,
paymentRule: "InArrears",
paymentDelay: "0",
paymentCalendar: [ "London" ],
interestPeriodAdjustment: "Adjusted",
fixingPeriodOffset: 2,
resetRule: "InAdvance",
fixingsPerPayment: "Quarterly",
fixingCalendar: [ "NewYork" ],
index: "ICE LIBOR",
indexSource: "Rates Service Provider",
indexTenor: {
name: "3M"
}
};
let calculationModel = {
expression: "( fixedLeg.notional.quantity * (fixedLeg.fixedRate.ratioUnit.value)) -(floatingLeg.notional.quantity * (calculation.fixingSchedule.get(context.getDate('currentDate')).rate.ratioUnit.value))",
floatingLegPaymentSchedule: {
},
fixedLegPaymentSchedule: {
}
};
let fixedRateViewModel = {
ratioUnit: {
value: 0.01 // %
}
}
let commonViewModel = {
baseCurrency: "EUR",
effectiveDate: new Date(2016, 3, 11),
terminationDate: new Date(2026, 3, 11),
eligibleCreditSupport: "Cash in an Eligible Currency",
independentAmounts: {
quantity: 0
},
threshold: {
quantity: 0
},
minimumTransferAmount: {
quantity: 25000000
},
rounding: {
quantity: 1000000
},
valuationDate: "Every Local Business Day",
notificationTime: "2:00pm London",
resolutionTime: "2:00pm London time on the first LocalBusiness Day following the date on which the notice is give",
interestRate: {
oracle: "Rates Service Provider",
tenor: {
name: "6M"
},
ratioUnit: null,
name: "EONIA"
},
addressForTransfers: "",
exposure: {},
localBusinessDay: [ "London" , "NewYork" ],
dailyInterestAmount: "(CashAmount * InterestRate ) / (fixedLeg.notional.token.currencyCode.equals('GBP')) ? 365 : 360",
hashLegalDocs: "put hash here"
};
let dealViewModel = {
fixedLeg: fixedLegModel,
floatingLeg: floatingLegModel,
common: commonViewModel
};
define([
'angular',
'angularRoute',

View File

@ -4,13 +4,16 @@ define([
'angular',
'maskedInput',
'utils/semantic',
'utils/dayCountBasisLookup',
'services/NodeApi',
'Deal'
], (angular, maskedInput, semantic, nodeApi, Deal) => {
], (angular, maskedInput, semantic, dayCountBasisLookup, nodeApi, Deal) => {
angular.module('irsViewer').controller('CreateDealController', function CreateDealController($http, $scope, $location, nodeService) {
semantic.init($scope, nodeService.isLoading);
$scope.dayCountBasisLookup = dayCountBasisLookup;
$scope.deal = nodeService.newDeal();
console.log($scope.deal.fixedLeg.dayCountBasis);
$scope.createDeal = () => {
nodeService.createDeal(new Deal($scope.deal))
.then((tradeId) => $location.path('#/deal/' + tradeId), (resp) => {

View File

@ -1,6 +1,6 @@
'use strict';
define(['angular', 'lodash'], (angular, _) => {
define(['angular', 'lodash', 'viewmodel/deal'], (angular, _, dealViewModel) => {
angular.module('irsViewer').factory('nodeService', ($http) => {
return new (function() {
let date = new Date(2016, 0, 1, 0, 0, 0);

View File

@ -0,0 +1,34 @@
'use strict';
define([], () => {
return {
"30/360": {
"day": "D30",
"year": "Y360"
},
"30E/360": {
"day": "D30E",
"year": "Y360"
},
"ACT/360": {
"day": "DActual",
"year": "Y360"
},
"ACT/365 Fixed": {
"day": "DActual",
"year": "Y365F"
},
"ACT/365 L": {
"day": "DActual",
"year": "Y365L"
},
"ACT/ACT ISDA": {
"day": "DActual",
"year": "YISDA"
},
"ACT/ACT ICMA": {
"day": "DActual",
"year": "YICMA"
},
};
})

View File

@ -0,0 +1,38 @@
'use strict';
define([], () => {
return {
baseCurrency: "EUR",
effectiveDate: new Date(2016, 3, 11),
terminationDate: new Date(2026, 3, 11),
eligibleCreditSupport: "Cash in an Eligible Currency",
independentAmounts: {
quantity: 0
},
threshold: {
quantity: 0
},
minimumTransferAmount: {
quantity: 25000000
},
rounding: {
quantity: 1000000
},
valuationDate: "Every Local Business Day",
notificationTime: "2:00pm London",
resolutionTime: "2:00pm London time on the first LocalBusiness Day following the date on which the notice is give",
interestRate: {
oracle: "Rates Service Provider",
tenor: {
name: "6M"
},
ratioUnit: null,
name: "EONIA"
},
addressForTransfers: "",
exposure: {},
localBusinessDay: [ "London" , "NewYork" ],
dailyInterestAmount: "(CashAmount * InterestRate ) / (fixedLeg.notional.token.currencyCode.equals('GBP')) ? 365 : 360",
hashLegalDocs: "put hash here"
};
});

View File

@ -0,0 +1,9 @@
'use strict';
define(['viewmodel/fixedLeg', 'viewmodel/floatingLeg', 'viewmodel/common'], (fixedLeg, floatingLeg, common) => {
return {
fixedLeg: fixedLeg,
floatingLeg: floatingLeg,
common: common
};
});

View File

@ -0,0 +1,21 @@
'use strict';
define([], () => {
return {
fixedRatePayer: "Bank A",
notional: {
quantity: 2500000000
},
paymentFrequency: "Annual",
effectiveDateAdjustment: null,
terminationDateAdjustment: null,
fixedRate: "1.676",
dayCountBasis: "30/360",
rollConvention: "Following",
dayInMonth: 10,
paymentRule: "InArrears",
paymentDelay: "0",
paymentCalendar: "London",
interestPeriodAdjustment: "Adjusted"
};
});

View File

@ -0,0 +1,9 @@
'use strict';
define([], () => {
return {
ratioUnit: {
value: 0.01 // %
}
};
});

View File

@ -0,0 +1,33 @@
'use strict';
define([], () => {
return {
floatingRatePayer: "Bank B",
notional: {
quantity: 2500000000
},
paymentFrequency: "Quarterly",
effectiveDate: new Date(2016, 3, 11),
effectiveDateAdjustment: null,
terminationDate: new Date(2026, 3, 11),
terminationDateAdjustment: null,
dayCountBasis: "30/360",
rollConvention: "Following",
fixingRollConvention: "Following",
dayInMonth: 10,
resetDayInMonth: 10,
paymentRule: "InArrears",
paymentDelay: "0",
paymentCalendar: [ "London" ],
interestPeriodAdjustment: "Adjusted",
fixingPeriodOffset: 2,
resetRule: "InAdvance",
fixingsPerPayment: "Quarterly",
fixingCalendar: [ "NewYork" ],
index: "ICE LIBOR",
indexSource: "Rates Service Provider",
indexTenor: {
name: "3M"
}
};
});

View File

@ -53,20 +53,9 @@
</div>
<div class="field">
<label>Day Count Basis</label>
<select class="ui selection " ng-model="deal.fixedLeg.dayCountBasis">
<option>30/360</option>
<option>30E/360</option>
<option>30E/360 (IDSA)</option>
<option>30E+/360 ISDO</option>
<option>ACT/360</option>
<option>ACT/365 Fixed</option>
<option>ACT/365 L</option>
<option>ACT/365 A/1</option>
<option>NL/365</option>
<option>ACT/ACT ISDA</option>
<option>ACT/ACT ICMA</option>
<option>Business/252</option>
<option>1/1</option>
<select class="ui selection"
ng-model="deal.fixedLeg.dayCountBasis"
ng-options="key for (key, value) in dayCountBasisLookup">
</select>
</div>
<div class="field">