Commit b2abb7d4 by Amelin Konstantin

Add CommodityOptionTemplate.

parent d2118f9d
......@@ -25,7 +25,8 @@ object Main {
case v if v == "bondOption" => throw new Exception("Undefined trade type")
case v if v == "equityOption" =>
if (debugMode) new EquityOptionTemplate(source) with Logger else new EquityOptionTemplate(source)
case v if v == "commodityOption" => throw new Exception("Undefined trade type")
case v if v == "commodityOption" =>
if (debugMode) new CommodityOptionTemplate(source) with Logger else new CommodityOptionTemplate(source)
case v => throw new Exception("Undefined trade type")
}
}
......
package templates
import scala.xml.Node
class CommodityOptionTemplate(source: Node) extends TradeTemplate(source) {
protected[this] def templateTradeBody: Node = {
<fpml:commodityOption>
<fpml:productType>{ get(source \ "trade" \ "commodityOption" \ "productType") }</fpml:productType>
<fpml:productId productIdScheme={ get(source \ "trade" \ "commodityOption" \ "productId", "productIdScheme") }>{ get(source \ "trade" \ "commodityOption" \ "productId") }</fpml:productId>
<fpml:buyerPartyReference href={ get(source \ "trade" \ "commodityOption" \ "buyerPartyReference", "href") }/>
<fpml:sellerPartyReference href={ get(source \ "trade" \ "commodityOption" \ "sellerPartyReference", "href") }/>
<fpml:optionType>{ get(source \ "trade" \ "commodityOption" \ "optionType") }</fpml:optionType>
<fpml:commodity id={ get(source \ "trade" \ "commodityOption" \ "commodity", "id") }>
<fpml:instrumentId instrumentIdScheme={ get(source \ "trade" \ "commodityOption" \ "commodity" \ "instrumentId", "instrumentIdScheme") }>{ get(source \ "trade" \ "commodityOption" \ "commodity" \ "instrumentId") }</fpml:instrumentId>
<fpml:unit>{ get(source \ "trade" \ "commodityOption" \ "commodity" \ "unit") }</fpml:unit>
<fpml:currency>{ get(source \ "trade" \ "commodityOption" \ "commodity" \ "currency") }</fpml:currency>
</fpml:commodity>
<fpml:totalNotionalQuantity>{ get(source \ "trade" \ "commodityOption" \ "totalNotionalQuantity") }</fpml:totalNotionalQuantity>
<fpml:exercise>
<fpml:americanExercise>
<fpml:exercisePeriod>
<fpml:commencementDate>
<fpml:adjustableDate>
<fpml:unadjustedDate>{ get(source \ "trade" \ "commodityOption" \\ "americanExercise" \\ "commencementDate" \\ "unadjustedDate") }</fpml:unadjustedDate>
</fpml:adjustableDate>
</fpml:commencementDate>
<fpml:expirationDate>
<fpml:adjustableDate>
<fpml:unadjustedDate>{ get(source \ "trade" \ "commodityOption" \\ "americanExercise" \\ "expirationDate" \\ "unadjustedDate") }</fpml:unadjustedDate>
</fpml:adjustableDate>
</fpml:expirationDate>
</fpml:exercisePeriod>
</fpml:americanExercise>
<fpml:europeanExercise>
<fpml:expirationDate>
<fpml:adjustableDate>
<fpml:unadjustedDate>{ get(source \ "trade" \ "commodityOption" \\ "europeanExercise" \\ "unadjustedDate") }</fpml:unadjustedDate>
</fpml:adjustableDate>
</fpml:expirationDate>
</fpml:europeanExercise>
<fpml:settlementCurrency>{ get(source \ "trade" \ "commodityOption" \ "exercise" \ "settlementCurrency") }</fpml:settlementCurrency>
<fpml:paymentDates>
<fpml:adjustableDates>
<fpml:unadjustedDate>{ get(source \ "trade" \ "commodityOption" \ "exercise" \ "paymentDates" \\ "unadjustedDate" ) }</fpml:unadjustedDate>
</fpml:adjustableDates>
</fpml:paymentDates>
</fpml:exercise>
<fpml:strikePricePerUnit>
<fpml:currency>{ get(source \ "trade" \ "commodityOption" \ "strikePricePerUnit" \ "currency") }</fpml:currency>
<fpml:amount>{ get(source \ "trade" \ "commodityOption" \ "strikePricePerUnit" \ "amount") }</fpml:amount>
</fpml:strikePricePerUnit>
<fpml:floatingStrikePricePerUnit>
<fpml:pricingDates>
<fpml:pricingDates>
<fpml:unadjustedDate>{ get(source \ "trade" \ "commodityOption" \ "floatingStrikePricePerUnit" \ "pricingDates" \\ "unadjustedDate" ) }</fpml:unadjustedDate>
</fpml:pricingDates>
</fpml:pricingDates>
<fpml:spread>
<fpml:currency>{ get(source \ "trade" \ "commodityOption" \ "floatingStrikePricePerUnit" \\ "currency") }</fpml:currency>
<fpml:amount>{ get(source \ "trade" \ "commodityOption" \ "floatingStrikePricePerUnit" \\ "amount") }</fpml:amount>
<fpml:spreadUnit>{ get(source \ "trade" \ "commodityOption" \ "floatingStrikePricePerUnit" \\ "spreadUnit") }</fpml:spreadUnit>
</fpml:spread>
<fpml:spreadPercentage>{ get(source \ "trade" \ "commodityOption" \ "floatingStrikePricePerUnit" \ "spreadPercentage") }</fpml:spreadPercentage>
</fpml:floatingStrikePricePerUnit>
<fpml:premium>
<fpml:payerPartyReference href={ get(source \ "trade" \ "commodityOption" \ "premium" \"payerPartyReference", "href") }/>
<fpml:receiverPartyReference href={ get(source \ "trade" \ "commodityOption" \ "premium" \"receiverPartyReference", "href") }/>
<fpml:paymentAmount>
<fpml:currency>{ get(source \ "trade" \ "commodityOption" \ "premium" \\ "currency") }</fpml:currency>
<fpml:amount>{ get(source \ "trade" \ "commodityOption" \ "premium" \\ "amount") }</fpml:amount>
</fpml:paymentAmount>
</fpml:premium>
</fpml:commodityOption>
}
def isStraight = true
}
......@@ -6,121 +6,117 @@ abstract class TradeTemplate(source: Node) extends Template(source) {
protected[this] def templateTradeBody: Node
def template: Node = {
<signedDocument xmlns="http://www.fpml.ru/repository">
<document>
<fpml:nonpublicExecutionReport xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
xmlns:fpmlext="http://www.fpml.org/FpML-5/ext" xmlns:rtsrep="http://www.fpml.ru/repository"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fpmlVersion="5-7">
<fpml:header>
<fpml:messageId>{ get(source \ "header" \"messageId") }</fpml:messageId>
<fpml:sentBy>{ get(source \ "header" \ "sentBy") }</fpml:sentBy>
<fpml:sendTo>{ get(source \ "header" \ "sendTo") }</fpml:sendTo>
<fpml:creationTimestamp>{ get(source \ "header" \ "creationTimestamp") }</fpml:creationTimestamp>
<fpml:implementationSpecification>
<fpml:version>2</fpml:version>
</fpml:implementationSpecification>
</fpml:header>
<fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection>
<fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId>
<fpml:trade>
<fpml:tradeHeader>
{ for { s <- source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier"
id = get(s \ "partyReference", "href").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:partyTradeIdentifier>
<fpml:partyReference href={ id }/>
<fpml:tradeId tradeIdScheme={ get(s \ "tradeId", "tradeIdScheme") }>{ get(s \ "tradeId") }</fpml:tradeId>
</fpml:partyTradeIdentifier>
}
}
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") }/>
<fpml:relatedParty>
<fpml:partyReference href={ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") } />
<fpml:role>ClearingOrganization</fpml:role>
</fpml:relatedParty>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-type">{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementType") }</fpml:category>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-method">{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementMethod") }</fpml:category>
<fpml:executionDateTime>{ get(source \ "trade" \ "tradeHeader" \ "tradeDate") + "T00:00:00" }</fpml:executionDateTime>
<fpml:reportingRegime>
<fpml:name>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "reportingRegime" \ "name") }</fpml:name>
<fpml:mandatorilyClearable>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "cleared").mkString.contains("Y")) "true" else msgNotFound }</fpml:mandatorilyClearable>
</fpml:reportingRegime>
</fpml:partyTradeInformation>
{ for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(s \ "servicingParty", "href") } />
<fpml:relatedParty>
<fpml:partyReference href={ get(s \ "id") } />
<fpml:role>{ if (get(s \ "id").mkString != msgNotFound) "Client" else msgNotFound}</fpml:role>
<fpml:type>{ get(s \ "type") }</fpml:type>
</fpml:relatedParty>
<fpml:timestamps>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate").mkString != msgNotFound) "InClearingPool" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate").mkString != msgNotFound) "InPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate").mkString != msgNotFound) "OutPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
</fpml:timestamps>
<fpml:collateralizationType>{
get(source \ "trade" \ "collateral" \ "marginType").mkString match {
case "FC" => "Fully"
case "PC" => "Partially"
case "OC" => "OneWay"
case "U" => "Uncollateralized"
case _ => msgNotFound
}
}</fpml:collateralizationType>
<fpml:collateralPortfolio>{ get(source \ "trade" \ "collateral" \ "collateralForm") }</fpml:collateralPortfolio>
</fpml:partyTradeInformation>
}
}
</fpml:tradeHeader>
{ templateTradeBody }
<fpml:documentation>
<fpml:masterAgreement>
<fpml:masterAgreementId>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier" \ "linkId") }</fpml:masterAgreementId>
</fpml:masterAgreement>
</fpml:documentation>
</fpml:trade>
{ for { s <- source \ "party"
id = get(s, "id").mkString
<fpml:nonpublicExecutionReport xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
xmlns:fpmlext="http://www.fpml.org/FpML-5/ext" xmlns:rtsrep="http://www.fpml.ru/repository"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fpmlVersion="5-7">
<fpml:header>
<fpml:messageId>{ get(source \ "header" \"messageId") }</fpml:messageId>
<fpml:sentBy>{ get(source \ "header" \ "sentBy") }</fpml:sentBy>
<fpml:sendTo>{ get(source \ "header" \ "sendTo") }</fpml:sendTo>
<fpml:creationTimestamp>{ get(source \ "header" \ "creationTimestamp") }</fpml:creationTimestamp>
<fpml:implementationSpecification>
<fpml:version>2</fpml:version>
</fpml:implementationSpecification>
</fpml:header>
<fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection>
<fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId>
<fpml:trade>
<fpml:tradeHeader>
{ for { s <- source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier"
id = get(s \ "partyReference", "href").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:party id={ id }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
<fpml:partyName>{ get(s \ "partyName") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
<fpml:partyTradeIdentifier>
<fpml:partyReference href={ id }/>
<fpml:tradeId tradeIdScheme={ get(s \ "tradeId", "tradeIdScheme") }>{ get(s \ "tradeId") }</fpml:tradeId>
</fpml:partyTradeIdentifier>
}
}
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") }/>
<fpml:relatedParty>
<fpml:partyReference href={ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") } />
<fpml:role>ClearingOrganization</fpml:role>
</fpml:relatedParty>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-type">{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementType") }</fpml:category>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-method">{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementMethod") }</fpml:category>
<fpml:executionDateTime>{ get(source \ "trade" \ "tradeHeader" \ "tradeDate") + "T00:00:00" }</fpml:executionDateTime>
<fpml:reportingRegime>
<fpml:name>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "reportingRegime" \ "name") }</fpml:name>
<fpml:mandatorilyClearable>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "cleared").mkString.contains("Y")) "true" else msgNotFound }</fpml:mandatorilyClearable>
</fpml:reportingRegime>
</fpml:partyTradeInformation>
{ for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:party id={ get(s \ "id") }>
<fpml:partyId>{ get(s \ "id") }</fpml:partyId>
<fpml:partyName>{ get(s \ "name") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(s \ "servicingParty", "href") } />
<fpml:relatedParty>
<fpml:partyReference href={ get(s \ "id") } />
<fpml:role>{ if (get(s \ "id").mkString != msgNotFound) "Client" else msgNotFound}</fpml:role>
<fpml:type>{ get(s \ "type") }</fpml:type>
</fpml:relatedParty>
<fpml:timestamps>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate").mkString != msgNotFound) "InClearingPool" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate").mkString != msgNotFound) "InPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate").mkString != msgNotFound) "OutPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value>
</fpml:timestamp>
</fpml:timestamps>
<fpml:collateralizationType>{
get(source \ "trade" \ "collateral" \ "marginType").mkString match {
case "FC" => "Fully"
case "PC" => "Partially"
case "OC" => "OneWay"
case "U" => "Uncollateralized"
case _ => msgNotFound
}
}</fpml:collateralizationType>
<fpml:collateralPortfolio>{ get(source \ "trade" \ "collateral" \ "collateralForm") }</fpml:collateralPortfolio>
</fpml:partyTradeInformation>
}
}
</fpml:nonpublicExecutionReport>
</document>
</signedDocument>
</fpml:tradeHeader>
{ templateTradeBody }
<fpml:documentation>
<fpml:masterAgreement>
<fpml:masterAgreementId>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier" \ "linkId") }</fpml:masterAgreementId>
</fpml:masterAgreement>
</fpml:documentation>
</fpml:trade>
{ for { s <- source \ "party"
id = get(s, "id").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:party id={ id }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
<fpml:partyName>{ get(s \ "partyName") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
{ for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:party id={ get(s \ "id") }>
<fpml:partyId>{ get(s \ "id") }</fpml:partyId>
<fpml:partyName>{ get(s \ "name") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
</fpml:nonpublicExecutionReport>
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment