Go to top ↑

Launching Trading screens

Almost all TradeIt functionality can be quickly and easily integrated just by launching the pre-built TradeIt screens from the SDK.

Linking a user’s broker

If the user has no previously linked brokers, launching any of the pre-built TradeIt screens will result in the user first being prompted to link a broker. Otherwise the broker linking UI flow can be manually launched like this:

TradeItSDK.launcher.launchBrokerLinking(fromViewController: self)

When the user has successfully authorized the linking, the SDK will deep link back into your app using the OAuth callback URL specified when you initialized the TradeItSDK. Your app should intercept the deep link and pass the callback URL and the top most currently presented view controller to TradeItSDK.launcher.handleOAuthCallback to complete the OAuth flow like this:

// In AppDelegate
func application(
    _ application: UIApplication,
    open url: URL,
    sourceApplication: String?,
    annotation: Any
) -> Bool {
    // Make sure to verify the deep link URL is the one you specified for the TradeItSDK before proceeding with launching handleOAuthCallback

    // Get the top view controller to pass to the launcher. The below example works in the general case, but your app may need to implement custom logic to get the top-most presented view controller.
    if var topViewController = UIApplication.shared.keyWindow?.rootViewController {
        while let presentedViewController = topViewController.presentedViewController {
            topViewController = presentedViewController

        if let navController = topViewController as? UINavigationController,
            let navTopViewController = navController.topViewController {
            topViewController = navTopViewController

        TradeItSDK.launcher.handleOAuthCallback(onTopmostViewController: topViewController, oAuthCallbackUrl: url)
    return true

Launch Portfolio

By default the first valid account is preselected.

TradeItSDK.launcher.launchPortfolio(fromViewController: self)

Launch Portfolio with a specific account pre-selected

let linkedBroker = TradeItSDK.linkedBrokerManager.linkedBrokers.first
let account = linkedBroker.accounts.first

TradeItSDK.launcher.launchPortfolio(fromViewController: self, forLinkedBrokerAccount: account)

Launch Orders screen for an account

guard let account = TradeItSDK.linkedBrokerManager.linkedBrokers.first?.accounts.first else {

TradeItSDK.launcher.launchOrders(fromViewController: self, forLinkedBrokerAccount: account)

Launch Transactions screen for an account

guard let account = TradeItSDK.linkedBrokerManager.linkedBrokers.first?.accounts.first else {

TradeItSDK.launcher.launchTransactions(fromViewController: self, forLinkedBrokerAccount: account)

Launch Trading

TradeItSDK.launcher.launchTrading(fromViewController: self)

Launch Trading with a pre-configured order

If a TradeItOrder is passed when launching trading, the trading ticket screen inputs will be prepopulated from the provided order.

let order = TradeItOrder()
order.symbol = "SYMB"
order.quantity = 100
order.action = .buyToCover
order.expiration = .goodForDay
TradeItSDK.launcher.launchTrading(fromViewController: self, withOrder: order)

Launch Account Management

TradeItSDK.launcher.launchAccountManagement(fromViewController: self)

Launch Account Linking

TradeItSDK.launcher.launchBrokerLinking(fromViewController: self, onLinked: { linkedBroker in
    print("Newly linked broker: \(linkedBroker)")
}, onFlowAborted: {
    print("User aborted linking")

Disabling Portfolio

To configure whether the Portfolio screen is accessible from the Trading flow use:

TradeItSDK.isPortfolioEnabled = false


See UIAppearance.