Skip to content
mitochondrion edited this page Dec 6, 2016 · 14 revisions

Initializing the TradeItLauncher

To use the SDK, first instantiate the TradeItLauncher:

let launcher = TradeItLauncher(apiKey: API_KEY, environment: TradeItEmsTestEnv)

It serves as the global managing object for the SDK.

Using the SDK

There are two ways to use the TradeIt SDK:

  • The SDK includes pre-built screens and UI workflows that minimize the effort to integrate Trade.it trading, portfolio, and account management into an app.
  • The SDK also includes a set of classes that allow developers to build custom screens and UI workflows for "deep integration" with the Trade.it API trading workflow and users' portfolio data.

Linked Brokers

Whenever a user links their broker, the SDK will automatically save the link (in the form of the associated Trade.it OAuth token) in the secure iOS keychain. When the app is relaunched and the TradeItLauncher is reinstantiated, the saved brokers are loaded from the keychain.

Environments

Environment Enum
Sandbox TradeItEmsTestEnv
Production TradeItEmsProductionEnv

Dummy broker account

In the Sandbox environment there is a Dummy broker available to perform tests without connecting a live broker account. All of the API interactions are stateless and return fake data. To login, select the Dummy broker and use the credentials:

Depending on the username you choose (password will always be "pass"), you can emulate the following scenarios:

Username Response
dummy no errorResult
dummyNotMargin returns error response if request is to place a sell short or buy to cover
dummyNull returns null values for every field that can potentially return as null
dummySecurity returns security question response (answer is tradingticket)
dummyMultiple returns a user with multiple accounts
dummySecurityImage returns response with challenge image (mainly used for IB)
dummyOptionLong returns response with multiple options for the security question answer (answer is option1)

Any other credentials will fail to authenticate.

Testing order errors

Order Size Returns
quantity < 50 review response with no warning messages
50 <= quantity < 100 returns review response with warnings and ack messages
quantity >= 100 returns error response

Live broker accounts

Be aware that our Sandbox environment points to live broker environments. Connecting a live broker account while pointing at our Sandbox will perform real trade requests to brokers.

Clone this wiki locally