This repository was archived by the owner on Jan 17, 2024. It is now read-only.
generated from pixel-foundry/swift-package
-
Notifications
You must be signed in to change notification settings - Fork 3
Money
hallee edited this page May 10, 2020
·
1 revision
Money is a precise representation of a currency value.
public struct Money: Hashable
For even dollar amounts, you can initialize this type with an integer literal:
let price: Money = 100
For dollars and cents, use the string literal initializer instead:
let price: Money = "100.12"
Swift’s Decimal
type loses precision when initialized via a float literal and encoding to JSON.
See this discussion for more details.
Enforcing the use of the string literal initializer ensures complete precision when dealing with money values.
AdditiveArithmetic
, Codable
, Comparable
, CustomDebugStringConvertible
, CustomStringConvertible
, ExpressibleByIntegerLiteral
, ExpressibleByStringLiteral
, Hashable
, Numeric
init(_ value: Decimal)
public init(stringLiteral value: String)
public init(integerLiteral value: Int)
public init(from decoder: Decoder) throws
public init?<T>(exactly source: T) where T: BinaryInteger
let value: Decimal
var description: String
var debugDescription: String
var magnitude: Money
public func encode(to encoder: Encoder) throws
public static func <(lhs: Money, rhs: Money) -> Bool
public static func +(lhs: Money, rhs: Money) -> Money
public static func -(lhs: Money, rhs: Money) -> Money
public static func *(lhs: Money, rhs: Money) -> Money
public static func /(lhs: Money, rhs: Money) -> Money
public static func *=(lhs: inout Money, rhs: Money)
public static func /=(lhs: inout Money, rhs: Money)
Generated at 2020-05-22T00:57:11+0000 using swift-doc 1.0.0-beta.3.
Types
- Account
- AccountStatus
- Alpaca
- Alpaca.Key
- Alpaca.Mode
- Alpaca.Version
- AlpacaAPI
- AlpacaAPI.Path
- AlpacaError
- Asset
- Asset.QueryParameters
- AssetClass
- AssetStatus
- Calendar
- Calendar.QueryParameters
- Cancel
- Clock
- Currency
- Direction
- Exchange
- Money
- Order
- Order.QueryParameters
- OrderCancellation
- OrderClass
- OrderRequest
- OrderSide
- OrderStatus
- OrderStatusFilter
- OrderType
- Position
- PositionLiquidation
- PositionSide
- Quantity
- StopLoss
- TakeProfit
- TimeInForce