Class

squants.market

MoneyContext

Related Doc: package market

Permalink

case class MoneyContext(defaultCurrency: Currency, currencies: Set[Currency], rates: Seq[CurrencyExchangeRate], allowIndirectConversions: Boolean = true) extends Product with Serializable

MoneyContext

Provides a context for Money specific operations.

When provided as an implicit parameter, the defaultCurrency will be used by the Money factory when no other currency is provided.

Provides for cross-currency conversions.

Will act as an implicit parameter to cross currency operations to allow for easy conversions

defaultCurrency

Currency used when none is supplied to the Money factory

rates

Collection of Exchange Rates used for currency conversions

Source
MoneyContext.scala
Since

0.1

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MoneyContext
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MoneyContext(defaultCurrency: Currency, currencies: Set[Currency], rates: Seq[CurrencyExchangeRate], allowIndirectConversions: Boolean = true)

    Permalink

    defaultCurrency

    Currency used when none is supplied to the Money factory

    rates

    Collection of Exchange Rates used for currency conversions

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def add(moneyA: Money, moneyB: Money): Money

    Permalink

    Adds two money values that may or may not be in the same currency.

    Adds two money values that may or may not be in the same currency.

    The result will be in the same currency as the first parameter.

    moneyA

    Money A

    moneyB

    Money B

    Exceptions thrown

    NoSuchExchangeRateException when no exchange rate is available

  5. val allowIndirectConversions: Boolean

    Permalink
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def compare(moneyA: Money, moneyB: Money): Int

    Permalink

    Performs a standard compare on two money values that may or may not be in the same currency

    Performs a standard compare on two money values that may or may not be in the same currency

    moneyA

    Money A

    moneyB

    Money B

    Exceptions thrown

    NoSuchExchangeRateException when no exchange rate is available

  9. def convert(money: Money, currency: Currency): Money

    Permalink

    Converts a Money value to the specified currency.

    Converts a Money value to the specified currency.

    The conversion first attempts to use an existing exchange rate for the two currencies in question. If no direct exchange works, a cross rate (limited to 1 hop) will be calculated and used. If no cross rate can be calculated a NoSuchElementException is thrown

    money

    Money to be converted

    currency

    Currency to be converted to

    Exceptions thrown

    NoSuchExchangeRateException when no exchange rate is available

  10. val currencies: Set[Currency]

    Permalink
  11. val defaultCurrency: Currency

    Permalink

    Currency used when none is supplied to the Money factory

  12. def directRateFor(curA: Currency, curB: Currency): Option[CurrencyExchangeRate]

    Permalink

    Returns an Option on an exchange rate if a direct rate exists, otherwise None

    Returns an Option on an exchange rate if a direct rate exists, otherwise None

    curA

    Currency A

    curB

    Currency B

  13. def divide(moneyA: Money, moneyB: Money): BigDecimal

    Permalink

    Divides two money value that may or may not be in the same currency after converting the second to the first

    Divides two money value that may or may not be in the same currency after converting the second to the first

    moneyA

    Money A

    moneyB

    Money B

  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. def indirectRateFor(curA: Currency, curB: Currency): Option[CurrencyExchangeRate]

    Permalink

    Return an Option on an exchange rate.

    Return an Option on an exchange rate. If a direct rate exists an Option on that will be returned. Otherwise, if a cross rate can be determined (1 hop limit), it will be created and returned in an Option. Otherwise, None will be returned

    curA

    Currency A

    curB

    Currency B

  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. val rates: Seq[CurrencyExchangeRate]

    Permalink

    Collection of Exchange Rates used for currency conversions

  23. def subtract(moneyA: Money, moneyB: Money): Money

    Permalink

    Subtracts two money values that may or may not be in the same currency

    Subtracts two money values that may or may not be in the same currency

    The result will be in the same currency as the first parameter.

    moneyA

    Money A

    moneyB

    Money B

    Exceptions thrown

    NoSuchExchangeRateException when no exchange rate is available

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. def withExchangeRates(rates: List[CurrencyExchangeRate]): MoneyContext

    Permalink

    Create a copy of this context with a new list of rates

    Create a copy of this context with a new list of rates

    rates

    List[CurrencyExchangeRate]

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped