Package com.opengamma.financial.convention

Examples of com.opengamma.financial.convention.ConventionBundleSource


  @Override
  public void init(final FunctionCompilationContext context) {
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final InterestRateFutureSecurityConverterDeprecated irFutureConverter = new InterestRateFutureSecurityConverterDeprecated(holidaySource, conventionSource, regionSource);
    final BondSecurityConverter bondConverter = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
    final BondFutureSecurityConverter bondFutureConverter = new BondFutureSecurityConverter(securitySource, bondConverter);
    final FutureSecurityConverterDeprecated futureSecurityConverter = new FutureSecurityConverterDeprecated(irFutureConverter, bondFutureConverter);
View Full Code Here


  @Override
  public void init(final FunctionCompilationContext context) {
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final HistoricalTimeSeriesResolver timeSeriesResolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    _converter = new InterestRateFutureOptionTradeConverterDeprecated(
        new InterestRateFutureOptionSecurityConverterDeprecated(holidaySource, conventionSource, regionSource, securitySource));
    _dataConverter = new FixedIncomeConverterDataProvider(conventionSource, timeSeriesResolver);
View Full Code Here

  @Override
  public void init(final FunctionCompilationContext context) {
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final HistoricalTimeSeriesResolver timeSeriesResolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    _converter = new InterestRateFutureTradeConverter(new InterestRateFutureSecurityConverterDeprecated(holidaySource, conventionSource, regionSource));
    _dataConverter = new FixedIncomeConverterDataProvider(conventionSource, timeSeriesResolver);
    ConfigDBCurveCalculationConfigSource.reinitOnChanges(context, this);
  }
View Full Code Here

  @Override
  protected TradeConverter getTargetToDefinitionConverter(final FunctionCompilationContext context) {
    final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionBundleSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final ConventionSource conventionSource = OpenGammaCompilationContext.getConventionSource(context);
    final FXVanillaOptionConverter fxOptionConverter = new FXVanillaOptionConverter(getCurrencyPairs(context));
    final FinancialSecurityVisitor<InstrumentDefinition<?>> securityConverter = FinancialSecurityVisitorAdapter.<InstrumentDefinition<?>>builder()
        .fxOptionVisitor(fxOptionConverter)
        .create();
View Full Code Here

  @Override
  public void init(final FunctionCompilationContext context) {
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final HistoricalTimeSeriesResolver timeSeriesResolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    _converter = new InterestRateFutureOptionTradeConverterDeprecated(
        new InterestRateFutureOptionSecurityConverterDeprecated(holidaySource, conventionSource, regionSource, securitySource));
    _dataConverter = new FixedIncomeConverterDataProvider(conventionSource, timeSeriesResolver);
View Full Code Here

  @Override
  public void init(final FunctionCompilationContext context) {
    final HolidaySource holidaySource = OpenGammaCompilationContext.getHolidaySource(context);
    final RegionSource regionSource = OpenGammaCompilationContext.getRegionSource(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final HistoricalTimeSeriesResolver timeSeriesResolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    _securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final SwapSecurityConverterDeprecated swapConverter = new SwapSecurityConverterDeprecated(holidaySource, conventionSource, regionSource, false);
    final SwaptionSecurityConverterDeprecated swaptionConverter = new SwaptionSecurityConverterDeprecated(_securitySource, swapConverter);
    final CapFloorSecurityConverterDeprecated capFloorVisitor = new CapFloorSecurityConverterDeprecated(holidaySource, conventionSource, regionSource);
View Full Code Here

    ConfigDBCurveCalculationConfigSource.reinitOnChanges(context, this);
  }

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(executionContext);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final Clock snapshotClock = executionContext.getValuationClock();
    final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
    final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final InstrumentDefinition<?> definition = security.accept(getVisitor());
    final Currency currency = FinancialSecurityUtils.getCurrency(security);
    final String conventionName = currency.getCode() + "_SWAP";
    final ConventionBundle convention = conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, conventionName));
    if (convention == null) {
      throw new OpenGammaRuntimeException("Could not get convention named " + conventionName);
    }
    final DayCount dayCount = convention.getSwapFloatingLegDayCount();
    if (dayCount == null) {
View Full Code Here

    return bundle;
  }

  public void testGetByIdentifier() {
    ConventionBundle bundle = createBundle();
    final ConventionBundleSource underlying = Mockito.mock(ConventionBundleSource.class);
    Mockito.when(underlying.getConventionBundle(ExternalId.of("Test", "Foo"))).thenReturn(bundle);
    Mockito.when(underlying.getConventionBundle(ExternalId.of("Test", "Bar"))).thenReturn(null);
    final DataConventionBundleSourceResource server = new DataConventionBundleSourceResource(underlying);
    final ConventionBundleSource client = new RemoteConventionBundleSource(URI.create("http://localhost/")) {
      @Override
      protected UniformInterface accessRemote(final URI uri) {
        assertTrue(uri.getPath().startsWith("/identifier/"));
        final UniformInterface builder = Mockito.mock(UniformInterface.class);
        Mockito.when(builder.get(ConventionBundle.class)).thenAnswer(new Answer<ConventionBundle>() {
          @Override
          public ConventionBundle answer(final InvocationOnMock invocation) throws Throwable {
            try {
              return OpenGammaFudgeContext.getInstance().fromFudgeMsg(ConventionBundle.class, (FudgeMsg) server.getByIdentifier(uri.getPath().substring(12)).getEntity());
            } catch (final WebApplicationException e) {
              assertEquals(e.getResponse().getStatus(), 404);
              throw new UniformInterfaceException404NotFound(new ClientResponse(404, null, null, null), false);
            }
          }
        });
        return builder;
      }
    };
    bundle = client.getConventionBundle(ExternalId.of("Test", "Foo"));
    assertNotNull(bundle);
    assertEquals(bundle.getUniqueId(), UniqueId.of("Mock", "0"));
    bundle = client.getConventionBundle(ExternalId.of("Test", "Bar"));
    assertNull(bundle);
  }
View Full Code Here

    assertNull(bundle);
  }

  public void testGetByBundle() {
    ConventionBundle bundle = createBundle();
    final ConventionBundleSource underlying = Mockito.mock(ConventionBundleSource.class);
    Mockito.when(underlying.getConventionBundle(ExternalId.of("Test", "Foo").toBundle())).thenReturn(bundle);
    Mockito.when(underlying.getConventionBundle(ExternalId.of("Test", "Bar").toBundle())).thenReturn(null);
    final DataConventionBundleSourceResource server = new DataConventionBundleSourceResource(underlying);
    final ConventionBundleSource client = new RemoteConventionBundleSource(URI.create("http://localhost/")) {
      @Override
      protected UniformInterface accessRemote(final URI uri) {
        assertTrue(uri.getPath().startsWith("/bundle"));
        assertTrue(uri.getQuery().startsWith("id="));
        final UniformInterface builder = Mockito.mock(UniformInterface.class);
        Mockito.when(builder.get(ConventionBundle.class)).thenAnswer(new Answer<ConventionBundle>() {
          @Override
          public ConventionBundle answer(final InvocationOnMock invocation) throws Throwable {
            try {
              return OpenGammaFudgeContext.getInstance().fromFudgeMsg(ConventionBundle.class, (FudgeMsg) server.getByBundle(Arrays.asList(uri.getQuery().substring(3))).getEntity());
            } catch (final WebApplicationException e) {
              assertEquals(e.getResponse().getStatus(), 404);
              throw new UniformInterfaceException404NotFound(new ClientResponse(404, null, null, null), false);
            }
          }
        });
        return builder;
      }
    };
    bundle = client.getConventionBundle(ExternalId.of("Test", "Foo").toBundle());
    assertNotNull(bundle);
    assertEquals(bundle.getUniqueId(), UniqueId.of("Mock", "0"));
    bundle = client.getConventionBundle(ExternalId.of("Test", "Bar").toBundle());
    assertNull(bundle);
  }
View Full Code Here

    assertNull(bundle);
  }

  public void testGetByUniqueId() {
    ConventionBundle bundle = createBundle();
    final ConventionBundleSource underlying = Mockito.mock(ConventionBundleSource.class);
    Mockito.when(underlying.getConventionBundle(UniqueId.of("Mock", "0"))).thenReturn(bundle);
    Mockito.when(underlying.getConventionBundle(UniqueId.of("Mock", "1"))).thenReturn(null);
    final DataConventionBundleSourceResource server = new DataConventionBundleSourceResource(underlying);
    final ConventionBundleSource client = new RemoteConventionBundleSource(URI.create("http://localhost/")) {
      @Override
      protected UniformInterface accessRemote(final URI uri) {
        assertTrue(uri.getPath().startsWith("/unique/"));
        final UniformInterface builder = Mockito.mock(UniformInterface.class);
        Mockito.when(builder.get(ConventionBundle.class)).thenAnswer(new Answer<ConventionBundle>() {
          @Override
          public ConventionBundle answer(final InvocationOnMock invocation) throws Throwable {
            try {
              return OpenGammaFudgeContext.getInstance().fromFudgeMsg(ConventionBundle.class, (FudgeMsg) server.getByUniqueId(uri.getPath().substring(8)).getEntity());
            } catch (final WebApplicationException e) {
              assertEquals(e.getResponse().getStatus(), 404);
              throw new UniformInterfaceException404NotFound(new ClientResponse(404, null, null, null), false);
            }
          }
        });
        return builder;
      }
    };
    bundle = client.getConventionBundle(UniqueId.of("Mock", "0"));
    assertNotNull(bundle);
    assertEquals(bundle.getUniqueId(), UniqueId.of("Mock", "0"));
    bundle = client.getConventionBundle(UniqueId.of("Mock", "1"));
    assertNull(bundle);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.convention.ConventionBundleSource

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.