public static Object getPropertyValue(final Object bean, final PropertyDescriptor descriptor) { notNull(bean); notNull(descriptor); final String name = descriptor.getName(); LOGGER.debug("{}.getPropertyValue({}, {})", bean.getClass().getName(), name); final Method method = descriptor.getReadMethod(); if (method == null) { throw new RuntimeException(format("No read method for property \"%s\"?", name)); } try { return method.invoke(bean); } catch (IllegalAccessException x) { LOGGER.error( String.format( "An exception was thrown while attempting to get property %s of an instance of %s.", name, bean.getClass()), x); throw new RuntimeException(x); } catch (IllegalArgumentException x) { LOGGER.error( String.format( "An exception was thrown while attempting to get property %s of an instance of %s.", name, bean.getClass()), x); throw new RuntimeException(x); } catch (InvocationTargetException x) { LOGGER.error( String.format( "An exception was thrown while attempting to get property %s of an instance of %s.", name, bean.getClass()), x); throw new RuntimeException(x); } }
/** * Creates the subcontext identified by the given <code>path</code> * * @param context * @param path slash separated hierarchy of sub contexts (e.g. /mdsp/brodcasterlistener/ * @throws NamingException */ public static Context createSubcontext(Context context, String path) throws NamingException { Validate.notNull(context, "context"); Validate.notNull(path, "path"); if (log.isDebugEnabled()) { log.debug( "> createSubcontext(context=" + context.getNameInNamespace() + ", path=" + path + ")"); } String[] subContextsNames = StringUtils.split(path, "/"); Context currentContext = context; for (String subContextName : subContextsNames) { try { currentContext = (Context) currentContext.lookup(subContextName); if (log.isDebugEnabled()) { log.debug("Context '" + subContextName + "' already exist"); } } catch (NameNotFoundException e) { currentContext = currentContext.createSubcontext(subContextName); if (log.isDebugEnabled()) { log.debug("Context '" + subContextName + "' created"); } } } if (log.isDebugEnabled()) { log.debug("< createSubcontext() : " + currentContext.getNameInNamespace()); } return currentContext; }
/** * Registers the given event to the specified listener using a directly passed EventExecutor * * @param event Event class to register * @param listener PlayerListener to register * @param priority Priority of this event * @param executor EventExecutor to register * @param plugin Plugin to register * @param ignoreCancelled Do not call executor if event was already cancelled */ public void registerEvent( Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) { Validate.notNull(listener, "Listener cannot be null"); Validate.notNull(priority, "Priority cannot be null"); Validate.notNull(executor, "Executor cannot be null"); Validate.notNull(plugin, "Plugin cannot be null"); if (!plugin.isEnabled()) { throw new IllegalPluginAccessException( "Plugin attempted to register " + event + " while not enabled"); } if (useTimings) { getEventListeners(event) .register( new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); } else { getEventListeners(event) .register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); } }
@Override public IPortletWindow getOrCreateDefaultPortletWindow( HttpServletRequest request, IPortletEntityId portletEntityId) { Validate.notNull(request, "request can not be null"); Validate.notNull(portletEntityId, "portletEntityId can not be null"); final IPortletWindowId portletWindowId = this.getDefaultPortletWindowId(request, portletEntityId); final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request); // Check if there is portlet window cached in the request IPortletWindow portletWindow = portletWindowMap.getWindow(portletWindowId); if (portletWindow != null) { logger.trace("Found IPortletWindow {} in request cache", portletWindow.getPortletWindowId()); return portletWindow; } final PortletWindowData portletWindowData = this.getOrCreateDefaultPortletWindowData(request, portletEntityId, portletWindowId); portletWindow = wrapPortletWindowData(request, portletWindowData); if (portletWindow == null) { return null; } // Cache the wrapped window in the request return portletWindowMap.storeIfAbsentWindow(portletWindow); }
@Override public Double visitBondFixedSecurity( final BondFixedSecurity bond, final YieldCurveBundle curves) { Validate.notNull(curves); Validate.notNull(bond); return METHOD_BOND.cleanPriceFromCurves(bond, curves); }
public <O extends ObjectType> O resolveObject(ObjectReferenceType ref) { Validate.notNull(ref.getOid(), "Object oid must not be null"); Validate.notNull(ref.getType(), "Object type must not be null"); Class type = prismContext.getSchemaRegistry().determineCompileTimeClass(ref.getType()); return resolveObject(type, ref.getOid()); }
/** * @param location the {@link Location} around which players must be to see the effect * @param effectName list of effects: https://gist.github.com/riking/5759002 * @param offsetX the amount to be randomly offset by in the X axis * @param offsetY the amount to be randomly offset by in the Y axis * @param offsetZ the amount to be randomly offset by in the Z axis * @param speed the speed of the particles * @param count the number of particles * @param radius the radius around the location */ public static void playParticleEffect( Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius) { Validate.notNull(location, "Location cannot be null"); Validate.notNull(effectName, "Effect cannot be null"); Validate.notNull(location.getWorld(), "World cannot be null"); PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles( effectName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); for (Player player : location.getWorld().getPlayers()) { if ((int) player.getLocation().distance(location) <= radius) { ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); } } }
/** * This calculates the sensitivity of the present value (PV) to a unit move in the forward. The * volatility surface remains unchanged. * * @param swap the VarianceSwap * @param market the VarianceSwapDataBundle * @param relShift Relative size of shift made in centered-finite difference approximation. * @return A Double. Currency amount per unit amount change in the black volatility */ @SuppressWarnings({}) public Double calcForwardSensitivity( final VarianceSwap swap, final VarianceSwapDataBundle market, final double relShift) { Validate.notNull(swap, "null VarianceSwap"); Validate.notNull(market, "null VarianceSwapDataBundle"); final VarianceSwapPresentValueCalculator pricer = VarianceSwapPresentValueCalculator.getInstance(); // Shift UP VarianceSwapDataBundle bumpedMarket = new VarianceSwapDataBundle( market.getVolatilitySurface(), market.getDiscountCurve(), market.getForwardCurve().withFractionalShift(relShift)); final double pvUp = pricer.visitVarianceSwap(swap, bumpedMarket); // Shift Down bumpedMarket = new VarianceSwapDataBundle( market.getVolatilitySurface(), market.getDiscountCurve(), market.getForwardCurve().withFractionalShift(-relShift)); final double pvDown = pricer.visitVarianceSwap(swap, bumpedMarket); final double t = swap.getTimeToSettlement(); final double fwd = market.getForwardCurve().getForward(t); // Centered-difference result return (pvUp - pvDown) / 2.0 / relShift / fwd; }
@Override public Double getValue(Double x, Double y, Double z) { Validate.notNull(x, "x"); Validate.notNull(y, "y"); Validate.notNull(z, "z"); return _interpolator.interpolate(_dataBundle, new double[] {x, y, z}); }
/** * This calculates the sensitivity of the present value (PV) to the lognormal Black implied * volatities at the knot points of the surface. * * <p>Note - the change of the surface due to the movement of a single node is * interpolator-dependent, so an instrument may have non-local sensitivity * * @param swap the VarianceSwap * @param market the VarianceSwapDataBundle * @param shift Size of shift made in centered-finite difference approximation. e.g. 1% would be * 0.01, and 1bp 0.0001 * @return A Double. Currency amount per unit amount change in the black volatility */ @SuppressWarnings({}) public Double calcBlackVegaParallel( final VarianceSwap swap, final VarianceSwapDataBundle market, final double shift) { Validate.notNull(swap, "null VarianceSwap"); Validate.notNull(market, "null VarianceSwapDataBundle"); final VarianceSwapPresentValueCalculator pricer = VarianceSwapPresentValueCalculator.getInstance(); // Parallel shift UP final BlackVolatilitySurface<?> upSurface = market.getVolatilitySurface().withShift(shift, true); final double pvUp = pricer.visitVarianceSwap( swap, new VarianceSwapDataBundle( upSurface, market.getDiscountCurve(), market.getForwardCurve())); // Parallel shift DOWN final BlackVolatilitySurface<?> downSurface = market.getVolatilitySurface().withShift(-shift, true); final double pvDown = pricer.visitVarianceSwap( swap, new VarianceSwapDataBundle( downSurface, market.getDiscountCurve(), market.getForwardCurve())); // Centered-difference result return (pvUp - pvDown) / (2.0 * shift); }
/** * This calculates the sensitivity of the present value (PV) to the lognormal Black implied * volatities at the knot points of the surface. * * <p>The return format is a DoubleMatrix2D with rows equal to the total number of maturities and * columns equal to the number of strikes. * * <p>Note - the change of the surface due to the movement of a single node is * interpolator-dependent, so an instrument may have non-local sensitivity * * @param swap the VarianceSwap * @param market the VarianceSwapDataBundle * @param shift Size of shift made in centered-finite difference approximation. e.g. 1% would be * 0.01, and 1bp 0.0001 * @return A NodalDoublesSurface with same axes as market.getVolatilitySurface(). Contains * currency amount per unit amount change in the black volatility of each node */ public NodalDoublesSurface calcBlackVegaForEntireSurface( final VarianceSwap swap, final VarianceSwapDataBundle market, final double shift) { Validate.notNull(swap, "null VarianceSwap"); Validate.notNull(market, "null VarianceSwapDataBundle"); // Unpack market data final Surface<Double, Double, Double> surface = market.getVolatilitySurface().getSurface(); Validate.isTrue( surface instanceof InterpolatedDoublesSurface, "Currently will only accept a Equity VolatilitySurfaces based on an InterpolatedDoublesSurface"); final InterpolatedDoublesSurface blackSurf = (InterpolatedDoublesSurface) surface; final Double[] maturities = blackSurf.getXData(); final Double[] strikes = blackSurf.getYData(); final int nNodes = maturities.length; Validate.isTrue(nNodes == strikes.length); // Bump and reprice final Double[] vegas = new Double[nNodes]; for (int j = 0; j < nNodes; j++) { vegas[j] = calcBlackVegaForSinglePoint(swap, market, maturities[j], strikes[j], shift); } return new NodalDoublesSurface(maturities, strikes, vegas); }
/** * This calculates the sensitivity of the present value (PV) to the continuously-compounded * discount rates at the knot points of the funding curve. * * <p>The return format is a DoubleMatrix1D (i.e. a vector) with length equal to the total number * of knots in the curve * * <p>The change of a curve due to the movement of a single knot is interpolator-dependent, so an * instrument can have sensitivity to knots at times beyond its maturity * * @param swap the VarianceSwap * @param market the VarianceSwapDataBundle * @return A DoubleMatrix1D containing bucketed delta in order and length of * market.getDiscountCurve(). Currency amount per unit amount change in discount rate */ public DoubleMatrix1D calcDeltaBucketed( final VarianceSwap swap, final VarianceSwapDataBundle market) { Validate.notNull(swap, "null VarianceSwap"); Validate.notNull(market, "null VarianceSwapDataBundle"); // We know that the VarianceSwap only has true sensitivity to one maturity on one curve. // A function written for interestRate sensitivities spreads this sensitivity across yield nodes // NodeSensitivityCalculator.curveToNodeSensitivities(curveSensitivities, interpolatedCurves) // 2nd arg = LinkedHashMap<String, YieldAndDiscountCurve> interpolatedCurves final YieldAndDiscountCurve discCrv = market.getDiscountCurve(); final String discCrvName = discCrv.getCurve().getName(); final YieldCurveBundle interpolatedCurves = new YieldCurveBundle(); interpolatedCurves.setCurve(discCrvName, discCrv); // 1st arg = Map<String, List<DoublesPair>> curveSensitivities = <curveName, // List<(maturity,sensitivity)>> final double settlement = swap.getTimeToSettlement(); final Double sens = calcDiscountRateSensitivity(swap, market); final Map<String, List<DoublesPair>> curveSensitivities = new HashMap<String, List<DoublesPair>>(); curveSensitivities.put(discCrvName, Lists.newArrayList(new DoublesPair(settlement, sens))); final NodeSensitivityCalculator distributor = PresentValueNodeSensitivityCalculator.getDefaultInstance(); return distributor.curveToNodeSensitivities(curveSensitivities, interpolatedCurves); }
/** * Constructor from all the details. * * @param currency The payment currency. * @param paymentTime Time (in years) up to the payment. * @param discountingCurveName Name of the funding curve. * @param paymentYearFraction The year fraction (or accrual factor) for the coupon payment. * @param notional Coupon notional. * @param fixingTime Time (in years) up to fixing. * @param index Ibor-like index on which the coupon fixes. The index currency should be the same * as the index currency. * @param fixingPeriodStartTime The fixing period start time (in years). * @param fixingPeriodEndTime The fixing period end time (in years). * @param fixingAccrualFactor The fixing period accrual factor (or year fraction) in the fixing * convention. * @param spread The spread paid above the Ibor rate. * @param factor The gearing (multiplicative) factor applied to the Ibor rate. * @param forwardCurveName The forward curve name used in to estimate the fixing index. */ public CouponIborGearing( Currency currency, double paymentTime, String discountingCurveName, double paymentYearFraction, double notional, double fixingTime, IborIndex index, double fixingPeriodStartTime, double fixingPeriodEndTime, double fixingAccrualFactor, double spread, double factor, String forwardCurveName) { super(currency, paymentTime, discountingCurveName, paymentYearFraction, notional, fixingTime); Validate.notNull(index, "Index"); Validate.notNull(forwardCurveName, "Forward curve"); Validate.isTrue(currency.equals(index.getCurrency())); this._index = index; this._fixingPeriodStartTime = fixingPeriodStartTime; this._fixingPeriodEndTime = fixingPeriodEndTime; this._fixingAccrualFactor = fixingAccrualFactor; this._spread = spread; this._factor = factor; this._forwardCurveName = forwardCurveName; _spreadAmount = getNotional() * getPaymentYearFraction() * spread; }
/** * @param entity * @param user * @return * @throws org.springframework.dao.DataAccessException */ public void update(I entity, QaUser user) { // sanity check // sanity check Validate.notNull(user, "User cannot be null"); Validate.notNull(entity, "Object cannot be null"); // session Session session = sessionFactory.getCurrentSession(); // prepare metadata QaMetadata metadata = ((QaMetaObject) entity).getMetadata(); if (null == metadata) { metadata = new QaMetadata(); metadata.setCreatedDate(new Timestamp(System.currentTimeMillis())); metadata.setCreator(user.getId()); metadata.setState(QaMetaState.ACTIVE); } metadata.setModifiedDate(new Timestamp(System.currentTimeMillis())); metadata.setModifier(user.getId()); ((QaMetaObject) entity).setMetadata(metadata); // update session.update(entity); }
/** * Constructor * * @param name The name for the parameter. May not be <code>null</code>. * @param type The type for the parameter. May not be <code>null</code>. */ public ParameterDefinition(String name, String type) { Validate.notNull(name); Validate.notNull(type); m_name = name; m_type = type; }
public InstrumentDefinition<?> convert(final Trade trade) { Validate.notNull(trade, "trade"); Validate.isTrue( trade.getSecurity() instanceof IRFutureOptionSecurity, "Can only handle trades with security type IRFutureOptionSecurity"); final Object securityDefinition = _securityConverter.convert((IRFutureOptionSecurity) trade.getSecurity()); final int quantity = 1; // trade.getQuantity().intValue(); TODO: correct when position/trade dilemma is solved. // TODO trade time or premium time? // final ZonedDateTime tradeDate = // ZonedDateTime.of(trade.getPremiumDate().atTime(trade.getPremiumTime()), // TimeZone.UTC); //TODO get the real time zone final ZonedDateTime tradeDate = ZonedDateTime.of( trade.getTradeDate().atTime(trade.getTradeTime()), TimeZone.UTC); // TODO get the real time zone final Double tradePrice = trade.getPremium(); Validate.notNull( tradePrice, "IRFutureOption trade must have a premium set. The interpretation of premium is the market price, without unit, i.e. not %"); // TODO: The premium is not the right place to store the trade price... if (securityDefinition instanceof InterestRateFutureOptionMarginSecurityDefinition) { final InterestRateFutureOptionMarginSecurityDefinition underlyingOption = (InterestRateFutureOptionMarginSecurityDefinition) securityDefinition; return new InterestRateFutureOptionMarginTransactionDefinition( underlyingOption, quantity, tradeDate, tradePrice); } final InterestRateFutureOptionPremiumSecurityDefinition underlyingOption = (InterestRateFutureOptionPremiumSecurityDefinition) securityDefinition; return new InterestRateFutureOptionPremiumTransactionDefinition( underlyingOption, quantity, tradeDate, tradePrice); }
/** * Constructs a new {@link TestHandler} and reads the tests from the specified URL resource. It * uses the web client to run the tests. * * @param theBrowser The web client in which the tests will run. It cannot be null. * @param theTestFile QUnit test file. It cannot be null. * @throws java.net.MalformedURLException If the file path cannot be parsed as a URL */ public TestHandler(final WebClient theBrowser, final URL theTestUrl) { Validate.notNull(theBrowser, "The web client cannot be null."); Validate.notNull(theTestUrl, "The test URL cannot be null."); browser = theBrowser; testUrl = theTestUrl; }
@Override public List<String> tabComplete(CommandSender sender, String alias, String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); if (args.length == 1) { return StringUtil.copyPartialMatches( args[0], WHITELIST_SUBCOMMANDS, new ArrayList<String>(WHITELIST_SUBCOMMANDS.size())); } else if (args.length == 2) { if (args[0].equalsIgnoreCase("add")) { List<String> completions = new ArrayList<String>(); for (OfflinePlayer player : Bukkit.getOfflinePlayers()) { String name = player.getName(); if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) { completions.add(name); } } return completions; } else if (args[0].equalsIgnoreCase("remove")) { List<String> completions = new ArrayList<String>(); for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { String name = player.getName(); if (StringUtil.startsWithIgnoreCase(name, args[1])) { completions.add(name); } } return completions; } } return ImmutableList.of(); }
/** Creates the InmutableURIAndCtx. */ public InmutableURIAndCtx(final URI uri, final Map<String, Object> ctx) { Validate.notNull(uri); Validate.notNull(ctx); this.uri = uri; this.ctx = Collections.unmodifiableMap(ctx); }
private ContainerWrapper( ObjectWrapper objectWrapper, T container, ContainerStatus status, ItemPath path, boolean createProperties, PageBase pageBase) { Validate.notNull(container, "container must not be null."); Validate.notNull(status, "Container status must not be null."); Validate.notNull(pageBase, "pageBase must not be null."); this.objectWrapper = objectWrapper; this.container = container; this.status = status; this.path = path; main = path == null; readonly = objectWrapper.isReadonly(); // [pm] this is quite questionable showInheritedObjectAttributes = objectWrapper.isShowInheritedObjectAttributes(); // have to be after setting "main" property containerDefinition = getItemDefinition(); if (createProperties) { // HACK HACK HACK, the container wrapper should not parse itself. This code should not be // here. // Constructor should NOT parse the object // the createProperties parameter is here to avoid looping when parsing associations properties = createProperties(pageBase); } else { properties = new ArrayList<>(); } }
/** * For ForwardRateAgreement the ParSpread is the spread to be added to the fixed rate to obtain a * present value of zero. * * @param fra The forward rate agreement. * @param curves The yield curve bundle. * @return The par spread. */ @Override public Double visitForwardRateAgreement( final ForwardRateAgreement fra, final YieldCurveBundle curves) { Validate.notNull(curves); Validate.notNull(fra); return METHOD_FRA.parSpread(fra, curves); }
/** * Computes the present value of a fixed coupon by discounting. * * @param cpn The coupon. * @param curves The curve bundle. * @return The present value. */ public CurrencyAmount presentValue(CouponFixed cpn, YieldCurveBundle curves) { Validate.notNull(curves); Validate.notNull(cpn); final YieldAndDiscountCurve fundingCurve = curves.getCurve(cpn.getFundingCurveName()); double pv = cpn.getAmount() * fundingCurve.getDiscountFactor(cpn.getPaymentTime()); return CurrencyAmount.of(cpn.getCurrency(), pv); }
@Override public IPortletWindow createDelegatePortletWindow( HttpServletRequest request, IPortletEntityId portletEntityId, IPortletWindowId delegationParentId) { Validate.notNull(request, "request can not be null"); Validate.notNull(portletEntityId, "portletEntityId can not be null"); // TODO does a delegate portlet entity need some sort of special treatment or do we just assume // that the calling code is using one? final IPortletWindowId portletWindowId = this.getDefaultPortletWindowId(request, portletEntityId); final PortletWindowCache<IPortletWindow> portletWindowMap = getPortletWindowMap(request); // Check if there is portlet window cached in the request IPortletWindow portletWindow = portletWindowMap.getWindow(portletWindowId); if (portletWindow != null) { logger.trace("Found IPortletWindow {} in request cache", portletWindow.getPortletWindowId()); return portletWindow; } final PortletWindowData portletWindowData = this.getOrCreateDefaultPortletWindowData( request, portletEntityId, portletWindowId, delegationParentId); portletWindow = wrapPortletWindowData(request, portletWindowData); if (portletWindow == null) { return null; } // Cache the wrapped window in the request return portletWindowMap.storeIfAbsentWindow(portletWindow); }
/** * Executed on tab completion for this command, returning a list of options the player can tab * through. * * @param sender Source object which is executing this command * @param alias the alias being used * @param args All arguments passed to the command, split via ' ' * @return a list of tab-completions for the specified arguments. This will never be null. List * may be immutable. * @throws IllegalArgumentException if sender, alias, or args is null */ public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); if (args.length == 0) { return ImmutableList.of(); } String lastWord = args[args.length - 1]; Player senderPlayer = sender instanceof Player ? (Player) sender : null; ArrayList<String> matchedPlayers = new ArrayList<String>(); for (Player player : sender.getServer().getOnlinePlayers()) { String name = player.getName(); if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) { matchedPlayers.add(name); } } Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER); return matchedPlayers; }
public boolean fileHasDependency(File file, File dependency) { Validate.notNull(file, "File can't be null"); Validate.notNull(dependency, "Dependency can't be null"); HierarchyNode fileNode = getNode(file); Validate.notNull(fileNode, "File isn't in hierarchy: " + file); return fileNode.containsDependency(dependency); }
/** * Downloads a {@link Document} from the DMS. * * @param uuid the ID of the document in DMS.<br> * @param versionLabel the version label to be downloaded. Use {@link * DMSConstants#INITIAL_VERSION_LABEL} for first version. Null is not allowed. * @return not null {@link Document} or Exception occurs if no content or no document for the * given frameID, or if the version label does not exist. * @throws RemoteException Communication Exception. * @throws DMSException if an error occurs in DMS back end */ @Interceptors(AuthenticationInterceptor.class) public Document getDocumentInVersion(String uuid, String versionLabel) throws RemoteException, DMSException { Validate.notNull(uuid); Validate.notNull(versionLabel); /** Get the version history. */ VersionHistory versionHistory = null; Document document = null; versionHistory = getAuthoringService() .getVersionHistory(getReference(null, uuid, DMSStoreRegistry.STORE_REF)); for (org.alfresco.webservice.types.Version version : versionHistory.getVersions()) { Reference reference = version.getId(); if (version.getLabel().equals(versionLabel)) { document = getContent(reference, DMSStoreRegistry.VERSION_STORE_REF); if (document != null) { return document; } } } throw new IllegalStateException("Could not download the version : " + versionLabel); }
/** * Computes the interest rate sensitivity of future price. * * @param future The future security. * @param curves The curves. * @return The curve sensitivity. */ @Override public InterestRateCurveSensitivity priceCurveSensitivity( final FederalFundsFutureSecurity future, final YieldCurveBundle curves) { Validate.notNull(future, "Future"); Validate.notNull(curves, "Curves"); int nbFixing = future.getFixingPeriodAccrualFactor().length; YieldAndDiscountCurve ois = curves.getCurve(future.getOISCurveName()); double[] df = new double[nbFixing + 1]; for (int loopfix = 0; loopfix < nbFixing + 1; loopfix++) { df[loopfix] = ois.getDiscountFactor(future.getFixingPeriodTime()[loopfix]); } // Backward sweep double priceBar = 1.0; double interestBar = -1.0 / future.getFixingTotalAccrualFactor() * priceBar; double[] dfBar = new double[nbFixing + 1]; for (int loopfix = 0; loopfix < nbFixing; loopfix++) { dfBar[loopfix] += 1.0 / df[loopfix + 1] * interestBar; dfBar[loopfix + 1] += -df[loopfix] / (df[loopfix + 1] * df[loopfix + 1]) * interestBar; } Map<String, List<DoublesPair>> resultMap = new HashMap<String, List<DoublesPair>>(); List<DoublesPair> listOIS = new ArrayList<DoublesPair>(); for (int loopfix = 0; loopfix < nbFixing + 1; loopfix++) { listOIS.add( new DoublesPair( future.getFixingPeriodTime()[loopfix], -future.getFixingPeriodTime()[loopfix] * df[loopfix] * dfBar[loopfix])); } resultMap.put(future.getOISCurveName(), listOIS); InterestRateCurveSensitivity result = new InterestRateCurveSensitivity(resultMap); return result; }
/** * {@inheritDoc} * * @see * org.prowim.dms.alfresco.ContentService#updateDMSDocument(org.prowim.datamodel.dms.Document, * java.lang.String) */ @Override @Interceptors(AuthenticationInterceptor.class) public void updateDMSDocument(Document document, String uuid) throws DMSException { Validate.notNull(document); Validate.notNull(uuid); ContentFormat contentFormat = new ContentFormat(document.getContentType(), DMSConstants.ENCODING); try { DocumentIdentification documentIdentification = new DocumentIdentification(uuid, null); getContentService() .write( this.getReference( documentIdentification.getPath(), documentIdentification.getUuid(), DMSStoreRegistry.STORE_REF), Constants.PROP_CONTENT, document.getContent(), contentFormat); } catch (ContentFault e) { String message = "Could not update content: "; LOG.error(message, e); DMSFault dmsFault = new DMSFault(); dmsFault.setMessage(message); throw new DMSException(message, dmsFault, e.getCause()); } catch (RemoteException e) { String message = "Could not create connection: "; LOG.error(message, e); DMSFault dmsFault = new DMSFault(); dmsFault.setMessage(message); throw new DMSException(message, dmsFault, e.getCause()); } }
@Override public Double visitVarianceSwap( final VarianceSwap derivative, final EquityOptionDataBundle market) { Validate.notNull(market); Validate.notNull(derivative); return PRICER.presentValue(derivative, market); }
public SimpleFXFuturePresentValueFunction( final String payCurveName, final String receiveCurveName) { Validate.notNull(payCurveName, "pay curve name"); Validate.notNull(receiveCurveName, "receive curve name"); _payCurveName = payCurveName; _receiveCurveName = receiveCurveName; }