Examples of FinancialSecuritySource


Examples of com.opengamma.financial.security.FinancialSecuritySource

  }

  //-------------------------------------------------------------------------
  @Override
  protected FinancialSecuritySource createObject() {
    FinancialSecuritySource source = new MasterFinancialSecuritySource(getSecurityMaster());
    if (getCacheManager() != null) {
      source = new EHCachingFinancialSecuritySource(source, getCacheManager());
    }
    return source;
  }
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

  private SecurityMaster _userSecurityMaster;

  //-------------------------------------------------------------------------
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) {
    FinancialSecuritySource source = initUnderlying(repo, configuration);
   
    // add user level if requested
    FinancialSecuritySource userSource = initUser(repo, configuration);
    Map<String, FinancialSecuritySource> map = new HashMap<String, FinancialSecuritySource>();
    if (userSource != null) {
      String scheme = repo.getInfo(getUserSecurityMaster()).getAttribute(ComponentInfoAttributes.UNIQUE_ID_SCHEME);
      map.put(scheme, userSource);
      source = new DelegatingFinancialSecuritySource(source, map);
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

      repo.getRestComponents().publish(info, new DataFinancialSecuritySourceResource(source));
    }
  }

  protected FinancialSecuritySource initUnderlying(ComponentRepository repo, LinkedHashMap<String, String> configuration) {
    FinancialSecuritySource source = new MasterFinancialSecuritySource(getUnderlyingSecurityMaster());
   
    // REVIEW kirk 2013-04-19 -- The block below should only be enabled when developing
    // the RedisCachingFinancialSecuritySource.
    /*JedisPool jedisPool = new JedisPool("localhost");
    source = new RedisCachingFinancialSecuritySource(source, jedisPool, "", OpenGammaFudgeContext.getInstance());*/
 
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

  protected FinancialSecuritySource initUser(ComponentRepository repo, LinkedHashMap<String, String> configuration) {
    if (getUserSecurityMaster() == null) {
      return null;
    }
    FinancialSecuritySource source = new MasterFinancialSecuritySource(getUserSecurityMaster());
    if (getUserClassifier() != null) {
      ComponentInfo info = new ComponentInfo(SecuritySource.class, getUserClassifier());
      info.addAttribute(ComponentInfoAttributes.LEVEL, 1);
      info.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteFinancialSecuritySource.class);
      repo.registerComponent(info, source);
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

   * @param repo  the component repository, not null
   * @param configuration  the remaining configuration, not null
   */
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) {
    FinancialSecuritySource source = createFinancialSecuritySource(repo);
   
    ComponentInfo info = new ComponentInfo(SecuritySource.class, getClassifier());
    info.addAttribute(ComponentInfoAttributes.LEVEL, 1);
    info.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteFinancialSecuritySource.class);
    repo.registerComponent(info, source);
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

   *
   * @param repo  the component repository, only used to register secondary items like lifecycle, not null
   * @return the financial security source, not null
   */
  protected FinancialSecuritySource createFinancialSecuritySource(ComponentRepository repo) {
    FinancialSecuritySource source = new MasterFinancialSecuritySource(getSecurityMaster());
    if (getCacheManager() != null) {
      source = new EHCachingFinancialSecuritySource(source, getCacheManager());
    }
    return source;
  }
View Full Code Here

Examples of com.opengamma.financial.security.FinancialSecuritySource

        final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(executionContext);
        final RegionSource regionSource = OpenGammaExecutionContext.getRegionSource(executionContext);
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final BondSecurityConverter converter = new BondSecurityConverter(holidaySource, conventionSource, regionSource);
        final FinancialSecuritySource securitySource = executionContext.getSecuritySource(FinancialSecuritySource.class);
        final Collection<Security> allBonds = new ArrayList<Security>(securitySource.getBondsWithIssuerName(ISSUER_NAME));
        final Iterator<Security> iter = allBonds.iterator();
        while (iter.hasNext()) {
          final Security sec = iter.next();
          if (sec instanceof BondSecurity) {
            final BondSecurity bond = (BondSecurity) sec;
            if (bond.getLastTradeDate().getExpiry().isBefore(now)) {
              iter.remove();
            }
            s_logger.info(bond.getLastTradeDate().toString());
          } else {
            throw new OpenGammaRuntimeException("non-bond security " + sec + " returned by getAllBondsOfIssuerType()");
          }
        }
        final int n = allBonds.size();
        final double[] t = new double[n];
        final double[] ytm = new double[n];
        int i = 0;
        for (final Security security : allBonds) {
          final GovernmentBondSecurity bondSec = (GovernmentBondSecurity) security;
          final Object ytmObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.YTM, ComputationTargetType.SECURITY, security.getUniqueId()));
          if (ytmObject == null) {
            s_logger.warn("Could not get YTM for " + security.getUniqueId());
            continue;
          }
          if (!(ytmObject instanceof Double)) {
            throw new IllegalArgumentException("YTM should be a double");
          }
          final InstrumentDefinition<?> definition = converter.visitGovernmentBondSecurity(bondSec);
          final String bondStringName = PROPERTY_PREFIX + "_" + CURRENCY.getCode();
          final InstrumentDerivative bond = definition.toDerivative(now, bondStringName);
          t[i] = bond.accept(LAST_DATE);
          ytm[i++] = ((Double) ytmObject / 100);
        }
        final DoubleMatrix1D initialValues = new DoubleMatrix1D(new double[] {1, 2, 3, 4, 2, 3 });
        final ParameterizedFunction<Double, DoubleMatrix1D, Double> parameterizedFunction = MODEL.getParameterizedFunction();
        final LeastSquareResults result = MINIMISER.solve(new DoubleMatrix1D(t), new DoubleMatrix1D(ytm), parameterizedFunction, initialValues);
        final DoubleMatrix1D parameters = result.getFitParameters();
        final FunctionalDoublesCurve curve = FunctionalDoublesCurve.from(parameterizedFunction.asFunctionOfArguments(parameters));
        final YieldCurve yieldCurve = YieldCurve.from(curve);
        return Sets.newHashSet(new ComputedValue(_result, yieldCurve));
      }

      @Override
      public ComputationTargetType getTargetType() {
        return ComputationTargetType.CURRENCY;
      }

      @SuppressWarnings("synthetic-access")
      @Override
      public boolean canApplyTo(final FunctionCompilationContext context, final ComputationTarget target) {
        return CURRENCY.equals(target.getValue());
      }

      @SuppressWarnings("synthetic-access")
      @Override
      public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
        if (canApplyTo(context, target)) {
          final FinancialSecuritySource securitySource = context.getSecuritySource(FinancialSecuritySource.class);
          final Collection<Security> allBonds = new ArrayList<Security>(securitySource.getBondsWithIssuerName("US TREASURY N/B"));
          final Iterator<Security> iter = allBonds.iterator();
          while (iter.hasNext()) {
            final Security sec = iter.next();
            if (sec instanceof BondSecurity) {
              final BondSecurity bond = (BondSecurity) sec;
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.