Package org.archfirst.common.money

Examples of org.archfirst.common.money.Money


        return total;
    }
   
    @Transient
    public Money getTotalPriceOfExecutions() {
        Money totalPrice = new Money("0.00");
        for (Execution execution : executions) {
            totalPrice = totalPrice.plus(
                    execution.getPrice().times(execution.getQuantity()));
        }
        return totalPrice.scaleToCurrency();
    }
View Full Code Here


    }
   
    @Transient
    public Money getWeightedAveragePriceOfExecutions() {
        if (executions.size() == 0) {
            return new Money("0.00");
        }

        // Calculate weighted average
        Money totalPrice = new Money("0.00");
        DecimalQuantity totalQuantity = new DecimalQuantity();
        for (Execution execution : executions) {
            totalPrice = totalPrice.plus(
                    execution.getPrice().times(execution.getQuantity()));
            totalQuantity = totalQuantity.plus(execution.getQuantity());
        }
        totalPrice = totalPrice.scaleToCurrency();
        return totalPrice.div(totalQuantity, Constants.PRICE_SCALE);
    }
View Full Code Here

        if (type == OrderType.Limit && limitPrice == null) {
            return new OrderEstimate(OrderCompliance.LimitOrderWithNoLimitPrice);
        }
       
        // Calculate estimated values
        Money unitPrice = (type == OrderType.Market) ?
                marketDataService.getMarketPrice(symbol) : limitPrice;
        Money estimatedValue = unitPrice.times(quantity).scaleToCurrency();
        Money fees = getFees();
        Money estimatedValueInclFees = (side==OrderSide.Buy) ?
                estimatedValue.plus(fees) : estimatedValue.minus(fees);
        return new OrderEstimate(estimatedValue, fees, estimatedValueInclFees);
    }
View Full Code Here

        // Create the account
        BrokerageAccount account = new BrokerageAccount(
                accountName,
                AccountStatus.Active,
                OwnershipType.Individual,
                new Money("0.00"));
        brokerageAccountRepository.injectDependencies(account);
        brokerageAccountRepository.persistAndFlush(account);
       
        // Add AccountParty
        AccountParty accountParty =
View Full Code Here

        this.marketValue = marketValue;
    }
   
    public void calculateInstrumentPosition() {
        quantity = new DecimalQuantity();
        totalCost = new Money("0.00");
       
        for (Position child : children) {
            quantity = quantity.plus(child.getQuantity());
            totalCost = totalCost.plus(child.getTotalCost());
        }
View Full Code Here

        if (lastQty == null) {
            lastQty = new DecimalQuantity("0");
        }

        // Initialize lastPrice - it is a required FIX field
        Money lastPrice = executionReport.getLastPrice();
        if (lastPrice == null) {
            lastPrice = new Money("0.00");
        }

        // Now create the FIX message
        quickfix.fix44.ExecutionReport fixMessage =
            new quickfix.fix44.ExecutionReport(
View Full Code Here

        // Extract symbol
        String symbol = message.getInstrument().getSymbol().getValue();

        // Extract limit price
        Money limitPrice = null;
        if (message.isSetField(Price.FIELD) && message.isSetField(Currency.FIELD)) {
            limitPrice = MoneyConverter.toDomain(message.getPrice(), message.getCurrency());
        }

        // Extract allOrNone
View Full Code Here

    @Override
    @Transient
    public Money getAmount() {
        // A securities transfer does not involve money
        return new Money("0.00");
    }
View Full Code Here

        return new Currency(money.getCurrency().getCurrencyCode());
    }
   
    public static Money toDomain(Price price, Currency currency) {
        // Convert using string representation of double
        return new Money(
                new BigDecimal(Double.toString(price.getValue())),
                java.util.Currency.getInstance(currency.getValue()));
    }
View Full Code Here

        this.createBrokerageAccount1();
        this.createExternalAccount1();

        // Transfer cash
        this.baseAccountService.transferCash(
                USERNAME1, new Money(amount),
                externalAccount1Id, brokerageAccount1Id);
    }
View Full Code Here

TOP

Related Classes of org.archfirst.common.money.Money

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.