Examples of EGenMoney


Examples of edu.brown.benchmark.tpce.util.EGenMoney

    private double meanInTheMoneySubmissionDelay;
   
    public MEESecurity() {
        rnd = new EGenRandom(EGenRandom.RNG_SEED_BASE_MEE_SECURITY);
       
        rangeLow = new EGenMoney(TPCEConstants.minSecPrice);
        rangeHigh = new EGenMoney(TPCEConstants.maxSecPrice);
        range = new EGenMoney(TPCEConstants.maxSecPrice - TPCEConstants.minSecPrice);
        period = SEC_PRICE_PERIOD;      // time to get to the same price (in seconds)
    }
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

        }
        else {
            pricePosition = (period - timeWithinPeriod) / (period / 2);
        }

        EGenMoney priceCents = new EGenMoney(range);
        priceCents.multiplyByDouble(pricePosition);
        priceCents.add(rangeLow);

        return priceCents;
    }
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

    * @param  tradeType   Order trade type
    *
    * @return The expected submission time
    */
    public double getSubmissionTime(long secIndex, double pendingTime, EGenMoney limitPrice, TradeType tradeType) {
        EGenMoney priceAtPendingTime = calculatePrice(secIndex, pendingTime);
        double submissionTimeFromPending;  // Submission - Pending time difference

        /*
         *  Check if the order can be fulfilled immediately
         *  i.e., if the current price is less than the buy price
         *  or the current price is more than the sell price.
         */
        if (((tradeType == TradeType.eLimitBuy || tradeType == TradeType.eStopLoss) && priceAtPendingTime.lessThanOrEqual(limitPrice)) ||
            ((tradeType == TradeType.eLimitSell) && limitPrice.lessThanOrEqual(priceAtPendingTime))) {
            // Trigger the order immediately.
            submissionTimeFromPending = rnd.doubleRange(0.5 * meanInTheMoneySubmissionDelay, 1.5 * meanInTheMoneySubmissionDelay);
        }
        else {
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

    */
    private double calculateTime(EGenMoney startPrice, EGenMoney endPrice, int startDirection) {
        int halfPeriod = period / 2;

        // Distance on the price curve from StartPrice to EndPrice (in dollars)
        EGenMoney distance;

        // Amount of time (in seconds) needed to move $1 on the price curve.
        // In half a period the price moves over the entire price range.
        double speed = halfPeriod / range.getDollars();

        if (startPrice.lessThan(endPrice)) {
            if (startDirection > 0) {
                distance = EGenMoney.subMoney(endPrice, startPrice);
            }
            else {
                distance = EGenMoney.addMoney(EGenMoney.subMoney(startPrice, rangeLow), EGenMoney.subMoney(endPrice, rangeLow));
            }
        }
        else {
            if (startDirection > 0) {
                distance = EGenMoney.addMoney(EGenMoney.subMoney(rangeHigh, startPrice), EGenMoney.subMoney(rangeHigh, endPrice));
            }
            else {
                distance = EGenMoney.subMoney(startPrice, endPrice);
            }
        }

        return distance.getDollars() * speed;
    }
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

            GregorianCalendar baseGreTime = new GregorianCalendar();
            currGreTime.setTime(currentTime);
            baseGreTime.setTime(baseTime);
            double fCurrentTime = currGreTime.getTimeInMillis() - baseGreTime.getTimeInMillis();
            //TODO the third para, compare to c++
            TriggerTimeDelay = priceBoard.getSubmissionTime(pNewEntry.symbol, fCurrentTime, new EGenMoney(pNewEntry.price_quote), eTradeType) - fCurrentTime;
            limitOrderTimers.startTimer( TriggerTimeDelay);
        }
    }
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

        newTrade.secFileIndex = accIdAndSecs[2];
       
        newTrade.tradeType = generateTradeType();
        newTrade.tradeStatus = StatusTypeId.E_COMPLETED; // always "completed" for the loading phase
       
        newTrade.bidPrice = new EGenMoney(rnd.doubleIncrRange(TPCEConstants.minSecPrice, TPCEConstants.maxSecPrice, 0.01));
        newTrade.tradeQty = HoldingsAndTrades.TRADE_QTY_SIZES[rnd.intRange(0, HoldingsAndTrades.TRADE_QTY_SIZES.length - 1)];
       
        if (newTrade.tradeType == TradeType.eMarketBuy || newTrade.tradeType == TradeType.eMarketSell) {
            newTrade.submissionTime = currentSimulatedTime;
            newTrade.bidPrice = meeSecurity.calculatePrice(newTrade.secFileIndex, currentSimulatedTime); // correcting the price
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

       
        currCompletedTrades++;
    }
   
    private void updateHoldings() {
        addTrade.buyValue = new EGenMoney(0);
        addTrade.sellValue = new EGenMoney(0);
       
        int neededQty = newTrade.tradeQty;
       
        // new series of holding history rows
        holdingHistory.clear();
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

                // int values)
                String[] ttRow = tradeTypeFile.getTupleByIndex(newTrade.tradeType.ordinal());

                // compare trade type symbols
                if (chargeRow[0].equals(ttRow[0])) {
                    addTrade.charge = new EGenMoney(Double.valueOf(chargeRow[2]));
                    return;
                }
            }
        }
       
View Full Code Here

Examples of edu.brown.benchmark.tpce.util.EGenMoney

        assert false;
    }

    private void generateTradeTax() {
        if (addTrade.sellValue.lessThanOrEqual(addTrade.buyValue)) { // no capital gain
            addTrade.tax = new EGenMoney(0);
            return;
        }
       
        long addrId = addrGenerator.getAddrIdForCustomer(newTrade.customer);
        int[] countryAndDivisionCodes = addrGenerator.getCountryAndDivCodes(addrId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.