Package com.opengamma.id

Examples of com.opengamma.id.UniqueId


  }

  @Test
  public void test_remove_101_removeRangeWithNullEnd() {
    ObjectId oid = ObjectId.of("DbHts", "DP101");
    UniqueId uniqueId = _htsMaster.removeTimeSeriesDataPoints(oid, LocalDate.of(2011, 1, 2), null);
   
    ManageableHistoricalTimeSeries testCorrected = _htsMaster.getTimeSeries(uniqueId);
    assertEquals(uniqueId, testCorrected.getUniqueId());
    LocalDateDoubleTimeSeries timeSeries = testCorrected.getTimeSeries();
    assertEquals(1, timeSeries.size());
View Full Code Here


    @Deprecated
    private static ValueRequirement plat3044Translate(final ValueRequirement valueRequirement) {
      if (valueRequirement.getTargetReference() instanceof ComputationTargetSpecification) {
        final ComputationTargetSpecification spec = valueRequirement.getTargetReference().getSpecification();
        if (spec.getType().equals(ComputationTargetType.PRIMITIVE)) {
          final UniqueId uid = spec.getUniqueId();
          if (ExternalSchemes.BLOOMBERG_TICKER.getName().equals(uid.getScheme())) {
            return new ValueRequirement(valueRequirement.getValueName(), new ComputationTargetRequirement(spec.getType(), ExternalId.of(ExternalSchemes.BLOOMBERG_TICKER, uid.getValue())),
                valueRequirement.getConstraints());
          }
        }
      }
      return valueRequirement;
View Full Code Here

   * For a specific bug
   */
  @Test
  public void formatHistoryForValueNameWithUnknownType() {
    ResultsFormatter formatter = new ResultsFormatter();
    UniqueId uid = UniqueId.of("scheme", "value");
    ComputationTargetSpecification spec = new ComputationTargetSpecification(ComputationTargetType.POSITION, uid);
    ValueProperties props = ValueProperties.builder().with(ValuePropertyNames.FUNCTION, "fn").get();
    // if this works without an exception then the bug is fixed
    formatter.format(123d, new ValueSpecification("unknown value name", spec, props), TypeFormatter.Format.HISTORY, null);
  }
View Full Code Here

    assertEquals(result, "123");
  }

  private ValueSpecification buildValueSpecificationWithCurrency(String valueName) {

    UniqueId uid = UniqueId.of("scheme", "value");
    ComputationTargetSpecification cts = new ComputationTargetSpecification(ComputationTargetType.POSITION, uid);

    ValueProperties props = ValueProperties.builder()
        .with(ValuePropertyNames.FUNCTION, "fn")
        .with(ValuePropertyNames.CURRENCY, "USD")
View Full Code Here

    _nodeId = _savedPortfolio.getRootNode().getChildNodes().get(0).getUniqueId();
  }

  @Test
  public void newSecurityWithNoUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(), BlotterTestUtils.FX_FORWARD_DATA_SOURCE, null, _nodeId);
    ManageableTrade trade = _positionMaster.getTrade(tradeId);
    UniqueId positionId = trade.getParentPositionId();
    ManageablePosition position = _positionMaster.get(positionId).getPosition();
    assertEquals(BigDecimal.ONE, trade.getQuantity());
    assertEquals(BigDecimal.ONE, position.getQuantity());
    ManageableSecurity security = _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                      VersionCorrection.LATEST).getSecurity();
    assertNotNull(security);
    security.setUniqueId(null); // so it can be tested for equality against the unsaved version
    assertEquals(BlotterTestUtils.FX_FORWARD, security);
    assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
    assertEquals(PREMIUM, trade.getPremium());
    assertEquals(Currency.GBP, trade.getPremiumCurrency());
    assertEquals(PREMIUM_DATE, trade.getPremiumDate());
    assertEquals(TRADE_DATE, trade.getTradeDate());
    assertEquals(PREMIUM_TIME, trade.getPremiumTime());
    assertEquals(TRADE_TIME, trade.getTradeTime());
    assertEquals(ATTRIBUTES, trade.getAttributes());

    // can't check the node ID as nodes are completely replaced
    ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio().getRootNode();
    ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0);
    assertEquals(1, loadedNode.getPositionIds().size());
    assertEquals(positionId.getObjectId(), loadedNode.getPositionIds().get(0));
  }
View Full Code Here

    assertEquals(positionId.getObjectId(), loadedNode.getPositionIds().get(0));
  }

  @Test
  public void existingSecurityWithNoUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(), BlotterTestUtils.FX_FORWARD_DATA_SOURCE, null, _nodeId);
    BeanDataSource updatedTradeData = createTradeData("uniqueId", tradeId.toString(),
                                                      "counterparty", "updatedCounterparty",
                                                      "tradeDate", "2012-12-22",
                                                      "premium", "4321");
    BeanDataSource updatedSecurityData = BlotterTestUtils.overrideBeanData(BlotterTestUtils.FX_FORWARD_DATA_SOURCE,
                                                                           "payCurrency", "AUD",
                                                                           "payAmount", "200");

    UniqueId updatedTradeId = _builder.updateTrade(updatedTradeData, updatedSecurityData, null);
    ManageableTrade updatedTrade = _positionMaster.getTrade(updatedTradeId);
    assertEquals("updatedCounterparty", updatedTrade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), updatedTrade.getTradeDate());
    assertEquals(4321d, updatedTrade.getPremium());
    PositionDocument positionDocument = _positionMaster.get(updatedTrade.getParentPositionId());
View Full Code Here

    assertEquals(200d, updatedSecurity.getPayAmount());
  }

  @Test
  public void newSecurityWithOtcUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(),
                                         BlotterTestUtils.SWAPTION_DATA_SOURCE,
                                         BlotterTestUtils.SWAP_DATA_SOURCE,
                                         _nodeId);
    ManageableTrade trade = _positionMaster.getTrade(tradeId);
    UniqueId positionId = trade.getParentPositionId();
    ManageablePosition position = _positionMaster.get(positionId).getPosition();
    assertEquals(BigDecimal.ONE, trade.getQuantity());
    assertEquals(BigDecimal.ONE, position.getQuantity());
    SwaptionSecurity security = (SwaptionSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                                       VersionCorrection.LATEST).getSecurity();
    assertNotNull(security);
    // check this later
    ExternalId underlyingId = security.getUnderlyingId();
    security.setUniqueId(null); // so it can be tested for equality against the unsaved version
    security.setUnderlyingId(BlotterTestUtils.SWAPTION.getUnderlyingId()); // will need this later
    assertEquals(BlotterTestUtils.SWAPTION, security);
    assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
    assertEquals(PREMIUM, trade.getPremium());
    assertEquals(Currency.GBP, trade.getPremiumCurrency());
    assertEquals(PREMIUM_DATE, trade.getPremiumDate());
    assertEquals(TRADE_DATE, trade.getTradeDate());
    assertEquals(PREMIUM_TIME, trade.getPremiumTime());
    assertEquals(TRADE_TIME, trade.getTradeTime());
    assertEquals(ATTRIBUTES, trade.getAttributes());

    // can't check the node ID as nodes are completely replaced
    ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio().getRootNode();
    ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0);
    assertEquals(1, loadedNode.getPositionIds().size());
    assertEquals(positionId.getObjectId(), loadedNode.getPositionIds().get(0));

    SecuritySearchRequest searchRequest = new SecuritySearchRequest();
    searchRequest.setExternalIdSearch(new ExternalIdSearch(underlyingId));
    SecuritySearchResult searchResult = _securityMaster.search(searchRequest);
    ManageableSecurity underlying = searchResult.getSingleSecurity();
View Full Code Here

    assertEquals(BlotterTestUtils.SWAP, underlying);
  }

  @Test
  public void existingSecurityWithOtcUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(),
                                         BlotterTestUtils.SWAPTION_DATA_SOURCE,
                                         BlotterTestUtils.SWAP_DATA_SOURCE,
                                         _nodeId);
    BeanDataSource updatedTradeData = createTradeData("uniqueId", tradeId.toString(),
                                                      "counterparty", "updatedCounterparty",
                                                      "tradeDate", "2012-12-22",
                                                      "premium", "4321");
    BeanDataSource updatedSecurityData = BlotterTestUtils.overrideBeanData(BlotterTestUtils.SWAPTION_DATA_SOURCE,
                                                                           "payer", "false",
                                                                           "longShort", "Long",
                                                                           "currency", "CAD");
    BeanDataSource updatedUnderlyingData = BlotterTestUtils.overrideBeanData(BlotterTestUtils.SWAP_DATA_SOURCE,
                                                                             "tradeDate", "2013-01-01",
                                                                             "eom", "false");

    UniqueId updatedTradeId = _builder.updateTrade(updatedTradeData, updatedSecurityData, updatedUnderlyingData);
    ManageableTrade updatedTrade = _positionMaster.getTrade(updatedTradeId);
    assertEquals("updatedCounterparty", updatedTrade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), updatedTrade.getTradeDate());
    assertEquals(4321d, updatedTrade.getPremium());
    PositionDocument positionDocument = _positionMaster.get(updatedTrade.getParentPositionId());
View Full Code Here

  }

  @Path("value/{valueName}/{targetType}/{targetId}")
  public DependencyGraphTraceProviderResource setValueRequirementByUniqueId(@PathParam("valueName") final String valueName, @PathParam("targetType") final String targetType,
      @PathParam("targetId") final String targetId) {
    UniqueId uniqueId = UniqueId.parse(targetId);
    ValueRequirement valueRequirement = toValueRequirement(valueName, new ComputationTargetSpecification(ComputationTargetType.parse(targetType), uniqueId));
    DependencyGraphTraceBuilderProperties properties = _properties.addRequirement(valueRequirement);
    return new DependencyGraphTraceProviderResource(_provider, _fudgeContext, properties);
  }
View Full Code Here

  private ManageableSecurity loadSecurity(final ExternalId ticker) {
    final ExternalIdBundle tickerBundle = ExternalIdBundle.of(ticker);
    final Collection<ExternalIdBundle> bundles = Collections.singleton(tickerBundle);
    final Map<ExternalIdBundle, UniqueId> loaded = getToolContext().getSecurityLoader().loadSecurities(bundles);
    final UniqueId loadedSec = loaded.get(tickerBundle);
    if (loadedSec == null) {
      throw new OpenGammaRuntimeException("Failed to load security for " + ticker);
    }
    return getToolContext().getSecurityMaster().get(loadedSec).getSecurity();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.id.UniqueId

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.