Examples of FXForwardSecurity


Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    ExternalId region = externalIdBeanToExternalId(bean.getRegion());
    Currency payCurrency = currencyBeanToCurrency(bean.getPayCurrency());
    double payAmount = bean.getPayAmount();
    Currency receiveCurrency = currencyBeanToCurrency(bean.getReceiveCurrency());
    double receiveAmount = bean.getReceiveAmount();
    return new FXForwardSecurity(payCurrency, payAmount, receiveCurrency, receiveAmount, forwardDate, region);
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

   */
  @Test
  public void fxForward() throws JSONException {
    ZonedDateTime forwardDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ExternalId regionId = ExternalId.of(ExternalSchemes.FINANCIAL, "GB");
    FXForwardSecurity fxForward = new FXForwardSecurity(Currency.USD, 150, Currency.GBP, 100, forwardDate, regionId);
    fxForward.setName("GBP/USD forward");

    JsonDataSink sink = new JsonDataSink(BlotterUtils.getJsonBuildingConverters());
    BeanVisitor<JSONObject> writingVisitor = new BuildingBeanVisitor<>(fxForward, sink);
    BeanTraverser traverser = new BeanTraverser(s_propertyFilter);
    JSONObject json = (JSONObject) traverser.traverse(FXForwardSecurity.meta(), writingVisitor);
    assertNotNull(json);
//    System.out.println(json);

    JsonBeanDataSource dataSource = new JsonBeanDataSource(new JSONObject(json.toString()));
    MetaBeanFactory metaBeanFactory = new MapMetaBeanFactory(ImmutableSet.<MetaBean>of(FXForwardSecurity.meta()));
    BeanVisitor<BeanBuilder<Bean>> readingVisitor =
        new BeanBuildingVisitor<>(dataSource, metaBeanFactory, BlotterUtils.getBeanBuildingConverters());
    BeanBuilder<FXForwardSecurity> beanBuilder =
        (BeanBuilder<FXForwardSecurity>) traverser.traverse(FXForwardSecurity.meta(), readingVisitor);
    FXForwardSecurity fxForward2 = beanBuilder.build();
    assertEquals(fxForward, fxForward2);
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    }
    final double callAmount = NOTIONAL * fxRate;
    final Currency payCurrency = bundle._long ? bundle._secondCurrency : bundle._firstCurrency;
    final Currency receiveCurrency = bundle._long ? bundle._firstCurrency : bundle._secondCurrency;
    final String dateString = forwardDate.toString(DATE_FORMATTER);
    final FXForwardSecurity fxForwardSecurity = new FXForwardSecurity(payCurrency, callAmount, receiveCurrency, putAmount, forwardDate, REGION);
    final String callAmountString = NOTIONAL_FORMATTER.format(callAmount);
    final String putAmountString = NOTIONAL_FORMATTER.format(putAmount);
    fxForwardSecurity.setName("Pay " + payCurrency + " " + callAmountString + ", receive " + receiveCurrency + " " + putAmountString + " on " + dateString);
    return fxForwardSecurity;
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    trade.setPremiumCurrency(security.getCallCurrency());
    return trade;
  }

  protected ManageableTrade createFXForwardSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final FXForwardSecurity security = createFXForwardSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getPayAmount());
    trade.setPremiumCurrency(security.getPayCurrency());
    return trade;
   
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    assertEquals(LocalDate.of(2012, 12, 22), updatedTrade.getTradeDate());
    assertEquals(4321d, updatedTrade.getPremium());
    PositionDocument positionDocument = _positionMaster.get(updatedTrade.getParentPositionId());
    ManageablePosition updatedPosition = positionDocument.getPosition();
    assertEquals(updatedTrade, updatedPosition.getTrade(updatedTradeId));
    FXForwardSecurity updatedSecurity = (FXForwardSecurity) _securityMaster.get(updatedTrade.getSecurityLink().getObjectId(),
                                                                                VersionCorrection.LATEST).getSecurity();
    assertEquals(Currency.AUD, updatedSecurity.getPayCurrency());
    assertEquals(200d, updatedSecurity.getPayAmount());
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    assertEquals(1, loadedPosition.getTrades().size());
    ManageableTrade trade = loadedPosition.getTrades().get(0);
    assertEquals("updatedCounterparty", trade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), trade.getTradeDate());
    assertEquals(4321d, trade.getPremium());
    FXForwardSecurity updatedSecurity = (FXForwardSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                                                VersionCorrection.LATEST).getSecurity();
    assertEquals(Currency.AUD, updatedSecurity.getPayCurrency());
    assertEquals(200d, updatedSecurity.getPayAmount());
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

  @Test
  public void otherSecurityType() {
    SecurityMaster securityMaster = mock(SecurityMaster.class);
    ExternalIdVisitor visitor = new ExternalIdVisitor(securityMaster);
    FXForwardSecurity security = new FXForwardSecurity(Currency.GBP, 123, Currency.AUD, 321, ZonedDateTime.now(),
                                                       ExternalId.of("reg", "123"));
    security.accept(visitor);
    assertTrue(security.getExternalIdBundle().isEmpty());
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

  private Collection<FXForwardSecurity> createRandomFXForwards() {
    fetch(CCYS);
    final Collection<FXForwardSecurity> fxForwards = new ArrayList<>();
    final Random random = new Random(1235);
    for (int i = 0; i < SIZE; i++) {
      FXForwardSecurity fxForward = null;
      try {
        final UnorderedCurrencyPair ccys = CCYS[random.nextInt(CCYS.length)];
        final LocalDate tradeDate = getTradeDate(random, ccys.getFirstCurrency());
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        fxForward = makeFXForward(random, ccys, tradeDate, tenor);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (fxForward != null) {
        fxForwards.add(fxForward);
      }
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Parsed ").append(fxForwards.size()).append(" FX forwards:\n");
    for (final FXForwardSecurity fxForward : fxForwards) {
      sb.append("\t").append(fxForward.getName()).append("\n");
    }
    s_logger.info(sb.toString());
    return fxForwards;
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    sb.append(payCurrency);
    sb.append("/");
    sb.append(receiveCurrency);
    sb.append(" @ ");
    sb.append(FORMATTER.format(forwardRate));
    final FXForwardSecurity fxForward = new FXForwardSecurity(payCurrency, payAmount, receiveCurrency, receiveAmount, forwardDate, REGION);
    fxForward.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    fxForward.setName(sb.toString());
    return fxForward;
  }
View Full Code Here

Examples of com.opengamma.financial.security.fx.FXForwardSecurity

    /*
    0 root
    1  |_pos/trade1
    2  |_pos/trade2
    */
    FXForwardSecurity security = new FXForwardSecurity(Currency.GBP, 123,
                                                       Currency.USD, 321,
                                                       LocalDate.of(2012, 12, 21).atTime(11, 0).atZone(ZoneOffset.UTC),
                                                       ExternalId.of("Reg", "ABC"));
    SimplePortfolioNode portfolioRoot = new SimplePortfolioNode();
    SimplePosition position1 = new SimplePosition();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.