Go to top ↑
Menu
JSON API iOS SDK Android SDK

Overview

Welcome to TradeIt!

Below you will find instructions for using the TradeIt API.

Before running the API in your production environment, you will need to have a unique API key issued to you.

Although we have done our best to illustrate function calls with sample JSON request/response objects, please make sure to peruse the details of each method, as not all scenarios can be possibly covered.

Our API is architected around a JSON-pure approach. We use standard HTTP to communicate as well as JSON responses to indicate status and errors. All responses come in standard JSON format.

The TradeIt API is served over HTTPS to ensure data privacy. Request data is included within the body as JSON, with the exception of the SRV param which is passed along the query string for the authentication and security question requests.

The basic flow is centered around using our oAuth flow to create a userToken. Using this userToken you can authenticate the user to establish a 30 minute session. Successful authentication will return a session token that is required for all subsequent API calls.

All tokens to expire after 30 days, at which point a renew token function will need to be called and the user re-authenticated. We also provide a delete token function that should be implemented in the event the user wants to disconnect from your service.

Still have questions? Get in touch.

Implementation Guidelines

Testing & Environment

Make sure to build and test your code against our testing environment before deploying to production.
TradeIt Testing Environment: https://ems.qa.tradingticket.com
TradeIt Production Environment: https://ems.tradingticket.com

While using the TradeIt testing environment, all broker connections are made to the LIVE broker environments.

In order to test the flow without executing a trade, use our virtual Dummy Broker. Click here to find out more about using the Dummy Broker

Authentication & Token Storage

Mobile implementations should use the iOS SDK or Android SDK to create and retrieve tokens.

Desktop applications and non-standard mobile implementations need to use the TradeIt oAuth page and follow the outlined flow:

  1. Request the PopUp URL user/getOAuthLoginPopupUrlForWebApp
  2. Open the returned PopUp URL in a new window, so the user can login
  3. On successful authentication the page uses a javascript post message, to alert your site with an oAuthVerifier token
  4. You'll post this to your server and then request user/getOAuthAccessToken to receive the userId and userToken

Check out Auth Tokens for more information, and examples.

NOTE: After 3 invalid login attempts in a row, the user IP will be blocked from TradeIt servers for a duration of 5 minutes.

Broker Branding

TradeIt does not hold the trademark rights to the brokers it supports. Some brokers are more sensitive than others about protocols for branding and advertising. Therefore, we ask that you refrain from building broker-branded content into your UX, unless you have a specific arrangement with a broker for co-promotion that uses their branding.

TradeIt Logo and Terms Link

Please include “powered by TradeIt” somewhere in the UX for authenticating or linking an account. Also, we require that you include a link to our terms and conditions, which are located at: https://www.trade.it/terms

User Service

Auth Tokens


curl "https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"apiKey\":\"tradeit-test-api-key\",
        \"broker\":\"Dummy\"
}"

import requests
payload = {
        "apiKey":"tradeit-test-api-key",
        "broker":"Dummy"
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp")
payload = {
        "apiKey":"tradeit-test-api-key",
        "broker":"Dummy"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp",
[
        "apiKey" => "tradeit-test-api-key",
        "broker" => "Dummy"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "oAuthURL": "https://ems.qa.tradingticket.com/oAuth/tradeItAuthScreen?oAuthTempToken=793f1e9e-0dcb-493f-981f-9c965ed810cd",
    "shortMessage": "oAuth URL successfully generated",
    "status": "SUCCESS",
    "token": "",
    "longMessages": null
}

A user oAuth token is generated given credentials for a broker. The token may be used to authenticate the user in the future without them having to re-enter their credentials. And because of this the userId/userToken should be handled like a username/password.

Request oAuth PopUp URL

https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Param Status Details
apiKey required The API key given to you by TradeIt
broker* required See broker options below

* Choose one of the following broker values: Dummy (for testing only), Etrade, IB, Scottrade, Fidelity, TradeStation, Tradier, Ally Invest, FOREX.com.

With the PopUp URL you'll want to open a PopUp window which will present either the broker's official oAuth page, or if the broker doesn't support an official oAuth flow, a TradeIt designed login form will appear. On success the PopUp window will send a javascript post message back to the parent page.

Example Javascript Post Message Code


〈script〉
        var receiveMessage = function(e) {
                var data = JSON.parse(e.data);
                var oAuthVerifier = data.oAuthVerifier;
        };


        if (window.addEventListener) {
                addEventListener("message", receiveMessage, false);
        } else {
                attachEvent("onmessage", receiveMessage);
        }
〈/script〉

curl "https://ems.qa.tradingticket.com/api/v1/user/getOAuthAccessToken" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"apiKey\":\"tradeit-test-api-key\",
        \"oAuthVerifier\":\"46eb5b7c-06e7-4a97-a285-8f5aa260700a\"
}"

import requests
payload = {
        "apiKey":"tradeit-test-api-key",
        "oAuthVerifier":"46eb5b7c-06e7-4a97-a285-8f5aa260700a"
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/getOAuthAccessToken', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/getOAuthAccessToken")
payload = {
        "apiKey":"tradeit-test-api-key",
        "oAuthVerifier":"46eb5b7c-06e7-4a97-a285-8f5aa260700a"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/getOAuthAccessToken",
[
        "apiKey" => "tradeit-test-api-key",
        "oAuthVerifier" => "46eb5b7c-06e7-4a97-a285-8f5aa260700a"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "activationTime": "IMMEDIATE",
    "broker": "Dummy",
    "longMessages": [null],
    "shortMessage": "User successfully linked",
    "status": "SUCCESS",
    "token": "6101da3a9aab4ee68eb5fb9e4b50b3a2",
    "userId": "6291461529169096d5b8",
    "userToken": "ZAqri9soyMf0VcaeR6Bom3Sj8K3WuGrARdjFJjs49LM%3DRXZsi8XH38QL%2BGh0OBwYVA%3D%3D"
}

Request UserId and UserToken

Once your app has recieved the oAuthVerifier token you'll want to pass it to your server to exchange it for the userId and userToken fields that are used with the authenticate method. The userId and userToken should be handled like a username and password.

IB specific: The first time a user links an IB account, it needs to be activated, and it will be available in one or two business days. A specific message will be returned (see activationTime field in a successful response). Each account needs only one activation (per API Key).

https://ems.qa.tradingticket.com/api/v1/user/getOAuthAccessToken

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Param Status Details
apiKey required The API key given to you by TradeIt
oAuthVerifier* required The oAuthVerifier that was returned via postmessage

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent request for the user session
shortMessage string "User successfully linked" or "Activation in Progress"
longMessages Array of String null or ["Your broker account is being activated. Check back soon (up to two business days)"]
userId String userId used in authentication
userToken string userToken used in authentication
activationTime string linked account availability: "IMMEDIATE" or "ONE_OR_TWO_BUSINESS_DAY"

Live Example


Request to: https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForWebApp

Authenticate


curl "https://ems.qa.tradingticket.com/api/v1/user/authenticate?srv=1455723756890" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"userToken\":\"ZAqri9soyMf0VcaeR6Bom3Sj8K3WuGrARdjFJjs49LM%3DRXZsi8XH38QL%2BGh0OBwYVA%3D%3D\",
        \"userId\":\"6a2793dee39d4f21a5169be53bf22b92\",
        \"apiKey\":\"tradeit-test-api-key\"
}"

import requests
payload = {
        'userToken':'ZAqri9soyMf0VcaeR6Bom3Sj8K3WuGrARdjFJjs49LM%3DRXZsi8XH38QL%2BGh0OBwYVA%3D%3D',
        'userId':'6291461529169096d5b8',
        'apiKey':'tradeit-test-api-key'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/authenticate?1455723756890', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/authenticate?srv=1455723756890")
payload = {
        "userToken" => "ZAqri9soyMf0VcaeR6Bom3Sj8K3WuGrARdjFJjs49LM%3DRXZsi8XH38QL%2BGh0OBwYVA%3D%3D",
        "userId" => "6291461529169096d5b8",
        "apiKey" => "tradeit-test-api-key"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/authenticate?srv=1455723756890",
[
        "userToken" => "ZAqri9soyMf0VcaeR6Bom3Sj8K3WuGrARdjFJjs49LM%3DRXZsi8XH38QL%2BGh0OBwYVA%3D%3D",
        "userId" => "6291461529169096d5b8",
        "apiKey" => "tradeit-test-api-key"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "accounts": [{
            "accountNumber": "brkAcct1",
            "name": "My Margin Account",
            "accountIndex": "sTnFSqaSoEel2F++dg5K0wxfIwA=",
            "accountBaseCurrency": "USD"
    }],
    "longMessages": null,
    "shortMessage": "Credential Successfully Validated",
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8"
}

After using our oAuth page to create a userToken, you will then exchange this token for a session token to be used for all subsequent requests. You will also get a list of user accounts associated with that login information.

REQUIRED srv param: The srv param is a timestamp or UID that must be the same between auth and answer security question requests for a user. This should passed in along the query string.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/authenticate?srv=

Environment: Testing
While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
userToken string required Token from oAuth link call
userId string required Internal id returned from oAuth link call
apiKey string required Your issued API key

Query Parameters

Field Type Status Details
srv string required Timestamp or UID, will be used in the answer security question request

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent request for the user session
shortMessage string "Credential Successfully Validated"
longMessages null null
accounts array Array of account objects belonging to user
∟ accountNumber string Used for account specific actions like trading
∟ name string Display value for referencing the account
∟ accountBaseCurrency string base currency of the account
∟ accountIndex string A unique (per user/broker) key to represent the account

{
    "informationType": "SECURITY_QUESTION",
    "longMessages": null,
    "securityQuestion": "When is Valentines Day?",
    "securityQuestionOptions": [
            "July 4th",
            "February 14th",
            "December 25th",
            "February 2nd",
            "January 1st",
            "None of the above"
    ],
    "shortMessage": "Answering Security Question",
    "status": "INFORMATION_NEEDED",
    "token": "c8e6c20b3b7843028332e1e522cb89b8"
}

Security Question Response

If you get this response, you will need to call user/answerSecurityQuestion in order to activate the session. This result will always contain a security question. However, depending on the broker, it may also include a list of security question answer options.

Field Type Description
status string INFORMATION_NEEDED
informationType string "SECURITY_QUESTION"
longMessages array[string] Informational messages
securityQuestion string The question to be presented to the user
securityQuestionOptions array[string] If populated, the question is a multiple choice, all options to be displayed to the user
shortMessage string "Answering Security Question"
token string Token to be used to continue the session

Error Response

Standard error message format, short and long messages should be presented to the user

Security Question


curl "https://ems.qa.tradingticket.com/api/v1/user/answerSecurityQuestion?srv=1455723756890" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"securityAnswer\":\"February 14th\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'securityAnswer':'February 14th',
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/answerSecurityQuestion?srv=1455723756890', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/answerSecurityQuestion?srv=1455723756890")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "securityAnswer" => "February 14th"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/answerSecurityQuestion?srv=1455723756890",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "securityAnswer" => "February 14th"
];
my $resp = $ua->request($req);

Used when the auth response is a security question. Some brokers have multiple security questions, so it's possible to get a secondary security question response.

REQUIRED srv param: The srv param is a timestamp or UID that must be the same between auth and answer security question requests for a user. This should passed in along the query string.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/answerSecurityQuestion?srv=

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
securityAnswer string required

Query Parameters

Field Type Status Details
srv string required Timestamp or UID, used in the authenticate request

Success Response

This is the same success response as shown in the /user/auth call

Security Question Response

This is the same security question response as shown in the /user/auth call, this can happen if the user answered incorrectly, or some brokers present multiple questions.

Error Response

Standard error message format, short and long messages should be presented to the user.

Close Session


curl "https://ems.qa.tradingticket.com/api/v1/user/closeSession" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"apiKey\":\"tradeit-test-api-key\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'apiKey':'tradeit-test-api-key'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/closeSession', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/closeSession")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "apiKey" => "tradeit-test-api-key"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/closeSession",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "apiKey" => "tradeit-test-api-key"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "longMessages": null,
    "shortMessage": null,
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8"
}

Used to close a user's current session

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/closeSession

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
apiKey string required Your issued API key

Success Response

Field Type Details
status string SUCCESS
shortMessage null null
longMessages null null
token string The token for the session just closed

Error Response

Standard error message, most often caused by the session having already expired.

Keep Alive


curl "https://ems.qa.tradingticket.com/api/v1/user/keepSessionAlive" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"apiKey\":\"tradeit-test-api-key\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'apiKey':'tradeit-test-api-key'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/keepSessionAlive', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/keepSessionAlive")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "apiKey" => "tradeit-test-api-key"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/keepSessionAlive",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "apiKey" => "tradeit-test-api-key"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "longMessages": null,
    "shortMessage": null,
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8"
}

Used to keep a user's current session from expiring

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/keepSessionAlive

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
apiKey string required Your issued API key

Success Response

Field Type Details
status string SUCCESS
shortMessage null null
longMessage null null
token string String, the token for the session just kept alive

Error Response

Standard error message, most often caused by the session having already expired.

oAuth Token Update


curl "https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForTokenUpdate" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"apiKey\":\"tradeit-test-api-key\",
        \"userId\":\"02c1449004895516a7c2\",
        \"broker\":\"Dummy\"
}"

import requests
payload = {
        'apiKey':'tradeit-test-api-key',
        'userId':'02c1449004895516a7c2',
        'broker':'Dummy'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForTokenUpdate', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForTokenUpdate")
payload = {
        "apiKey" => "tradeit-test-api-key",
        "userId" => "02c1449004895516a7c2",
        "broker" => "Dummy"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForTokenUpdate",
[
        "apiKey" => "tradeit-test-api-key",
        "userId" => "02c1449004895516a7c2",
        "broker" => "Dummy"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "oAuthURL": "https://ems.qa.tradingticket.com/oAuth/tradeItAuthScreen?oAuthTempToken=793f1e9e-0dcb-493f-981f-9c965ed810cd",
    "shortMessage": "oAuth URL successfully generated",
    "status": "SUCCESS",
    "token": "",
    "longMessages": null
}

Used to create a new userToken after expiration, this is similar to the original oAuth flow, however it is preferred for renewing a token as it will keep the userId for better tracking and more accurate analytics.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/getOAuthLoginPopupUrlForTokenUpdate

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
apiKey string required The API key given to you by TradeIt
userId string required The id returned from the original auth call
broker string required See broker options in the auth method
interAppAddressCallback string optional Use only for mobile app oAuth flow

Success Response

Field Type Details
oAuthURL string oAuthURL with oAuthTempToken
shortMessage string "oAuth URL successfully generated"
status string SUCCESS
token string ""
longMessages string null

Error Response

Standard error message, most often invalid credentials.

oAuth Token Delete


curl "https://ems.qa.tradingticket.com/api/v1/user/oAuthDelete" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"userToken\":\"wVzwE8ZBjb3sBd53LlcJ0yiJ4QGy6KWDgS3TGp0yNZQ%3DM%2FPDoGWovjE2ArcdzE2%2BYg%3D%3D\",
        \"userId\":\"02c1449004895516a7c2\",
        \"apiKey\":\"tradeit-test-api-key\"
}"

import requests
payload = {
        'userToken':'wVzwE8ZBjb3sBd53LlcJ0yiJ4QGy6KWDgS3TGp0yNZQ%3DM%2FPDoGWovjE2ArcdzE2%2BYg%3D%3D',
        'userId':'02c1449004895516a7c2',
        'apiKey':'tradeit-test-api-key'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/user/oAuthDelete', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/user/oAuthDelete")
payload = {
        "userToken" => "wVzwE8ZBjb3sBd53LlcJ0yiJ4QGy6KWDgS3TGp0yNZQ%3DM%2FPDoGWovjE2ArcdzE2%2BYg%3D%3D",
        "userId" => "02c1449004895516a7c2",
        "apiKey" => "tradeit-test-api-key"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/user/oAuthDelete",
[
        "userToken" => "wVzwE8ZBjb3sBd53LlcJ0yiJ4QGy6KWDgS3TGp0yNZQ%3DM%2FPDoGWovjE2ArcdzE2%2BYg%3D%3D",
        "userId" => "02c1449004895516a7c2",
        "apiKey" => "tradeit-test-api-key"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "longMessages": null,
    "shortMessage": "User succesfully unlinked",
    "status": "SUCCESS",
    "userToken": "bETY32YiKo3NjmxMhIXC38mn4A%2Bg2A93Giy9s5z2Oog%3DxmDaq8R2EO4T2cHcYm6yhw%3D%3D"
}

Used to delete a token when the user disconnects their account

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/user/oAuthDelete

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
userToken string required User's oAuth token
userId string required The id returned from the original auth call
apiKey string required Your issued API key

Success Response

Field Type Details
status string SUCCESS
shortMessage null null
longMessage null null
userToken string The user token deleted

Error Response

Standard error message, most often if token already deleted.

Balance Service

Get Account Overview

curl "https://ems.qa.tradingticket.com/api/v1/balance/getAccountOverview" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/balance/getAccountOverview', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/balance/getAccountOverview")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/balance/getAccountOverview",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this for equities:


{
    "availableCash": 0,
    "buyingPower": 1452.02,
    "dayAbsoluteReturn": 2.34,
    "dayPercentReturn": 0.12,
    "longMessages": >null,
    "shortMessage": "Account Overview successfully fetched",
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "marginCash": "-5.43",
    "totalAbsoluteReturn": -16.89,
    "totalPercentReturn": -0.009969542428106,
    "totalValue": 1694.16
}

The above command returns JSON structured like this for FX:


{
    "status": "SUCCESS",
    "longMessages"": null,
    "fxAccountOverview": null,
    "token": "ce387e2a42214310b9045f1510763c5b",
    "accountOverview":
    {
        "accountBaseCurrency": "USD",
        "buyingPower": 2408.12,
        "totalPercentReturn": 22.84,
        "dayPercentReturn": 3.25,
        "totalAbsoluteReturn": 14486.67,
        "dayAbsoluteReturn": 78.42,
        "totalValue": 76489.23,
        "availableCash": 1204.06
    },
    "shortMessage": Account Overview successfully fetched"
}

Retrieve account overview and balances. Please note some brokerages have slight variations for these fields see the broker exception table below.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/balance/getAccountOverview

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in

Success Response (Equities only)

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests.
shortMessage string "Account Overview successfully fetched"
longMessages null null
availableCash double Cash available to withdraw [+ / null]
buyingPower double The buying power of the account [+ / null]
totalValue double The total account value [+ / null]
dayAbsoluteReturn double The daily return of the account [+ / - / null]
dayPercentReturn double The daily return percentage [+ / - / null]
totalAbsoluteReturn double The total absolute return on the account [+ / - / null]
totalPercentReturn double The total percentage return on the account [+ / - / null]
marginCash double The margin cash balance of the account [+ / - / null]

Success Response (FX only)

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests
shortMessage string "Account Overview successfully fetched"
longMessages null null
buyingPowerBaseCurrency double The buying power of the account in the account's base currency
marginBalanceBaseCurrency double The margin balance in the account's base currency
realizedPLBaseCurrency double Realized profit and loss in the account's base currency
totalValueBaseCurrency double The total value of the account in the account's base currency
totalValueUSD double The total value of the account in USD
unrealizedPLBaseCurrency double Unrealized profit and loss in the account's base currency

Broker Exceptions

Broker Field Details
E*Trade dayAbsoluteReturn The dayAbsoluteReturn is not provided by E*Trade.
E*Trade dayPercentReturn The dayPercentReturn is not provided by E*Trade.
Fidelity Total GainLoss Dollar This field is not provided by Fidelity.
Fidelity Total GainLoss Percent Fidelity provides this field as YearToDate total gain/loss.
IB dayAbsoluteReturn The dayAbsoluteReturn is not provided by IB.
IB dayPercentReturn The dayPercentReturn is not provided by IB.
OptionsHouse Total GainLoss OptionsHouse provides these fields as YearToDate values.
OptionsHouse Margin Cash The margin cash balance is not provided by Optionshouse.
Scottrade Margin Cash The margin cash balance is not provided by Scottrade.
TradeStation Available Cash TradeStation only provides a begining of day value.
TradeStation Margin Cash The margin cash balance is not provided by TradeStation.
Tradier Daily GainLoss This field is not provided by Tradier.
Tradier Margin Cash The margin cash balance is not provided by Tradier.
Vanguard Daily GainLoss The daily gain/loss is not provided by Vanguard.
Vanguard Total GainLoss The total gain/loss is not provided by Vanguard.

Error Response

Standard error message

Position Service

Get Positions


curl "https://ems.qa.tradingticket.com/api/v1/position/getPositions" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/position/getPositions', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/position/getPositions")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/position/getPositions",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "currentPage": 0,
    "longMessages": null,
    "positions": [{
        "costbasis": 43.0,
        "holdingType": "LONG",
        "lastPrice": 0.41,
        "quantity": 100.0,
        "symbol": "AMNL",
        "symbolClass": "EQUITY_OR_ETF",
        "todayGainLossDollar": 0.5,
        "todayGainLossPercentage": 0.012345679012345678,
        "totalGainLossDollar": -2.0,
        "totalGainLossPercentage": -0.046511627906976744
        },
        {"costbasis": 11633.02,
        "holdingType": "LONG",
        "lastPrice": 116.33,
        "quantity": 100.0,
        "symbol": "APPL",
        "symbolClass": "EQUITY_OR_ETF",
        "todayGainLossDollar": 0.5,
        "todayGainLossPercentage": 0.012345679012345678,
        "totalGainLossDollar": -2.0,
        "totalGainLossPercentage": -0.046511627906976744
    }],
    "shortMessage": "Position successfully fetched",
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "totalPages": 1
}

The above command returns JSON structured like this for FX:


{
    "accountBaseCurrency": "USD",
    "currentPage": 0,
    "longMessages": null,
    "positions": [{
        "symbol": "USD/JPY",
        "symbolClass": "FX",
        "holdingType": "LONG",
        "quantity": 1000.0,
        "totalUnrealizedProfitAndLossBaseCurrency": 0.0,
        "totalValueBaseCurrency": 105689.0,
        "totalValueUSD": 1000.0,
        "averagePrice": 105.689,
        "limitPrice": 0.0,
        "stopPrice": 0.0
        }],
    "shortMessage": "Position successfully fetched",
    "status": "SUCCESS",
    "token": "bdd218ec25724217887b686a757bd195",
    "totalPages": 1
}

Retrieve all positions for an account given its number. Please note some brokerages have slight variations for these fields see the broker exception table below.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/position/getPositions

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in
page int optional Used to navigate multiple sets of results

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests
shortMessage string "Position successfully fetched"
longMessages null null
accountBaseCurrency string base currency of the account
currentPage int Indicates the page of a multi page result
totalPages int The total number of pages to retrieve all positions
positions array Array of position objects

Position Object

Field Type Description
costbasis double the total base cost of the security [+, null]
holdingType string "LONG" or "SHORT"
lastPrice double the last traded price of the security [+]
quantity double the total quantity held. It's a double to support cash and Mutual Funds [+]
symbol string the ticker symbol or CUSIP for fixed income positions. Symbols for Class A or B shares use dot annotation (BRK.A). For Option, we follow the OCC symbology format (GWRRF 141122P00019500).
symbolClass string the type of security: BUY_WRITES, CASH, COMBO, EQUITY_OR_ETF, FIXED_INCOME, FUTURE, FX, MULTILEG, MUTUAL_FUNDS, OPTION, SPREADS, UNKNOWN
todayGainLossDollar double the total gain/loss in dollars for the day for the position [+ / - / null]
todayGainLossPercentage double the percentage gain/loss for the day for the position [+ / - / null]
totalGainLossDollar double the total gain/loss in dollars for the position [+ / - / null]
totalGainLossPercentage double the total percentage of gain/loss for the position [+ / - / null]

Position Object (FX only)

Field Type Description
holdingType string "LONG"
quantity double the total quantity held
symbol string Symbol pair (EX: 'USD/EUR')
symbolClass string "FX"
totalUnrealizedProfitAndLossBaseCurrency double Total unrealized profit and loss in base currency
totalValueBaseCurrency double Total value in base currency
totalValueUSD double Total value in USD
limitPrice double limit price
stopPrice double stop price

Broker Exceptions

Broker Field Details
E*Trade Daily GainLoss The daily gain/loss is not available, you can calculate based on last price, however this wouldn't account for intraday trades.
TradeStation Daily GainLoss The daily gain/loss is not available, you can calculate based on last price, however this wouldn't account for intraday trades.
Tradier Daily GainLoss The daily gain/loss is not available, you can calculate based on last price, however this wouldn't account for intraday trades.
Fidelity symbolClass Fidelity holds the user's cash in money market funds and also returns those funds as positions, we classify these holdings as CASH.
IB symbolClass, symbol IB currently only supports US stocks. "UNKNOWN" will be returned for these fields otherwise.
Vanguard Daily GainLoss The daily gain/loss is not available, you can calculate based on last price, however this wouldn't account for intraday trades.

Error Response

Standard error message

Trade Service

Preview Trade (Equity Only)


curl "https://ems.qa.tradingticket.com/api/v1/order/previewStockOrEtfOrder" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\",
        \"orderAction\":\"buy\",
        \"orderQuantity\":\"100\",
        \"orderSymbol\":\"GE\",
        \"orderPriceType\":\"stopMarket\",
        \"orderLimitPrice\":\"30.85\",
        \"orderStopPrice\":\"30.50\",
        \"orderExpiration\":\"gtc\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1',
        'orderAction':'buy',
        'orderQuantity':'100',
        'orderSymbol':'GE',
        'orderPriceType':'stopMarket',
        'orderLimitPrice':'30.85',
        'orderStopPrice':'30.50',
        'orderExpiration':'gtc'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/previewStockOrEtfOrder', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/previewStockOrEtfOrder")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderAction" => "buy",
        "orderQuantity" => "100",
        "orderSymbol" => "GE",
        "orderPriceType" => "stopMarket",
        "orderLimitPrice" => "30.85",
        "orderStopPrice" => "30.50",
        "orderExpiration" => "gtc"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/previewStockOrEtfOrder",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderAction" => "buy",
        "orderQuantity" => "100",
        "orderSymbol" => "GE",
        "orderPriceType" => "stopMarket",
        "orderLimitPrice" => "30.85",
        "orderStopPrice" => "30.50",
        "orderExpiration" => "gtc"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "longMessages": null,
    "orderDetails": {
        "orderSymbol": "EROS",
        "orderAction": "buy",
        "orderQuantity": 1.0,
        "orderExpiration": "day",
        "orderPrice": "market",
        "orderValueLabel": "Estimated Cost",
        "orderCommissionLabel": "Broker Fee"
        "orderMessage": "You are about to place a market order to buy EROS",
        "buyingPower": 1515.42,
        "availableCash": 1535.36,
        "estimatedOrderCommission": 0.0,
        "warnings": [{
            "message": "This trade was placed after hours. Please read the disclaimer below and acknowledge your acceptance of the terms.",
            "requiresAcknowledgement": true,
            "links": [{
                "label": "View disclaimer",
                "url": "https://www.trade.it"
            }]
        }]
    },
    "orderId": "127",
    "shortMessage": null,
    "status": "REVIEW_ORDER",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
}

Given parameters for an order, preview details and estimates of that order. A successful result is required before being able to place the order.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/previewStockOrEtfOrder

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in
orderAction string required Options: "buy", "sell", "buyToCover", "sellShort"
orderQuantity double required Number of shares to trade
orderSymbol string required Ticker symbol for the equity or ETF to display on the Trading Ticket. For Class A or B shares use dot annotation (i.e BRK.A)
orderPriceType string required Options: "market", "limit", "stopLimit", "stopMarket"
orderExpiration string required Options: "day", "gtc"
orderLimitPrice double optional Only required if orderPriceType is limit or stopLimit
orderStopPrice double optional Only required if orderPriceType is stopMarket or stopLimit

Success Response

Field Type Description
status string REVIEW_ORDER
shortMessage null null
longMessages null null
orderId string TradeIt internal orderId used in place order request
token string User's session token
warningsList array[string] DEPRECATED Upgrade to orderDetails.warnings instead. Array of strings. Passive warnings to be shown to the user
ackWarningsList array[string] DEPRECATED Upgrade to orderDetails.warnings instead. These warnings must be presented to the user and acknowledged via some sort of checkbox/switch/popup
orderDetails string Order details object

Order Details Object

Please note that as not all brokers return all fields, your code should be able to handle null values. It needs to either use 'N/A' or not display those fields back to the user at all.

Field Type Description
orderId string TradeIt internal order id, used with place order request
orderSymbol string The street symbol for the trade
orderAction string The order action used for the trade "buy", "sell", "sellShort", "buyToCover"
orderQuantity double The quantity of the security to be traded
orderExpiration string "day" or "gtc"
orderPrice string "market" for market orders, limit/stop will show the trigger price, stopLimit shows the trigger and limit
orderValueLabel string "Estimated Proceeds" or "Estimated Cost"
orderCommissionLabel string "Broker Fee" or "Broker Commission"
orderMessage string Top level readable review of order ie. "You are about to place a market order to buy EROS"
buyingPower double The current buying power of the account
longHoldings double The currently long held quantity of the security to be traded
shortHoldings double The currently short held quantity of the security to be traded
availableCash double Cash available to trade in the account
estimatedOrderCommission double Estimated broker commission for the order
estimatedOrderValue double Estimated value of the order, does not include fees
estimatedTotalValue double Estimated total cost of the order including fees
warnings array[warning] Array of warning objects that must be displayed to the user before submitting the order

Warning Object

Field Type Description
message string Text that must be displayed to the user on the preview order screen
requiresAcknowledgement boolean Indicates whether the message must be accepted by the user via a check box, switch or pop up
links array[links] Links associated with the warning that must be displayed and clickable

Link Object

Field Type Description
label string Label to display the link
url string URL to launch to the web browser. Must be able to support `https`, `tel` and `mailto` protocols

Error Response

Standard error message, short and long messages should be presented to the user so they can attempt to the fix the failed order and resubmit.

Place Trade (Equity Only)


curl "https://ems.qa.tradingticket.com/api/v1/order/placeStockOrEtfOrder" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"orderId\":\"127\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'orderId':'127'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/placeStockOrEtfOrder', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/placeStockOrEtfOrder")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "orderId" => "127"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/placeStockOrEtfOrder",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "orderId" => "127"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "broker": "Etrade",
    "confirmationMessage": "Your order message 1121944599 to buy 1 shares of GE at $25.00 has been successfully transmitted to Etrade at 24\/11\/15 2:55 PM EST.",
    "longMessages": [
    "Transmitted succesfully to Etrade"
    ],
    "orderInfo": {
        "action": "buy",
        "quantity": 1,
        "symbol": "GE",
        "price": {
            "type": "limit",
            "limitPrice": 25
        }
        "expiration": "gtc"
    },
    "orderNumber": "1121944599",
    "shortMessage": "Order Successfully Submitted",
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8"
}

After a successful order preview request, this method is used to submit the order to the broker.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/placeStockOrEtfOrder

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
orderId string required The orderId returned from the preview trade request

Success Response

Field Type Description
status string SUCCESS
broker string The broker used to execute the trade
shortMessage string "Order Successfully Submitted"
longMessages array[string] Array of messages, can be displayed to user, however normally confirmation message is more detailed
confirmationMessage string Display friendly confirmation order message
orderNumber string Order number from the broker
timestamp string The timestamp of when the order was submitted
token string The user's session token
orderInfo object Order Info Object, contains details about the order that was placed

Order Info Object

Field Type Description
symbol string The street symbol for the trade
action string The order action used for the trade "buy", "sell", "sellShort", "buyToCover"
quantity double The quantity of the security traded
expiration string "day" or "gtc"
price object Object, price information
∟ type string "market","limit","stopLimit","stopMarket"
∟ limitPrice double Limit price if limit order or stop limit order
∟ stopPrice double Stop price if stop market or stop limit order

Error Response

Standard error message, short and long messages should be shown to the user so they can correct the order and submit again.

Place Fx Trade


 curl "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder" \
 -X POST -H "Content-Type: application/json" \
 -d "{
 \"token\":\"756ed4564c9446338851d74a5a287177\",
 \"accountNumber\":\"0\",
 \"fxOrderInfoInput\": {
    \"orderType\": \"SINGLE\",
    \"orderExpiration\": \"DAY\",
    \"orderLegs\": [
        {
            \"priceType\": \"MARKET\",
            \"symbol\": "USD/CHF\",
            \"action\": \"BUY\",
            \"amount\": 1000
        }
    ]
 }
 }"

 import requests
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "MARKET",
                "symbol": "USD/CHF",
                "action": "BUY",
                "amount": 1000
            }
        ]
    }
 }
 r = requests.post('https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder', json=payload)

 require "net/http"
 require "uri"
 uri = URI.parse("https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder")
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "MARKET",
                "symbol": "USD/CHF",
                "action": "BUY",
                "amount": 1000
            }
        ]
    }
 }
 r = Net::HTTP.post_form(uri, payload)

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
 my $req = POST "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder",
 [
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "MARKET",
                "symbol": "USD/CHF",
                "action": "BUY",
                "amount": 1000
            }
        ]
    }
 ];
 my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "status": "SUCCESS",
    "longMessages": [
        "Transmitted successfully to FOREX.com"
    ],
    "confirmationMessage": "Your market order to buy USD/CHF - 1000; has been sent to your broker.",
    "timestamp": "09/01/17 5:21 PM EST",
    "broker": "FOREX.com",
    "token": "01b94b7a1d384857b421842ebec0cf77",
    "accountBaseCurrency": "USD",
    "orderInfoOutput": {
        "orderExpiration": "DAY",
        "orderType": "SINGLE",
        "orderLegs": [
            {
                "action": "BUY",
                "symbol": "USD/CHF",
                "amount": 1000,
                "rate": null,
                "priceType": "MARKET",
                "orderNumber": "283588647",
                "orderStatus": "PENDING",
                "orderStatusMessage": " buy USD/CHF - 1000 has been sent to your broker."
            }
        ]
    },
    "shortMessage": "Order Successfully Submitted"
}

Example PlaceFxOrder with Close position action - request:


 curl "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder" \
 -X POST -H "Content-Type: application/json" \
 -d "
 {
    \"token\": \"ca29c6c9077146a6b103c00e044c3a51\",
    \"accountNumber\": \"0\",
    \"fxOrderInfoInput\": {
        \"orderType\": \"SINGLE\",
        \"orderLegs\": [
            {
                \"symbol\": \"EUR/USD\",
                \"action\": \"CLOSE_POSITION\",
            }
        ]
    }
 }"

 import requests
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderLegs": [
            {
                "symbol": "EUR/USD",
                "action": "CLOSE_POSITION",
            }
        ]
    }
 }
 r = requests.post('https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder', json=payload)

 require "net/http"
 require "uri"
 uri = URI.parse("https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder")
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderLegs": [
            {
                "symbol": "EUR/USD",
                "action": "CLOSE_POSITION",
            }
        ]
    }
 }
 r = Net::HTTP.post_form(uri, payload)

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
 my $req = POST "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder",
 [
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "SINGLE",
        "orderLegs": [
            {
                "symbol": "EUR/USD",
                "action": "CLOSE_POSITION",
            }
        ]
    }
 ];
 my $resp = $ua->request($req);

Example PlaceFxOrder with Oco order type - request:


 curl "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder" \
 -X POST -H "Content-Type: application/json" \
 -d "
 {
    \"token\": \"ca29c6c9077146a6b103c00e044c3a51\",
    \"accountNumber\": \"0\",
    \"fxOrderInfoInput\": {
        \"orderType\": \"ONE_CANCELS_THE_OTHER\",
        \"orderExpiration\": \"DAY\",
        \"orderLegs\": [
            {
                \"priceType\": \"LIMIT\",
                \"symbol\": \"EUR/USD\",
                \"action\": \"BUY\",
                \"amount\": 1000,
                \"rate\": 1.04504
            },
            {
                \"priceType\": \"LIMIT\",
                \"symbol\": \"EUR/USD\",
                \"action\": \"SELL\",
                \"amount\": 1000,
                \"rate\": 1.04604
            }
        ]
    }
 }"

 import requests
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "ONE_CANCELS_THE_OTHER",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 }
 r = requests.post('https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder', json=payload)

 require "net/http"
 require "uri"
 uri = URI.parse("https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder")
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "ONE_CANCELS_THE_OTHER",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 }
 r = Net::HTTP.post_form(uri, payload)

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
 my $req = POST "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder",
 [
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "ONE_CANCELS_THE_OTHER",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 ];
 my $resp = $ua->request($req);

Example PlaceFxOrder with IfThen order type - request:


 curl "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder" \
 -X POST -H "Content-Type: application/json" \
 -d "
 {
    \"token\": \"ca29c6c9077146a6b103c00e044c3a51\",
    \"accountNumber\": \"0\",
    \"fxOrderInfoInput\": {
        \"orderType\": \"IF_THEN\",
        \"orderExpiration\": \"DAY\",
        \"orderLegs\": [
            {
                \"priceType\": \"LIMIT\",
                \"symbol\": \"EUR/USD\",
                \"action\": \"BUY\",
                \"amount\": 1000,
                \"rate\": 1.04504
            },
            {
                \"priceType\": \"LIMIT\",
                \"symbol\": \"EUR/USD\",
                \"action\": \"SELL\",
                \"amount\": 1000,
                \"rate\": 1.04604
            }
        ]
    }
 }"

 import requests
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "IF_THEN",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 }
 r = requests.post('https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder', json=payload)

 require "net/http"
 require "uri"
 uri = URI.parse("https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder")
 payload = {
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "IF_THEN",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 }
 r = Net::HTTP.post_form(uri, payload)

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
 my $req = POST "https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder",
 [
    "token":"756ed4564c9446338851d74a5a287177",
    "accountNumber":"0",
    "fxOrderInfoInput": {
        "orderType": "IF_THEN",
        "orderExpiration": "DAY",
        "orderLegs": [
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "BUY",
                "amount": 1000,
                "rate": 1.04504
            },
            {
                "priceType": "LIMIT",
                "symbol": "EUR/USD",
                "action": "SELL",
                "amount": 1000,
                "rate": 1.04604
            }
        ]
    }
 ];
 my $resp = $ua->request($req);

This method is used to place an Fx order. Note: FX does not have a review order step. Notice the v2 in the url path.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v2/order/placeFxOrder

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in
fxOrderInfoInput object required Fx Order Info Input Object, contains details about the order that is placed

Fx Order Info Input Object

Field Type Description
orderType string The type of the order. Possible values: 'SINGLE', 'ONE_CANCELS_THE_OTHER', 'IF_THEN'
orderExpiration string order expiration. Possible values: DAY, GOOD_TILL_CANCEL, 'FILL_OR_KILL', IMMEDIATE_OR_CANCEL
orderLegs array[orderLeg] Array of Order Leg Object

Note that not all brokers accept all combinations of OrderType,PriceType and Expiration. Currently only Oanda supports FILL_OR_KILL and IMMEDIATE_OR_CANCEL expiration types.

Order Leg Object

Field Type Description
priceType string The type of order. Possible values: 'MARKET, 'LIMIT', 'STOP'
symbol string Valid symbol pair
action string 'BUY' or 'SELL' or 'CLOSE_POSITION'
amount integer the quantity
rate double the limit/stop rate if any

Success Response

Field Type Description
status string SUCCESS
shortMessage string "Order Successfully Submitted"
longMessages array[string] [ "Transmitted successfully to FOREX.com" ]
token string The user's session token
broker string The broker's name
timestamp string The timestamp of when the order was submitted
confirmationMessage string Display friendly confirmation order message
orderInfoOutput Object Order Info Output Object, contains details about the order that was placed

Order Info Output Object

Field Type Description
orderType string The type of the order. Possible values: SINGLE, ONE_CANCELS_THE_OTHER, IF_THEN
orderExpiration string order expiration. Possible values: DAY, GOOD_TILL_CANCEL, FILL_OR_KILL, IMMEDIATE_OR_CANCEL
orderLegs array[orderLeg] Array of Order Leg Response Object

Order Leg Response Object

Field Type Description
priceType string The type of order. Possible values: 'MARKET, 'LIMIT', 'STOP'
symbol string Valid symbol pair
action string 'BUY' or 'SELL' or 'CLOSE_POSITION'
amount integer the quantity
rate double the limit/stop rate if any
orderNumber string Order number from the broker
orderStatus string PENDING, OPEN, FILLED, PART_FILLED, CANCELED, REJECTED, NOT_FOUND, PENDING_CANCEL, EXPIRED
orderStatusMessage string Success or error message

Error Response

Standard error message, short and long messages should be shown to the user so they can correct the order and submit again.

Get Fx Rate


 curl "https://ems.qa.tradingticket.com/api/v1/order/getFxRate" \
 -X POST -H "Content-Type: application/json" \
 -d "{
    \"token\": \"579cd94238e64f8c887642469395820e\",
    \"symbol\": \"USD/JPY\"
 }"

 import requests
 payload = {
    "token": "579cd94238e64f8c887642469395820e",
    "symbol": "USD/JPY"
 }
 r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/getFxRate', params=payload)

 require "net/http"
 require "uri"
 uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/getFxRate")
 payload = {
    "token": "579cd94238e64f8c887642469395820e",
    "symbol": "USD/JPY"
 }
 r = Net::HTTP.post_form(uri, payload)

 use HTTP::Request::Common qw(POST);
 use LWP::UserAgent;
 my $ua = LWP::UserAgent->new;
 my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/getFxRate",
 [
    "token": "579cd94238e64f8c887642469395820e",
    "symbol": "USD/JPY"
 ];
 my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
        "token" : null,
        "status" : "SUCCESS",
        "quotes" : [
            {
                "dateTime" : null,
                "symbol" : "USD\/JPY",
                "volume" : null,
                "bidPrice" : 112.544,
                "change" : null,
                "companyName" : null,
                "pctChange" : null,
                "low" : 112.507,
                "askPrice" : 112.559,
                "high" : 113.961,
                "lastPrice" : null
            }
        ],
        "longMessages" : null,
        "shortMessage" : "Quote data successfully fetched"
}

This method is used to get a FX rate for a symbol pair.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/getFxRate

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
symbol string required Symbol pair on which info is retrieved

Success Response

Field Type Description
token string The user's session token
status string SUCCESS
quotes array[object] Array of objects of quote details
∟ dateTime string null
∟ symbol string symbol of the symbol pair
∟ volume Double volume of the symbol pair
∟ bidPrice Double bid price of the symbol pair
∟ change Double null
∟ companyName string null
∟ pctChange Double null
∟ low Double low price of the symbol pair for the day
∟ askPrice Double asking price
∟ high Double high price of the symbol pair for the day
∟ lastPrice Double null
longMessages array[string] null
shortMessage string "Quote data successfully fetched"

Error Response

Standard error message, short and long messages should be shown to the user so they can correct the order and submit again.

Order Service

All Order Status


curl "https://ems.qa.tradingticket.com/api/v1/order/getAllOrderStatus" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/getAllOrderStatus', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/getAllOrderStatus")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/getAllOrderStatus",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "status": "SUCCESS",
    "longMessages": null,
    "shortMessage": "Order statuses successfully fetched",
    "accountNumber": "30049872",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "orderStatusDetailsList": [
        {
            "groupOrderType": null,
            "orderExpiration": "GOOD_FOR_DAY",
            "orderType": "EQUITY_OR_ETF",
            "groupOrderId": null,
            "orderLegs": [{
                "priceInfo": {"type": "MARKET"},
                "fills": [{
                    "timestamp": "03/03/10 6:55 PM EST",
                    "price": 24.84,
                    "quantity": 1
                }],
                "symbol": "CSCO",
                "orderedQuantity": 1,
                "filledQuantity": 1,
                "action": "SELL"
            }],
            "orderNumber": "208",
            "orderStatus": "FILLED",
            "groupOrders": []
        },
        {
            "groupOrderType": "ONE_TRIGGERS_ALL",
            "orderExpiration": null,
            "orderType": null,
            "groupOrderId": "1350",
            "orderLegs": [],
            "orderNumber": 1,
            "orderStatus": "GROUP_CLOSED",
            "groupOrders": [{
                "groupOrderType": null,
                "orderExpiration": "GOOD_FOR_DAY",
                "orderType": "EQUITY_OR_ETF",
                "groupOrderId": null,
                "orderLegs": [{
                    "priceInfo": {"type": "MARKET"},
                    "fills": [{
                        "timestamp": "17/03/11 12:50 PM EDT",
                        "price": 0.1,
                        "quantity": 1
                    }],
                "orderNumber": "1",
                "orderStatus": "FILLED",
                "groupOrders": [],
                "symbol": "MSFT",
                "orderedQuantity": 1,
                "filledQuantity": 1,
                "action": "BUY"
            }]
        },
        {
            "groupOrderType": null,
            "orderExpiration": "GOOD_FOR_DAY",
            "orderType": "EQUITY_OR_ETF",
            "groupOrderId": null,
            "orderLegs": [{
                "priceInfo": {"type": "MARKET"},
                "fills": [{
                    "timestamp": "17/03/11 12:51 PM EDT",
                    "price": 7.39,
                    "quantity": 1
                }],
                "symbol": "CSCO",
                "orderedQuantity": 1,
                "filledQuantity": 1,
                "action": "BUY"
            }],
            "orderNumber": "2",
            "orderStatus": "FILLED",
            "groupOrders": []
        }
    ]
}

Given an account number: canceled, completed, and rejected orders for the day, and all open orders are returned.

IB provides only open orders passed via the API.

Please note that DriveWealth only returns pending orders.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/getAllOrderStatus

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to get order status

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests.
shortMessage string "Order statuses successfully fetched"
longMessages null null
accountNumber string The account number that was passed in
orderStatusDetailsList array[object] Array of order status objects for the last 60 days

Order Status Object

Field Type Description
orderNumber string The broker assigned order number
orderExpiration string DAY, GTC, GOOD_THROUGH_DATE, FILL_OR_KILL, IMMEDIATE_OR_CANCEL, UNKNOWN
orderType string OPTION, EQUITY_OR_ETF, BUY_WRITES, SPREADS, COMBO, MULTILEG, MUTUAL_FUNDS, FIXED_INCOME, CASH, UNKNOWN, FX
orderStatus string PENDING, OPEN, FILLED, PART_FILLED, CANCELED, REJECTED, NOT_FOUND, PENDING_CANCEL, EXPIRED, GROUP_CLOSED, GROUP_OPEN
orderLegs array[object] Array of objects of each part of the order
∟ symbol string Street symbol for the order. Symbols for Class A or B shares use dot annotation (BRK.A). For Option, we follow the OCC symbology format (GWRRF 141122P00019500).
∟ orderedQuantity double The total quantity ordered [+ / -]
∟ filledQuantity double The total quantity filled so far [+ / -]
∟ action string BUY, BUY_OPEN, BUY_CLOSE, BUY_TO_COVER, SELL, SELL_OPEN, SELL_CLOSE, SELL_SHORT, UNKNOWN
∟ priceInfo object Price Info Object from the broker, representing the price and order type
∟ fills array[object] Array of fill objects describing how the order was filled
groupOrderType string ONE_TRIGGERS_OCO, ONE_TRIGGERS_ALL, ONE_CANCELS_ALL, UNKNOWN
groupOrders array[object] Array of order status objects if the order is a group Order
groupOrderId string The broker's group order id. Note only some brokers will populate this field

Order Status Price Info Object

Field Type Description
type string MARKET, LIMIT, STOP, STOP_LIMIT, NET_DEBIT, TRAILING_STOP_DOLLAR, TRAILING_STOP_PRCT, UNKNOWN
limitPrice double The limit price
stopPrice double The stop price
trailPrice double The trail price (in dollars if the type is TRAILING_STOP_DOLLAR, in percentage if type is TRAILING_STOP_PRCT)
triggerPrice double Deprecated. Will be removed in the next version

Order Status Fill Object

Field Type Description
timestamp string String, timestamp of the fill
price double Price of the fill
quantity double Quantity that was filled

Single Order Status


curl "https://ems.qa.tradingticket.com/api/v1/order/getSingleOrderStatus" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\",
        \"orderNumber\":\"208\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1',
        'orderNumber':'208'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/getSingleOrderStatus', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/getSingleOrderStatus")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderNumber" => "208"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/getSingleOrderStatus",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderNumber" => "208"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "status": "SUCCESS",
    "longMessages": null,
    "shortMessage": "Order statuses successfully fetched",
    "accountNumber": "30049872",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "orderStatusDetailsList": [{
        "groupOrderType": null,
        "orderExpiration": "GOOD_FOR_DAY",
        "orderType": "EQUITY_OR_ETF",
        "groupOrderId": null,
        "orderLegs": [{
            "priceInfo": {"type": "MARKET"},
            "fills": [{
                "timestamp": "03/03/10 6:55 PM EST",
                "price": 24.84,
                "quantity": 1
            }],
            "symbol": "CSCO",
            "orderedQuantity": 1,
            "filledQuantity": 1,
            "action": "SELL"
        }],
        "orderNumber": "208",
        "orderStatus": "FILLED",
        "groupOrders": []
    }]
}

Given an account number and order number, return the order status.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/getSingleOrderStatus

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in
orderNumber string required Order number

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests.
shortMessage string "Order statuses successfully fetched"
longMessages null null
accountNumber string The account number that was passed in
orderStatusDetailsList array[object] Array of order status object containing the order requested

Error Response

Standard error message

Cancel Order


curl "https://ems.qa.tradingticket.com/api/v1/order/cancelOrder" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\",
        \"orderNumber\":\"2bcdef234\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1', 'orderNumber':'2bcdef234'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/order/cancelOrder', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/order/cancelOrder")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderNumber" => "2bcdef234"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/order/cancelOrder",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1",
        "orderNumber" => "2bcdef234"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "status": "SUCCESS",
    "longMessages": null,
    "shortMessage": "Order statuses successfully fetched",
    "accountNumber": "30049872",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "orderStatusDetailsList": [{
        "groupOrderType": null,
        "orderExpiration": "GOOD_FOR_DAY",
        "orderType": "EQUITY_OR_ETF",
        "groupOrderId": null,
        "orderLegs": [{
            "priceInfo": {"type": "MARKET"},
            "fills": [],
            "symbol": "CSCO",
            "orderedQuantity": 1,
            "filledQuantity": 0,
            "action": "SELL"
        }],
        "orderNumber": "208",
        "orderStatus": "PENDING_CANCEL",
        "groupOrders": []
    }]
}

Given an account number and order number, return the order status after cancelling

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/order/cancelOrder

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to place the trade in
orderNumber string required Order number

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests.
shortMessage string "Order statuses successfully fetched"
longMessages null null
accountNumber string The account number that was passed in
orderStatusDetailsList array[object] Array of order status objects

Error Response

Standard error message

Transaction Service

All Transactions History


curl "https://ems.qa.tradingticket.com/api/v1/account/getAllTransactionsHistory" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"token\":\"c8e6c20b3b7843028332e1e522cb89b8\",
        \"accountNumber\":\"brkAcct1\"
}"

import requests
payload = {
        'token':'c8e6c20b3b7843028332e1e522cb89b8',
        'accountNumber':'brkAcct1'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/account/getAllTransactionsHistory', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/account/getAllTransactionsHistory")
payload = {
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/account/getAllTransactionsHistory",
[
        "token" => "c8e6c20b3b7843028332e1e522cb89b8",
        "accountNumber" => "brkAcct1"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "accountNumber": "A0424940",
    "longMessages": null,
    "shortMessage": "Transaction history successfully fetched",
    "status": "SUCCESS",
    "token": "c8e6c20b3b7843028332e1e522cb89b8",
    "numberOfDaysHistory": 60,
    "transactionHistoryDetailsList": [
        {
            "date": "01/26/2017",
            "description": "BA dividend on 25 shares",
            "price": null,
            "symbol": "BA",
            "commission": null,
            "amount": 142.0,
            "action": "CREDIT",
            "type": "DIVIDEND",
            "id": null,
            "quantity": 25.0
        },
        {
            "date": "03/11/2017",
            "description": "2:1 split VOD",
            "price": null,
            "symbol": "VOD",
            "commission": null,
            "amount": null,
            "action": "BUY",
            "type": "CORP_ACTION",
            "id": null,
            "quantity": 50.0
        },
        {
            "date": "04/10/2017",
            "description": "Buy 25 shares BA",
            "price": 129.82,
            "symbol": "BA",
            "commission": 0.0,
            "amount": 3245.45,
            "action": "BUY",
            "type": "TRADE",
            "id": null,
            "quantity": 25.0
        }
    ]
}

Given an account number all transactions, for the last 60 days are returned.

TradeStation only provides the last 14 days order history. Corporate actions and movement are not reported.

IB provides only the last 6 days order history passed via the API.

Fidelity uses a different symbology in their transactions where class shares, such as BRK.B, will be shown with no delineation i.e. BRKB.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/account/getAllTransactionsHistory

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
token string required Token from auth call
accountNumber string required Account number to get transactions history

Success Response

Field Type Description
status string SUCCESS
token string Token used for all subsequent user session requests.
shortMessage string "Transaction history successfully fetched"
longMessages null null
accountNumber string The account number that was passed in
numberOfDaysHistory int The number of days history returned
transactionHistoryDetailsList array[object] Array of transaction history objects

Transaction History Object

Field Type Description
date date Date of the transaction format: MM/dd/yyyy
description string from the broker, description of the transaction
price double Price of one share [+ / null]
symbol string Symbol if it is a trade. Symbols for Class A or B shares use dot annotation (BRK.A). For Option, we follow the OCC symbology format (GWRRF 141122P00019500).
commission double Broker commission if exists or null
amount double The amount of the transaction [+ / - / null]
action string BUY, SELL, COVER, SHORT, DEBIT, CREDIT, UNKNOWN
type string TRADE, DIVIDEND, FEE, INTEREST, REINVESTMENT, TRANSFER, JOURNALED, CORP_ACTION, CONVERSION, UNKNOWN
id string (Used for Interactive Brokers) or null
quantity double Number of shares [+ / - / null]

Preference Service

Get Broker List


curl "https://ems.qa.tradingticket.com/api/v1/preference/getBrokerList" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"apiKey\":\"tradeit-test-api-key\"
}"

import requests
payload = {
        'apiKey':'tradeit-test-api-key'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/preference/getBrokerList', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/preference/getBrokerList")
payload = {
        "apiKey" => "tradeit-test-api-key"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/preference/getBrokerList",
[
        "apiKey" => "tradeit-test-api-key"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "brokerList": [
        {
            "shortName": "Fidelity",
            "longName": "Fidelity",
            "userName": "Username"
        },
        {
            "shortName": "Etrade",
            "longName": "E*Trade",
            "userName": "User Id"
        },
        {
            "shortName": "Dummy",
            "longName": "Dummy Broker",
            "userName": "Username"
        },
        {
            "shortName": "OptionsHouse",
            "longName": "OptionsHouse",
            "userName": "User Id"
        },
        {
            "shortName": "Scottrade",
            "longName": "Scottrade",
            "userName": "Account #"
        },
        {
            "shortName": "TradeStation",
            "longName": "TradeStation",
            "userName": "Username"
        },
        {
            "shortName": "Tradier",
            "longName": "Tradier Brokerage",
            "userName": "Username"
        },
        {
            "shortName": "IB",
            "longName": "Interactive Brokers",
            "userName": "Username"
        },
        {
            "shortName": "TradeKing",
            "longName": "TradeKing",
            "userName": "Username"
        }
    ],
    "longMessages": null,
    "shortMessage": "Successfully fetched broker list",
    "status": "SUCCESS",
    "token": null
}

Retrieve the most up-to-date list of supported brokers. TradeIt can also configure a custom configuration file to exclude any brokers you don't wish to use, as well as customizing the order in which the brokers appear.

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/preference/getBrokerList

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
apiKey string required Your issued API key

Success Response

Field Type Description
status string SUCCESS
token null null
shortMessage string "Successfully fetched broker list"
longMessages null null
brokerList array List of available brokers
∟ shortName string The broker as it should be passed into the oAuthLink method
∟ longName string The broker name it should be displayed to the end user
∟ userName string The label to use for username field, i.e. username, email, account#

Error Response

Standard error message

Market Data Service

Symbol Lookup


curl "https://ems.qa.tradingticket.com/api/v1/marketdata/symbolLookup" \
-X POST -H "Content-Type: application/json" \
-d "{
        \"query\":\"aa\"
}"

import requests
payload = {
        'query':'aa'
}
r = requests.post('https://ems.qa.tradingticket.com/api/v1/marketdata/symbolLookup', params=payload)

require "net/http"
require "uri"
uri = URI.parse("https://ems.qa.tradingticket.com/api/v1/marketdata/symbolLookup")
payload = {
        "query" => "aa"
}
r = Net::HTTP.post_form(uri, payload)

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = POST "https://ems.qa.tradingticket.com/api/v1/marketdata/symbolLookup",
[
        "query" => "aa"
];
my $resp = $ua->request($req);

The above command returns JSON structured like this:


{
    "longMessages": null,
    "query": "aa",
    "results": [
        {
            "name": "Alcoa Inc",
            "symbol": "AA"
        },
        {
            "name": "AAC Holdings Inc",
            "symbol": "AAC"
        },
        {
            "name": "Aaron's Inc",
            "symbol": "AAN"
        },
        {
            "name": "Advance Auto Parts Inc",
            "symbol": "AAP"
        },
        {
            "name": "American Airlines Group Inc",
            "symbol": "AAL"
        },
        {
            "name": "American Assets Trust Inc",
            "symbol": "AAT"
        },
        {
            "name": "Aaon Inc",
            "symbol": "AAON"
        },
        {
            "name": "Apple Inc",
            "symbol": "AAPL"
        },
        {
            "name": "Applied Optoelectronics Inc",
            "symbol": "AAOI"
        }
    ],
    "shortMessage": "Symbol lookup successfully fetched",
    "status": "SUCCESS",
    "token": null
}

Given a query and partial symbol, return a list of companies/symbols that may match the desired security

HTTP Request

POST https://ems.qa.tradingticket.com/api/v1/marketdata/symbolLookup

Environment: Testing

While this is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

Post Parameters

Field Type Status Details
query string required The query/partial symbol to match against

Success Response

Field Type Description
status string SUCCESS
token null null
shortMessage string "Symbol lookup successfully fetched"
longMessages null null
query string The query that was passed in
results array List of possible matches
∟ name string The name of the company or fund
∟ symbol string The symbol for the company or fund

Error Response

Standard error message

Error Handling


{
"code":200,
"longMessages": [
        "(00906A) The limit price you have entered is too far away from the Ask Price for this security. Please use the following guidelines when entering your limit price: For buy limit orders in which your limit price is below the current Ask Price, your limit price can be no more than 50% away from the Ask Price. "
],
"shortMessage": "Could Not Review Your Order",
"status": "ERROR",
"token": "daeb18efb16c4c5fa798c25e95fcd54b"
}

All requests can potentially return our standard error message. We provide a table of error codes and meanings below.
For the few methods that specify so, we also return a short and long message that should be presented to the user.
Generally, the short message can be used as title and the long messages as the body.

Field Type Details
code int See table below for code meanings
longMessages array[string] An array of strings to be presented to the user.
shortMessage string The general error message
status string Will always be ERROR
token string User's session token
Code Meaning
100 System Error
101 Concurrent Authentication Error - Triggered when we are currently processing a login for a user and second request for the same user comes in.
200 Broker Execution Error - User should modify the input for the trade request
300 Broker Authentication Error - Authentication info is incorrect or the user may have changed their login information and the oAuth token is no longer valid.
301 Too Many Login Attempts Error - After 3 invalid login attempts in a row, the user IP will be blocked from TradeIt servers for a duration of 5 minutes.
400 Broker Account Error - User credentials are valid, but needs to take action on the brokers site (ie. sign exchange agreement, sign margin agreement)
500 Params Error - Publisher should check the parameters being passed in
600 Session Expired - Publisher should call authenticate again in order to generate a new session token
700 Token invalid or expired - Publisher should call oAuthUpdate in order to refresh the token
800 Broker Account not available - The broker account is being activated. User will have to authenticate in one or two business day

Testing

TradeIt Testing Environment is https://ems.qa.tradingticket.com

While it is TradeIt's testing environment, all broker connections are made to the LIVE broker environments.

In order to test the flow without executing a trade, use the Dummy Broker.

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

username response
dummy no errors
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
dummyOptionLong returns response with multiple options for the security question answer (answer is option1)
dummyDelay used to reproduce the IB account activation in progress: once you link dummyDelay, the error 800 will be returned for ten minutes
dummy600 expires sessionToken after 4 requests
dummy700 expires userToken after re-authenticating a sessionToken, which expires after 4 requests
dummyAction returns 400 Broker Account Error (Your broker needs more information before you can trade. Please visit your broker website for details.) on authentication
dummyNoAccount returns 400 Broker Account Error (Your broker requires an active account before you can trade. It's possible your funds have yet to clear or an agreement needs to be signed. Please visit your broker website for more information.) on authentication
dummyQuote returns 400 Broker Account Error (Your broker requires you to sign or update your Real-Time quote agreements before you can trade. Please visit your broker website for more information.) on authentication
dummyFailTrade returns 200 Broker Execution Error (Could not place trade) for each trade request with quantity above 10
dummyRetirement returns 400 Broker Account Error (You cannot trade this kind of security in a retirement account. Please visit your broker to open a brokerage account.) on authentication
any other ID that is not dummy returns error response with authentication error

When username is dummy , dummyMultiple or dummySecurity:

Order Size Returns
quantity is below 50 returns review response with no warning messages
quantity is between 50 and 99 returns review response with warnings and ack messages
quantity is 100 and up returns error response
+ +

For all dummy brokers:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
actionwhenreturns
Authenticationpassword is NOT pass or expires-after-(digit)300 Broker Authentication Error (Check your username and password and try again.)
Cancel orderorderNumber is invalidOrderNumber200 Broker Execution Error (Invalid order number)
Get single orderorderNumber is invalidOrderNumber200 Broker Execution Error (Invalid order number)
Review orderorderInfo.symbol is INVALIDSYMBOL200 Broker Execution Error (Invalid symbol)

Third Party Libraries

Stockflare

Stockflare helps you find new trade ideas with a five star stock rating system.

Github