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
typeThe type of the updates.
frequencyThe frequency of the updates.
requestThe 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
requestThe 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
instrumentThe instrument for which the updates should be started.
aggregationThe aggregation (in minutes) for which the updates should be started.
fromA 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
updatesRequestThe request that should be used to fetch the snapshot.
completionHandlerThe 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
updatesRequestThe request that should be used to fetch the prices.
completionHandlerThe 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
completionHandlerThe 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
completionHandlerThe 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
completionHandlerThe 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
idThe ID of the order that should be fetched.
completionHandlerThe 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
orderCommandThe order command object, containing information about the order that should be issued.
completionHandlerThe 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
instrumentThe instrument for which the order should be issued.
amountThe amount of the order.
sideThe side of the order.
orderDelegateAn optional TradableOrderStatusDelegate to notify when the order status changes.
completionHandlerThe 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
instrumentThe instrument for which the order should be issued.
amountThe amount of the order.
sideThe side of the order.
takeProfitAn optional take profit protection.
stopLossAn optional stop loss protection.
orderDelegateAn optional TradableOrderStatusDelegate to notify when the order status changes.
completionHandlerThe 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
completionHandlerThe 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
completionHandlerThe 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
idThe ID of the position that should be fetched.
completionHandlerThe 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
candleRequestThe candle request object containing information about the candles that should be fetched.
completionHandlerThe 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
instrumentThe instrument for which the candles should be retrieved.
aggregationThe candle aggregation.
sessionsThe number of sessions to retrieve. Must be greater than 0.
completionHandlerThe 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
lastSessionCloseRequestThe request to be made.
completionHandlerThe 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
searchPhraseThe phrase that the instruments will be searched for.
completionHandlerThe 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
instrumentSearchRequestThe request object containing a list of instrument IDs for which the instruments should be retrieved.
completionHandlerThe 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)
View on GitHub
TradableAccount Class Reference