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: HashableFor even dollar amounts, you can initialize this type with an integer literal:
let price: Money = 100For 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) throwspublic init?<T>(exactly source: T) where T: BinaryIntegerlet value: Decimalvar description: Stringvar debugDescription: Stringvar magnitude: Moneypublic func encode(to encoder: Encoder) throwspublic static func <(lhs: Money, rhs: Money) -> Boolpublic static func +(lhs: Money, rhs: Money) -> Moneypublic static func -(lhs: Money, rhs: Money) -> Moneypublic static func *(lhs: Money, rhs: Money) -> Moneypublic static func /(lhs: Money, rhs: Money) -> Moneypublic 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