TradableAccount
@objc public class TradableAccount: NSObject, NSCoding
An account used for trading.
-
A unique identifier for the account.
Declaration
Swift
@objc public let id: String
-
Display name for the account.
Declaration
Swift
@objc public let displayName: String
-
The name of the broker that the account belongs to.
Declaration
Swift
@objc public let brokerName: String
-
The id of the broker that the account belongs to.
Declaration
Swift
@objc public let brokerId: Int
-
The id of the broker account.
Declaration
Swift
@objc public let brokerageAccountId: String
-
Collection of logos for the broker.
Declaration
Swift
@objc public let brokerLogos: TradableBrokerLogos
-
The router endpoint URL for this account. Tradable integrates with brokers in different regions of the world, to minimize the latency you must connect to a Tradable endpoint in the same region as the broker’s trading backend is located.
Declaration
Swift
@objc public let endpointUrl: String
-
The ISO code for the currency.
Declaration
Swift
@objc public let currencyIsoCode: String
-
The symbolic sign for the currency.
Declaration
Swift
@objc public let currencySign: String
-
An optional URL to the broker’s backend reporting system.
Declaration
Swift
@objc public let externalBackofficeReport: String?
-
Indicates whether it is live account or not.
Declaration
Swift
@objc public let isLive: Bool
-
Specifies the account’s track configuration.
Declaration
Swift
@objc public let trackConfiguration: TradableTrackConfiguration
-
Specifies if positions on this account support stop loss protections.
Declaration
Swift
@objc public let isStopLossSupported: Bool
-
Specifies if positions on this account support take profit protections.
Declaration
Swift
@objc public let isTakeProfitSupported: Bool
-
Specifies the capabilities of market orders on this account.
Declaration
Swift
@objc public let marketOrdersSupport: TradableOrderSupport
-
Specifies the capabilities of limit orders on this account.
Declaration
Swift
@objc public let limitOrdersSupport: TradableOrderSupport
-
Specifies the capabilities of stop orders on this account.
Declaration
Swift
@objc public let stopOrdersSupport: TradableOrderSupport
-
Specifies how instruments are retrieved for this account.
Declaration
Swift
@objc public let instrumentRetrieval: TradableInstrumentRetrieval
-
Specifies the types of protection entry supported, if any, when placing or modifying orders with protections for this account.
Declaration
Swift
@objc public let protectionEntryTypes: TradableProtectionEntryTypes
-
Simple description of this object.
Declaration
Swift
public override var description: String
-
Returns the access token for this account (may be nil).
Declaration
Swift
@objc public func getAccessToken() -> TradableAccessToken?
-
Starts updates for this account for all open positions; stops previous updates for this account, if such were in action.
Declaration
Swift
@objc public func startUpdates(ofType type: TradableUpdatesType, withFrequency frequency: TradableUpdatesFrequency, with request: TradableUpdatesRequest = TradableUpdatesRequest(instrumentIds: [], includeOpenPositions: true, includeMarginFactors: false))
Parameters
type
The type of the updates.
frequency
The frequency of the updates.
request
The request that should be used for updates.
-
Stops updates for this account.
Declaration
Swift
@objc public func stopUpdates()
-
Sets updates request for updates for this account. The request containing instrument IDs must be set after starting the updates.
Declaration
Swift
@objc public func setUpdatesRequest(_ request: TradableUpdatesRequest)
Parameters
request
The request that should be used for updates. Replaces the previous request that was in use for this account.
-
Starts candle updates for this account; stops previous candle updates for this account, if such were in action. Will start prices updates if there were no updates running, or full updates if the updates running were neither full nor prices.
Declaration
Swift
@objc public func startCandleUpdates(for instrument: TradableInstrument, aggregation: Int, from: UInt64)
Parameters
instrument
The instrument for which the updates should be started.
aggregation
The aggregation (in minutes) for which the updates should be started.
from
A Unix timestamp in milliseconds, specifies since when should the candles be requested. Cannot be greater than the current timestamp.
-
Stops candle updates for this account. Does not stop prices/full updates if such were started by starting candle updates. If you want to stop all updates, call also stopUpdates().
Declaration
Swift
@objc public func stopCandleUpdates()
-
Gets a snapshot of this account.
Declaration
Swift
@objc public func getAccountSnapshot(with updatesRequest: TradableUpdatesRequest, completionHandler: ((_ snapshot: TradableAccountSnapshot?, _ error: TradableError?) -> Void)!)
Parameters
updatesRequest
The request that should be used to fetch the snapshot.
completionHandler
The closure to be called when the response comes back, with an optional TradableAccountSnapshot object and an optional TradableError object.
-
Gets prices for this account.
Declaration
Swift
@objc public func getPrices(with updatesRequest: TradableUpdatesRequest, completionHandler: ((_ prices: TradablePrices?, _ error: TradableError?) -> Void)!)
Parameters
updatesRequest
The request that should be used to fetch the prices.
completionHandler
The closure to be called when the response comes back, with an optional array of TradablePrice objects and an optional TradableError object.
-
Gets this account’s metrics.
Declaration
Swift
@objc public func getAccountMetrics(_ completionHandler: ((_ accountMetrics: TradableAccountMetrics?, _ error: TradableError?) -> Void)!)
Parameters
completionHandler
The closure to be called when the response comes back, with an optional array of TradableMetrics objects and an optional TradableError object.
-
Gets all orders for this account.
Declaration
Swift
@objc public func getOrders(_ completionHandler: ((_ orders: TradableOrders?, _ error: TradableError?) -> Void)!)
Parameters
completionHandler
The closure to be called when the response comes back, with an optional TradableOrders object and an optional TradableError object.
-
Gets pending orders for this account.
Declaration
Swift
@objc public func getPendingOrders(_ completionHandler: ((_ pendingOrders: [TradableOrder]?, _ error: TradableError?) -> Void)!)
Parameters
completionHandler
The closure to be called when the response comes back, with an optional list of TradableOrder objects and an optional TradableError object.
-
Gets an order by ID for this account.
Declaration
Swift
@objc public func getOrder(withId id: String, completionHandler: ((_ order: TradableOrder?, _ error: TradableError?) -> Void)!)
Parameters
id
The ID of the order that should be fetched.
completionHandler
The closure to be called when the response comes back, with an optional TradableOrder object and an optional TradableError object.
-
Issues a new order.
Declaration
Swift
@objc public func issueNewOrder(with orderCommand: TradableOrderCommand, completionHandler: ((_ order: TradableOrder?, _ error: TradableError?) -> Void)!)
Parameters
orderCommand
The order command object, containing information about the order that should be issued.
completionHandler
The closure to be called when the response comes back, with an optional TradableOrder object and an optional TradableError object. TradableOrder is an order that will have been created. Getting it back in the closure doesn’t mean that the order has been executed; check its status in tradableOrdersUpdated delegate method.
-
Issues a new market order.
Declaration
Swift
@objc public func issueNewMarketOrder(for instrument: TradableInstrument, withAmount amount: Double, withSide side: TradableOrderSide, orderDelegate: TradableOrderStatusDelegate? = nil, completionHandler: ((_ order: TradableOrder?, _ error: TradableError?) -> Void)!)
Parameters
instrument
The instrument for which the order should be issued.
amount
The amount of the order.
side
The side of the order.
orderDelegate
An optional TradableOrderStatusDelegate to notify when the order status changes.
completionHandler
The closure to be called when the response comes back, with an optional TradableOrder object and an optional TradableError object. TradableOrder is an order that will have been created. Getting it back in the closure doesn’t mean that the order has been executed; check its status in tradableOrdersUpdated delegate method.
-
issueNewMarketOrderWithProtections(for:withAmount:withSide:withTakeProfit:withStopLoss:orderDelegate:completionHandler:)
Issues a new market order with protections.
Declaration
Swift
@objc public func issueNewMarketOrderWithProtections(for instrument: TradableInstrument, withAmount amount: Double, withSide side: TradableOrderSide, withTakeProfit takeProfit: TradableOrderProtection?, withStopLoss stopLoss: TradableOrderProtection?, orderDelegate: TradableOrderStatusDelegate? = nil, completionHandler: ((_ order: TradableOrder?, _ error: TradableError?) -> Void)!)
Parameters
instrument
The instrument for which the order should be issued.
amount
The amount of the order.
side
The side of the order.
takeProfit
An optional take profit protection.
stopLoss
An optional stop loss protection.
orderDelegate
An optional TradableOrderStatusDelegate to notify when the order status changes.
completionHandler
The closure to be called when the response comes back, with an optional TradableOrder object and an optional TradableError object. TradableOrder is an order that will have been created. Getting it back in the closure doesn’t mean that the order has been executed; check its status in tradableOrdersUpdated delegate method.
-
Gets all positions for this account.
Declaration
Swift
@objc public func getPositions(_ completionHandler: ((_ positions: TradablePositions?, _ error: TradableError?) -> Void)!)
Parameters
completionHandler
The closure to be called when the response comes back, with an optional TradablePositions object and an optional TradableError object.
-
Gets open positions for this account.
Declaration
Swift
@objc public func getOpenPositions(_ completionHandler: ((_ openPositions: [TradablePosition]?, _ error: TradableError?) -> Void)!)
Parameters
completionHandler
The closure to be called when the response comes back, with an optional list of TradablePosition objects and an optional TradableError object.
-
Gets a position by ID for this account.
Declaration
Swift
@objc public func getPosition(withId id: String, completionHandler: ((_ position: TradablePosition?, _ error: TradableError?) -> Void)!)
Parameters
id
The ID of the position that should be fetched.
completionHandler
The closure to be called when the response comes back, with an optional TradablePosition object and an optional TradableError object.
-
Gets candles.
Remark
This method is recursive.
Declaration
Swift
@objc public func getCandles(with candleRequest: TradableCandleRequest, completionHandler: ((_ candles: TradableCandleResponse?, _ error: TradableError?) -> Void)!)
Parameters
candleRequest
The candle request object containing information about the candles that should be fetched.
completionHandler
The closure to be called when the response comes back, with an optional TradableCandleResponse object and an optional TradableError object.
-
Returns candles grouped into open market sessions.
Declaration
Swift
@objc public func getGroupedCandles(for instrument: TradableInstrument, aggregation: TradableAggregation, sessions: UInt, completionHandler: ((_ groupedCandles: [UInt64:[TradableCandle]]?, _ error: TradableError?) -> Void)!)
Parameters
instrument
The instrument for which the candles should be retrieved.
aggregation
The candle aggregation.
sessions
The number of sessions to retrieve. Must be greater than 0.
completionHandler
The closure to be called when the response comes back, with an optional dictionary of UInt64 to list of TradableCandle objects and an optional TradableError object.
-
Gets the last session’s close.
Declaration
Swift
@objc public func getLastSessionClose(with lastSessionCloseRequest: TradableLastSessionCloseRequest, completionHandler: ((_ lastSessionClose: [TradableLastSessionClose]?, _ error: TradableError?) -> Void)!)
Parameters
lastSessionCloseRequest
The request to be made.
completionHandler
The closure to be called when the response comes back, with an optional list of TradableLastSessionClose objects and an optional TradableError object.
-
Searches for instruments that contain a specified phrase.
Declaration
Swift
@objc public func searchForInstruments(containing searchPhrase: String, completionHandler: ((_ searchResults: TradableInstrumentSearchResults?, _ error: TradableError?) -> Void)? = nil)
Parameters
searchPhrase
The phrase that the instruments will be searched for.
completionHandler
The closure to be called when the response comes back, with an optional TradableInstrumentSearchResults object and an optional TradableError object. If nil, the results will be returned using current searchDelegate’s tradableInstrumentSearchResultsReceived method.
-
Gets instruments.
Declaration
Swift
@objc public func getInstruments(with instrumentSearchRequest: TradableInstrumentSearchRequest, completionHandler: ((_ instrumentList: TradableInstrumentList?, _ error: TradableError?) -> Void)!)
Parameters
instrumentSearchRequest
The request object containing a list of instrument IDs for which the instruments should be retrieved.
completionHandler
The closure to be called when the response comes back, with an optional TradableInstrumentList object and an optional TradableError object.
-
Creates an object with given parameters. Conforms to NSCoding protocol.
Declaration
Swift
required convenience public init?(coder decoder: NSCoder)
-
Encoding method, conforming to NSCoding protocol.
Declaration
Swift
public func encode(with aCoder: NSCoder)