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
}
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