squants.market

Type members

Classlikes

object ARS extends Currency
object AUD extends Currency
object BRL extends Currency
object BTC extends Currency
object CAD extends Currency
object CHF extends Currency
object CLP extends Currency
object CNY extends Currency
object CZK extends Currency
abstract class Currency(val code: String, val name: String, val symbol: String, val formatDecimals: Int) extends UnitOfMeasure[Money]

Represents a Currency, which is the Unit of Measure for Money

Represents a Currency, which is the Unit of Measure for Money

Value Params
code

Currency code

formatDecimals

Number of decimals in standard formatting

name

Currency name

symbol

Currency symbol

Companion
object
object Currency
Companion
class
case class CurrencyExchangeRate(base: Money, counter: Money) extends Ratio[Money, Money]

Represent the rate of exchange between two currencies

Represent the rate of exchange between two currencies

Value Params
base

the base or "Fixed" currency (usually a value of 1 currency unit, but not required)

counter

the counter or "Variable" currency

Authors

garyKeorkunian

Since

0.1

object DKK extends Currency
object ETH extends Currency
object EUR extends Currency
object GBP extends Currency
object HKD extends Currency
object INR extends Currency
object JPY extends Currency
object KRW extends Currency
object LTC extends Currency
object MXN extends Currency
object MYR extends Currency
final class Money extends Quantity[Money]

Represents a quantity of Money.

Represents a quantity of Money.

Money is similar to other quantities in that it represents an amount of something - purchasing power - and it is measured in units - currencies.

The main difference is that the conversion rate between currencies can not be certain at compile. (In fact it may not always be so easy to know them at runtime as well.)

To address this diversion from the way most other quantities work, Money overrides several of the standard methods and operators to ensure one of two rules is followed:

  1. this and that are in the same currency, or
  2. there is in an implicit MoneyContext in scope (which may or may not have the applicable exchange rate)

Methods and operations applied to moneys of different currencies may throw a NoSuchExchangeRateException if the implicit MoneyContext does not contain the Rate(s) necessary to perform the conversion.

The defaultMoneyContext includes USD as the default currency, a list of ~20 other currencies and NO exchange rates

Value Params
amount

the amount of money

currency

the currency in which the money is denominated

Authors

garyKeorkunian

Since

0.1

Companion
object
object Money extends Dimension[Money]

Factory singleton for Money

Factory singleton for Money

Companion
class
case class MoneyContext(defaultCurrency: Currency, currencies: Set[Currency], rates: Seq[CurrencyExchangeRate], allowIndirectConversions: Boolean)

MoneyContext

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

Value Params
defaultCurrency

Currency used when none is supplied to the Money factory

rates

Collection of Exchange Rates used for currency conversions

Authors

garyKeorkunian

Since

0.1

Support for Money DSL

Support for Money DSL

object NAD extends Currency
object NOK extends Currency
object NZD extends Currency
case class NoSuchCurrencyException(code: String, fxContext: MoneyContext) extends Exception
class NoSuchExchangeRateException(val s: String) extends Exception
case class Price[A <: Quantity[A]](money: Money, quantity: A) extends Ratio[Money, A] with Serializable

Represents a price

Represents a price

A price is an squants.Ratio between a quantity of squants.market.Money and some other squants.Quantity

Type Params
A

Quantity Type

Value Params
money

Money

quantity

Quantity

Authors

garyKeorkunian

Since

0.1

object RUB extends Currency
object SEK extends Currency
object TRY extends Currency
object USD extends Currency
object XAG extends Currency
object XAU extends Currency
object ZAR extends Currency

Value members

Concrete fields