Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make constructor functions and extract common types
- Loading branch information
Showing
8 changed files
with
665 additions
and
256 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,64 @@ | ||
module Data.Actus.Contract.Future where | ||
|
||
import Data.Actus.Contract (Contract) | ||
import Data.Actus.Types as Types | ||
import Data.DateTime (DateTime) | ||
import Data.Interval.Duration.Iso (IsoDuration) | ||
import Data.Map.Heterogeneous (HMap) | ||
import Data.Maybe (Maybe) | ||
|
||
newtype Future = Future | ||
( Contract | ||
( calendar :: Calendar | ||
newtype Contract = Contract | ||
( Types.Contract | ||
( calendar :: Types.Calendar | ||
, contractPerformance :: Types.ContractPerformance | ||
, contractStructure :: Types.ContractStructure | ||
, notionalPrincipal :: NotionalPrincipal | ||
, settlement :: Maybe Settlement | ||
, futuresPrice :: Number | ||
, notionalPrincipal :: NotionalPrincipal | ||
, settlement :: Maybe Types.Settlement | ||
) | ||
) | ||
|
||
type Calendar = HMap | ||
( capitalizationEndDate :: Types.Calendar | ||
, businessDayConvention :: Types.BusinessDayConvention | ||
, endOfMonthConvention :: Types.EndOfMonthConvention | ||
) | ||
mkContract | ||
:: DateTime | ||
-> Types.ContractRole | ||
-> String | ||
-> Types.Calendar | ||
-> Types.ContractPerformance | ||
-> Types.ContractStructure | ||
-> NotionalPrincipal | ||
-> Maybe Types.Settlement | ||
-> Number | ||
-> Contract | ||
mkContract | ||
statusDate | ||
contractRole | ||
contractId | ||
calendar | ||
contractPerformance | ||
contractStructure | ||
notionalPrincipal | ||
settlement | ||
futuresPrice = | ||
Contract | ||
{ statusDate | ||
, contractRole | ||
, contractId | ||
, calendar | ||
, contractPerformance | ||
, contractStructure | ||
, futuresPrice | ||
, notionalPrincipal | ||
, settlement | ||
} | ||
|
||
type NotionalPrincipal = | ||
{ maturityDate :: DateTime | ||
, purchase :: Maybe Types.ContractEndEvent | ||
, termination :: Maybe Types.ContractEndEvent | ||
} | ||
|
||
type Settlement = | ||
{ exerciseAmount :: Number | ||
, exerciseDate :: DateTime | ||
, period :: Maybe IsoDuration | ||
, deliverySettlement :: Maybe Types.DeliverySettlement | ||
} | ||
mkNotionalPrincipal | ||
:: DateTime | ||
-> Maybe Types.ContractEndEvent | ||
-> Maybe Types.ContractEndEvent | ||
-> NotionalPrincipal | ||
mkNotionalPrincipal maturityDate purchase termination = | ||
{ maturityDate, purchase, termination } | ||
|
Oops, something went wrong.