Package com.opengamma.integration.tool.portfolio.xml.v1_0

Examples of com.opengamma.integration.tool.portfolio.xml.v1_0.SchemaGenerator


  private IdWrapper createExternalId(String id, String scheme) {
    ExtId tradeExtId = new ExtId();
    tradeExtId.setId(id);
    tradeExtId.setScheme(scheme);
    IdWrapper tradeId = new IdWrapper();
    tradeId.setExternalId(tradeExtId);
    return tradeId;
  }
View Full Code Here


  //-------------------------------------------------------------------------
  @Override
  public ManageableSecurity[] extractSecurities() {
    // Security extraction is handled by the listed security definition
    ListedSecurityDefinition listedSecurity = getTrade().getListedSecurityDefinition();
    return listedSecurity.getSecurityExtractor().extract();
  }
View Full Code Here

    manageableTrade.setProviderId(externalId);

    for (AdditionalCashflow cashflow : nullCheckIterable(trade.getAdditionalCashflows())) {

      if (cashflow.getCashflowType() == AdditionalCashflow.CashflowType.PREMIUM) {
        MonetaryAmount monetaryAmount = cashflow.getMonetaryAmount();
        manageableTrade.setPremium(monetaryAmount.getAmount().doubleValue());
        manageableTrade.setPremiumCurrency(monetaryAmount.getCurrency());
        manageableTrade.setPremiumDate(cashflow.getCashflowDate());
      }
    }

    manageableTrade.setAttributes(trade.getAdditionalAttributes());
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  protected ManageableSecurity createSecurity() {
    OptionSecurityDefinition defn = getSecurityDefinition();
    switch (defn.getListedOptionType()) {
      case EQUITY_DIVIDEND_OPTION:
        throw new PortfolioParsingException("EquityIndexDividendOption is not yet supported");
      case EQUITY_INDEX_OPTION:
        ExternalId underlyingId = defn.getUnderlyingId().toExternalId();
        ExerciseType exerciseType = defn.getExerciseType().convert();

        // We are only give month/year (e.g. MAR13) so arbitrarily use the first day of
        // the month but set the accuracy to reflect that
        Expiry expiry = new Expiry(defn.getOptionExpiry().atDay(1).atStartOfDay(ZoneOffset.UTC),
                                   ExpiryAccuracy.MONTH_YEAR);

        return new EquityIndexOptionSecurity(defn.getOptionType(),
                                             defn.getStrike().doubleValue(),
                                             defn.getCurrency(),
                                             underlyingId,
                                             exerciseType,
                                             expiry,
                                             defn.getPointValue(),
                                             defn.getExchange());
      default:
        // Should be prevented by XML parsing
        throw new PortfolioParsingException("Unrecognised listed option type: " + defn.getListedOptionType());
    }
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  public ManageableSecurity[] extractSecurities() {
    OtcEquityIndexOptionTrade trade = getTrade();
    EquityIndexOptionSecurity security = new EquityIndexOptionSecurity(
        trade.getOptionType(),
        trade.getStrike().doubleValue(),
        trade.getNotionalCurrency(),
        trade.getUnderlyingId().toExternalId(),
        trade.getExerciseType().convert(),
        new Expiry(convertLocalDate(trade.getExpiryDate())),
        1,
        "OTC");
    return securityArray(addIdentifier(security));
  }
View Full Code Here

   * @param portfolioDocument the portfolio document to create a dummy portfolio for
   * @return the dummy portfolio
   */
  private Portfolio createDummyPortfolio(PortfolioDocumentV1_0 portfolioDocument) {

    Portfolio pf = new Portfolio();

    // We leave the portfolio unnamed so a name can be provided from the command line

    // If we have trades with no positions, just add them to the dummy portfolio. If we have positions, just use them
    Set<Position> positions = portfolioDocument.getPositions();

    if (positions == null || positions.isEmpty()) {
      pf.setTrades(portfolioDocument.getTrades());
    } else {
      pf.setPositions(positions);
    }
    return pf;
  }
View Full Code Here

    return positionRef.getPosition();
  }

  @Override
  public PositionRef marshal(Position position) throws Exception {
    return new PositionRef(position);
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  public ManageableSecurity[] extractSecurities() {
    SwapTrade trade = getTrade();

    List<SwapLeg> payLegs = Lists.newArrayList(trade.getPayLegs());
    List<SwapLeg> recLegs = Lists.newArrayList(trade.getReceiveLegs());

    Preconditions.checkState(payLegs.size() == 1, format("Swaps must have one (and only one) pay leg. Found %d", payLegs.size()));
    Preconditions.checkState(recLegs.size() == 1, format("Swaps must have one (and only one) receive leg. Found %d", recLegs.size()));

    ManageableSecurity security = new SwapSecurity(
        convertLocalDate(trade.getTradeDate()),
        convertLocalDate(trade.getEffectiveDate()),
        convertLocalDate(trade.getMaturityDate()),
        trade.getCounterparty().getExternalId().getId(),
        convertLeg(payLegs.get(0)),
        convertLeg(recLegs.get(0)));

    return securityArray(addIdentifier(security));
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Override
  public ManageableSecurity[] extractSecurities() {
    SwaptionTrade trade = getTrade();
    SwapTrade swapTrade = trade.getUnderlyingSwapTrade();
    ManageableSecurity underlying = swapTrade.getSecurityExtractor().extractSecurities()[0];

    ExternalId underlyingId = underlying.getExternalIdBundle().getExternalId(ExternalScheme.of("XML_LOADER"));

    List<FixedLeg> fixedLegs = Lists.newArrayList(swapTrade.getFixedLegs());

    //note - these fields are resolved on a best effort basis
    //since they aren't actually used by the analytics.
    //see PLAT-1924
    Currency currency = null;
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  public ManageableSecurity[] extractSecurities() {
    SwaptionTrade trade = getTrade();
    SwapTrade swapTrade = trade.getUnderlyingSwapTrade();
    ManageableSecurity underlying = swapTrade.getSecurityExtractor().extractSecurities()[0];

    ExternalId underlyingId = underlying.getExternalIdBundle().getExternalId(ExternalScheme.of("XML_LOADER"));

    List<FixedLeg> fixedLegs = Lists.newArrayList(swapTrade.getFixedLegs());

    //note - these fields are resolved on a best effort basis
    //since they aren't actually used by the analytics.
    //see PLAT-1924
    Currency currency = null;
    boolean isPayer = false;

    if (!fixedLegs.isEmpty()) {
      currency = fixedLegs.get(0).getCurrency();
      isPayer = fixedLegs.get(0).getDirection() == Direction.PAY;
    }

    Expiry expiry = new Expiry(convertLocalDate(trade.getExpirationDate()));

    ManageableSecurity security = new SwaptionSecurity(
        isPayer, underlyingId, trade.getBuySell() == BuySell.BUY,
        expiry, trade.getSettlementType() == SettlementType.CASH_SETTLED,
        currency,
        null, trade.getExerciseType().convert(),
        convertLocalDate(trade.getCashSettlementPaymentDate()));

    return securityArray(addIdentifier(security), underlying);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.integration.tool.portfolio.xml.v1_0.SchemaGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.