Package com.opengamma.financial.security

Examples of com.opengamma.financial.security.FinancialSecurity


    } else {
      FinancialSecurityVisitor<Double> visitorAdapter = FinancialSecurityVisitorAdapter.<Double>builder()
        .equitySecurityVisitor(_equitySecurityVisitor)
        .equityOptionVisitor(_equityOptionSecurityVisitor)
        .create();
      FinancialSecurity security = (FinancialSecurity) position.getSecurityLink().resolve(_secSource);
      Double currMarketCap = security.accept(visitorAdapter);
      String classification = getCurrentMarketCapCategory(currMarketCap);
      return classification == null ? NO_CUR_MKT_CAP : classification;
    }
  }
View Full Code Here


    public int compare(Position position1, Position position2) {
      FinancialSecurityVisitor<Double> visitorAdapter = FinancialSecurityVisitorAdapter.<Double>builder()
        .equitySecurityVisitor(_equitySecurityVisitor)
        .equityOptionVisitor(_equityOptionSecurityVisitor)
        .create();
      FinancialSecurity security1 = (FinancialSecurity) position1.getSecurityLink().resolve(_secSource);
      FinancialSecurity security2 = (FinancialSecurity) position2.getSecurityLink().resolve(_secSource);
      Double currMktCap1 = security1.accept(visitorAdapter);
      Double currMktCap2 = security2.accept(visitorAdapter);
      return CompareUtils.compareWithNullLow(currMktCap1, currMktCap2);
    }
View Full Code Here

  }

  private Collection<FinancialSecurity> createRandomSwaps(final Random random, final int n) {
    final Collection<FinancialSecurity> securities = new HashSet<>();
    for (int i = 0; i < n; i++) {
      FinancialSecurity security = null;
      try {
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        security = makeSwap(random, tenor);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (security != null) {
        securities.add(security);
      }
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Parsed ").append(securities.size()).append(" swaps:\n");
    for (final FinancialSecurity security : securities) {
      sb.append("\t").append(security.getName()).append("\n");
    }
    s_logger.info(sb.toString());
    return securities;
  }
View Full Code Here

  }

  private Collection<FinancialSecurity> createRandomCapFloors(final Random random, final int n) {
    final Collection<FinancialSecurity> securities = new HashSet<>();
    for (int i = 0; i < n; i++) {
      FinancialSecurity security = null;
      try {
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        security = makeCapFloor(random, tenor);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (security != null) {
        securities.add(security);
      }
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Parsed ").append(securities.size()).append(" cap/floors:\n");
    for (final FinancialSecurity security : securities) {
      sb.append("\t").append(security.getName()).append("\n");
    }
    s_logger.info(sb.toString());
    return securities;
  }
View Full Code Here

  }

  private Collection<FinancialSecurity> createRandomCapFloorCMSSpreads(final Random random, final int n) {
    final Collection<FinancialSecurity> securities = new HashSet<>();
    for (int i = 0; i < n; i++) {
      FinancialSecurity security = null;
      try {
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        final Tenor payTenor = PAY_TENORS[random.nextInt(PAY_TENORS.length)];
        final Tenor receiveTenor = RECEIVE_TENORS[random.nextInt(RECEIVE_TENORS.length)];
        security = makeCMSCapFloorSpread(random, payTenor, receiveTenor, tenor, i);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (security != null) {
        securities.add(security);
      }
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Parsed ").append(securities.size()).append(" CMS cap/floor spreads:\n");
    for (final FinancialSecurity security : securities) {
      sb.append("\t").append(security.getName()).append("\n");
    }
    s_logger.info(sb.toString());
    return securities;
  }
View Full Code Here

        return NA; //TODO
      }

    };
    if (position.getSecurity() instanceof FinancialSecurity) {
      final FinancialSecurity security = (FinancialSecurity) position.getSecurity();
      return security.accept(visitor);
    }
    return NA;
  }
View Full Code Here

  @Override
  public String classifyPosition(final Position position) {
    final Security security = position.getSecurity();
    if (security instanceof FinancialSecurity) {
      final FinancialSecurity finSec = (FinancialSecurity) security;

      return finSec.accept(new FinancialSecurityVisitorAdapter<String>() {
        @Override
        public String visitAgricultureFutureSecurity(final AgricultureFutureSecurity security) {
          return AGRICULTURAL_FUTURES;
        }
View Full Code Here

    _webSecuritiesResource.setUriInfo(_uriInfo);
   
  }

  private void addSecurity(FinancialSecurity security) {
    FinancialSecurity clone = JodaBeanUtils.clone(security);
    SecurityDocument secDoc = _secMaster.add(new SecurityDocument(security));
    List<FinancialSecurity> securities = _securities.get(clone.getClass());
    if (securities == null) {
      securities = Lists.newArrayList();
      _securities.put(clone.getClass(), securities);
    }
    securities.add((FinancialSecurity) secDoc.getSecurity());
  }
View Full Code Here

      }
    } else {
      position.getSecurityLink().resolve(_secSource);
      final FinancialSecurityVisitor<String> visitor = new Visitor(position);
      if (position.getSecurity() instanceof FinancialSecurity) {
        final FinancialSecurity finSec = (FinancialSecurity) position.getSecurity();
        return finSec.accept(visitor);
      }
      return NOT_LONG_SHORT;
    }
  }
View Full Code Here

        return security.getExpiry().getExpiry().toLocalDate().toString();
      }

    };
    if (position.getSecurity() instanceof FinancialSecurity) {
      final FinancialSecurity security = (FinancialSecurity) position.getSecurity();
      return security.accept(visitor);
    }
    return NA;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.security.FinancialSecurity

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.