Class ComputablePriceV2


  • public class ComputablePriceV2
    extends java.lang.Object
    Ecapsulate the price computation.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Jan 25, 2013
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int buyPrice​(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToBuy)
      Integer binding calculation for the buy price.
      int calculateAffordableAmount​(ITradable tradable, int availableAmount, int maxAmount, long cash)
      Calculate the amount that can be afforded based on available cash.
      int calculateBuyAmount​(ITradable tradable, int availableAmount, int maxPrice, int maxAmount, long maxCash)
      Calculate the amount between 0 and maxAmount that can be bought for at max maxPrice
      int calculateSellAmount​(ITradable tradable, int availableAmount, int minPrice, int maxSellAmount)
      Calculate the amount that can be sold while maintaining a minimal average price per item.
      int sellPrice​(ITradable tradable, javafx.beans.property.ReadOnlyIntegerProperty availableAmount, javafx.beans.binding.IntegerBinding amountToSell)
      Integer binding calculation of the sell price.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ComputablePriceV2

        public ComputablePriceV2()
    • Method Detail

      • calculateSellAmount

        public int calculateSellAmount​(ITradable tradable,
                                       int availableAmount,
                                       int minPrice,
                                       int maxSellAmount)
        Calculate the amount that can be sold while maintaining a minimal average price per item.
        Parameters:
        tradable - good that is to be sold
        availableAmount - available amount in the target of tradable
        minPrice - minimal avg price that may not be transgressed.
        maxSellAmount - maximal amount that should be sold.
        Returns:
        amount that can be sold while maintaining a minimal avg price.
      • buyPrice

        public int buyPrice​(ITradable tradable,
                            javafx.beans.property.ReadOnlyIntegerProperty availableAmount,
                            javafx.beans.binding.IntegerBinding amountToBuy)
        Integer binding calculation for the buy price.
        Parameters:
        tradable - good that is to be traded
        availableAmount - amount of the good that is in store
        amountToBuy - amount to be bought
        Returns:
        buy price for one item of that good.
      • calculateBuyAmount

        public int calculateBuyAmount​(ITradable tradable,
                                      int availableAmount,
                                      int maxPrice,
                                      int maxAmount,
                                      long maxCash)
        Calculate the amount between 0 and maxAmount that can be bought for at max maxPrice
        Parameters:
        tradable - that should be bought
        availableAmount - amount that is available
        maxPrice - maximum buy price per item
        maxAmount - maximum amount to be bought
        maxCash - maximum amount of cash available.
        Returns:
        maximal amount that can be bought
      • calculateAffordableAmount

        public int calculateAffordableAmount​(ITradable tradable,
                                             int availableAmount,
                                             int maxAmount,
                                             long cash)
        Calculate the amount that can be afforded based on available cash.
        Parameters:
        tradable - that should be bought
        availableAmount - amount that is available
        maxAmount - maximum amount that should be bought
        cash - available cash reserves.
        Returns:
        number of items that can be bought between [0,maxAmount].
      • sellPrice

        public int sellPrice​(ITradable tradable,
                             javafx.beans.property.ReadOnlyIntegerProperty availableAmount,
                             javafx.beans.binding.IntegerBinding amountToSell)
        Integer binding calculation of the sell price.
        Parameters:
        tradable - good that is traded
        availableAmount - amount of the good that is in store
        amountToSell - amount to be sold
        Returns:
        sell price for one item of that good