Package org.archfirst.common.quantity

Examples of org.archfirst.common.quantity.DecimalQuantity


   
    public Order(OrderParams params) {
        this.setCreationTime(new DateTime());
        this.side = params.getSide();
        this.symbol = params.getSymbol();
        this.quantity = new DecimalQuantity(params.getQuantity());
        this.type = params.getType();
        if (this.type == OrderType.Limit) {
            this.limitPrice = params.getLimitPrice();
        }
        this.term = params.getTerm();
View Full Code Here


        return quantity.minus(getCumQty());
    }
   
    @Transient
    public DecimalQuantity getCumQtyOfExecutions() {
        DecimalQuantity total = new DecimalQuantity();
        for (Execution execution : executions) {
            total = total.plus(execution.getQuantity());
        }
        return total;
    }
View Full Code Here

            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

        this.instrumentName = Constants.CASH_INSTRUMENT_NAME;
        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 (executionId == null) {
            executionId = "0";
        }

        // Initialize lastQty - it is a required FIX field
        DecimalQuantity lastQty = executionReport.getLastQty();
        if (lastQty == null) {
            lastQty = new DecimalQuantity("0");
        }

        // Initialize lastPrice - it is a required FIX field
        Money lastPrice = executionReport.getLastPrice();
        if (lastPrice == null) {
View Full Code Here

        return new CumQty(quantity.doubleValue());
    }
   
    public static DecimalQuantity toDomain(CumQty cumQty)
            throws FieldNotFound {
        return new DecimalQuantity(cumQty.getValue());
    }
View Full Code Here

        order.accept(orderRepository);
        orderEventPublisher.publish(new OrderAccepted(order));
    }
   
    private void executeOrders(Order buyOrder, Order sellOrder, Money price) {
        DecimalQuantity quantity =
            buyOrder.getLeavesQty().min(sellOrder.getLeavesQty());
        DateTime executionTime = new DateTime();
        this.executeOrder(buyOrder, executionTime, quantity, price);
        this.executeOrder(sellOrder, executionTime, quantity, price);
    }
View Full Code Here

            Long fromAccountId,
            Long toAccountId) {
        baseAccountService.transferSecurities(
                username,
                symbol,
                new DecimalQuantity(quantity),
                pricePaidPerShare,
                fromAccountId,
                toAccountId);
    }
View Full Code Here

   
    public void transferSecurities(String accountName1, String accountName2, String symbol, BigDecimal quantity) {
        this.baseAccountService.transferSecurities(
                USERNAME1,
                symbol,
                new DecimalQuantity(quantity),
                new Money(),
                getAccountId(accountName1),
                getAccountId(accountName2));
    }
View Full Code Here

    public void initSecurityPosition(String symbol, BigDecimal quantity) throws Exception {
       
        Money pricePerShare = new Money("10");
       
        this.baseAccountService.transferSecurities(
                USERNAME1, symbol, new DecimalQuantity(quantity), pricePerShare,
                externalAccount1Id, brokerageAccount1Id);

        // getOrderEstimate() requires a market price to calculate sale amount
        marketDataService.updateMarketPrice(
                new MarketPrice(symbol, pricePerShare, new DateTime()));
View Full Code Here

TOP

Related Classes of org.archfirst.common.quantity.DecimalQuantity

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.