NAV Navbar
cURL MQL5
  • Introduction
  • Authentication
  • Application
  • Accounts
  • Trading
  • Market data
  • Errors
  • Appendix
  • Introduction

    We believe that modern financial mechanics is a problem of IT and code, not finance. We seek for elegance of integrations by eliminating the unnecessary complexity of financial infrastructure. Our API calls are based on REST concepts and can be made with any language that supports standard HTTP. Trading is made as easy as possible, just plain JSON and POST.

    Authentication

    All requests are authenticated with tokens issued by common OAuth 2.0 compatible flow. In order to use the API, the application should be registered with us first to get the client_id and client_secret. Please contact us at support@just2trade.com in order to do that. We support two authorization flows suitable for different scenarios. The password type is short and simple to be used by users trading directly on their account. The authorization_code type is longer and more complicated but allows third parties to get authorized access to client accounts. For security reasons, the third party applications will need to add one or more callback urls to the whitelist on our side first.

    Successful authentication issues a security token that needs to be specified with every authenticated request in the Authentication HTTP header: Authentication: Bearer {token goes here}

    Create username

    A user must have an identity with Just2Trade in order to use Just2Trade services. The identity is authenticated by username and password created by this endpoint. This does not open a trading account.

    curl
        -X POST
        --header 'Accept: application/json'
        --header 'Authorization: Basic {auth}'
        --header 'Content-Type: application/json'
        -d '{ \ 
            "auth": "YXBwOm15X3NlY3JldA==", \ 
            "email": "myemail@domain.com", \ 
            "first_name": "John", \ 
            "last_name": "Doe", \ 
            "username": john.doe.login, \ 
            "password": "passwordhere"
            }' 'https://auth.just2trade.com/api/register'
    
       
    auth Required. This is base 64-encoded string of {client_id}:{client_secret}. For example, if client_id is app and client_secret is my_secret then the auth string is the base64-encoded app:my_secret which is YXBwOm15X3NlY3JldA==
    email Required.
    first_name Required.
    last_name Required.
    username Required.
    password Required. Password complexity requirements are enforced

    Returns HTTP 200 OK if the identity is successfully created, HTTP 400 Bad Request with human readable error message in case of any validation errors

    Password Flow

    Create an access token by logging in with a valid username and password. The access token is issued for 24 hours by default and prolonged with every method call. In the most common scenario this is the first method to be called at the application start. The POST parameters are:

    curl
        -X POST
        --header 'Accept: application/json'
        --header 'Content-Type: application/x-www-form-urlencoded'
        -d 'grant_type=password&client_id={client_id}&client_secret={your_client_secret}&username={username}&password={password}'
        'https://auth.just2trade.com/connect/token'
    

    Response example

    {
      "scope": "email profile",
      "token_type": "Bearer",
      "access_token": "MjAwOTg1OWUtZTUwMy00YzY4LWEyZWQtODU0N2NkZTJiNDdlfDIwMTcxMDA3MTkyNDQzfHRlc3R8U2VyZ2V5fE1pbmtvdg==",
      "expires_in": 86400
    }
    
       
    grant_type Required. This is the OAuth authorization flow to use. password in this case.
    client_id Required. The client id issued to the service
    client_secret Required. The client secret issued to the service
    username Required with password grant type.
    password Required with password grant type.

    Response

    name value
    access_token the access token
    scope the scopes this token grants access to
    token_type Bearer means that the access token should be put to the Authorization header of every web request
    expires_in the expiration lifetime in seconds

    Code Flow - Authorize

    The user browser should be directed to the following authentication url. The user will see the Just2Trade login form to input the credentials.

    curl
        -X GET
        'https://auth.just2trade.com/connect/authorize?response_type=code&client_id={{your_client_id}}&redirect_uri={{your_redirect_uri}}'
    

    After successful authentication the user is redirected to redirect_uri with HTTP code 302 and the authorization code:

        302 Found
        Location: {{your_redirect_uri}}?code={{code}}
    

    Request

    parameter description
    response_type Required. This is the OAuth authorization flow to use. In this case this is code.
    client_id Required. The client id issued to the service
    redirect_uri Required. The url to redirect the user after successful authentication. For security reasons, we do not allow just any url, we require this url to be registered first

    Code Flow - Access token

    The next step is to exchange the authorization code to an access token which will be used to authenticate all API requests. By default the access token is issued for 24 hours and is prolonged with every usage.

    curl
        -X POST
        --header 'Accept: application/json'
        --header 'Content-Type: application/x-www-form-urlencoded'
        -d 'grant_type=authorization_code&code={code}&client_id={client_id}&client_secret={your_client_secret}&redirect_uri={your_redirect_uri}'
        'https://auth.just2trade.com/connect/token'
    

    Response example

    {
      "scope": "email profile",
      "token_type": "Bearer",
      "access_token": "MjAwOTg1OWUtZTUwMy00YzY4LWEyZWQtODU0N2NkZTJiNDdlfDIwMTcxMDA3MTkyNDQzfHRlc3R8U2VyZ2V5fE1pbmtvdg==",
      "expires_in": 86400
    }
    

    Request

    parameter description
    grant_type Required. This is the OAuth authorization flow to use. authorization_code in this case.
    client_id Required. The client id issued to the service
    client_secret Required. The client secret issued to the service
    code Required with authorization_code grant type. The authorization code received at the previous step. Please note the authorization code lifetime is short (5 minutes) so please be sure to exchange the code to a token immediately.
    redirect_uri Required with authorization_code grant type. The same url as on the previous request authorization step.

    Response

    name value
    access_token the access token
    scope the scopes this token grants access to
    token_type Bearer means that the access token should be put to the Authorization header of every web request
    expires_in the expiration lifetime in seconds

    User profile

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/userinfo'
    

    Response example

    {
        "id": "8f1e7eba-0000-0000-0000-2b67c9af83a5",
        "login": "login",
        "first_name" : "John",
        "last_name" : "Smith",
        "email": "login@email.com",
        "domestic": true,
        "accounts": [
            {
                "account_number": "12345678@vision",
                "account_name": "John Doe Individual",
                "trade_platform": "ETNA"
            },
            {
                "account_number": "11111111@cor",
                "account_name": "John Doe and Jane Doe Joint",
                "trade_platform": "ETNA"
            }
        ],
        "applications": [
            {
                "account_number": "",
                "status": "process"
            }
        ]
    }
    

    This retrieves the basic profile information including new accounts application status and the list of existing account numbers.

    Application

    Apply for new account

    curl
        -X POST
        --header 'Content-Type: application/json'
        --header 'Authorization: Bearer {token here}'
        -d 'json goes here' 'https://api.just2trade.com/application'
    

    Request example

    {
        "personal":
        {
            "first_name": "John",
            "middle_name": "A",
            "last_name": "Doe",
            "residential_address":
            {
                "street": "One Penn Plaza suite 1614",
                "city": "New York",
                "state": "NY",
                "zip": "10119",
                "country": "US"
            },
            "mobile_phone_country": "+1",
            "mobile_phone": "5551234567",
            "email_address": "email@email.com",
            "marital_status": "married",
            "mothers_maiden_name": "Doe",
            "date_of_birth": "12/01/1985",
            "ssn": "111-22-3333",
            "citizenship_country": "US",
            "id_type": "us_driving_license",
            "id_number": "75 123123"
        },
        "employment":
        {
            "status": "employed",
            "job_title": "Seaport Crane Operator",
            "company": "Port Authority",
            "nature": "Logistics",
            "company_years": 8,
            "employer_address":
            {
                "street": "89 South Street",
                "city": "New York",
                "state": "NY",
                "zip": "10038",
                "country": "US"           
            }
        },
        "financial":
        {
            "number_of_dependents": 2,
            "annual_income": "$75,000 - $199,999",
            "net_worth": "$150,000 - $499,999",
            "liquid_net_worth": "$50,000 - $149,999",
            "tax_bracket": "31 - 35%",
            "funding_source":
            [
                "earnings", "home_equity_line_of_credit"
            ],
            "funding_source_other": "line of credit"
        },
        "investment":
        {
            "knowledge": "limited",
            "risk_tolerance": "moderate",
            "liquidity_needs": "Important (1 - 5 Years)",
            "objectives":
            [
                "capital_appreciation", "preservation_of_capital", "income", "speculation"
            ],
            "time_horizon": "1 to 5 Years",
            "experience":
            {
                "stocks": "1 to 5 Years",
                "options": "1 to 5 Years",
                "short_sales": "1 to 5 Years",
                "mutual_funds": "1 to 5 Years",
                "margin": "1 to 5 Years"
            }
        },
        "affiliations":
        {
            "employee_of_exchange": false,
            "employee_of_brokerdealer": false,
            "employee_of_regulator": false,
            "employee_of_advisor": false,
            "person_to_influence_securities": false,
            "person_to_contribute_major_capital": false,
            "senior_officer_of_financial_institution": false,
            "senior_officer_of_public_company": false,
            "director_of_public_company": false,
            "major_shareholder_of_public_company": false,
            "senior_officer_foreign": false,
            "relationship_to_another_account": false,
            "relationship_to_another_entity": false
        },
        "legal_issues":
        {
            "bankruptcy": false,
            "legal_dispute": false,
            "unpaid_balance": true,
            "comment": "lannisters always pay their debts"
        },
        "agreements": {
            "just2trade": true,
            "vision": true,
            "vision_margin": true,
            "nyse": true,
            "nasdaq": true,
            "extended_hours": true,
            "otc": true
        },
        "documents":
        [
            {
                "type": "identity",
                "file": "scan.jpg",
                "content": " -- --- -- - -- base64 content goes here - - -- - - -- "
            }
        ]
    }
    

    Request

    Field Description
    personal Personal information section according to the structure described below
    employment Employment information section
    financial General financial information
    investment Investment experience questionnaire
    affiliatons Affiliations information required by law to prevent market manipulation. Set to true if you or any immediate family member (spouse, brother, sister, parent, child, mother-in-law, sister-in-law, brother-in-law, daugher-in-law, son-in-law), or other person who supports you or who you support to a material extent, or an additional account holder, is a person described here.
    legal_issues Legal issues background
    agreements Agreements and signatures. Set to true if the corresponding document is read and agreed to.
    documents Documents binaries encoded as base64
    Personal Information  
    first_name First name as stated on the ID document
    middle_name Middle name if applicable
    last_name Last name as stated on the ID document
    residential_address Permanent address in the format of the Address Structure described below
    mobile_phone_country Mobile phone country code, a mandatory plus sign and digits. For example, for US it is +1
    mobile_phone Mobile Phone, digits only, no dashes or brackets
    email_address Email Address
    marital_status Marital status, one of the following: single, married, divorced
    mothers_maiden_name Mother's maiden name to be used as a security question
    date_of_birth Date of birth, US format mm/dd/yyyy
    ssn SSN or ITIN, required for US residents, digits only
    citizenship_country Country, two-symbol ISO code
    id_type The type of ID document, the following values are supported: passport, us_state_id, us_driving_license, us_green_card
    id_number The number of ID document
    Employment  
    status Employment status, one of the following values: employed, self_employed, retired, not_employed, student
    job_title Job title
    company Company name
    company_years Years with this company
    nature Nature of the business
    employer_address The address in the format of the Address Structure described below
    Address  
    street Street address including apartment number if applicable
    city City
    state State, two-symbol ISO code, required for United States
    zip Postal code
    country Country, two-symbol ISO code
    Financial  
    number_of_dependents A qualifying child or relative for whom you can claim a tax exemption, including yourself.
    annual_income Annual income, one of the following values Under $25,000, $25,000 - $74,999, $75,000 - $199,999, $200,000 - $499,999, $500,000 - $999,999, $1,000,000+
    net_worth One of the following values Under $50,000, $50,000 - $149,999, $150,000 - $499,999, $500,000 - $999,999, $1,000,000 - $4,999,999, Over $5,000,000
    liquid_net_worth One of the following values Under $50,000, $50,000 - $149,999, $150,000 - $499,999, $500,000 - $999,999, $1,000,000 - $4,999,999, Over $5,000,000
    tax_bracket One of the following values 0 - 15%, 16 - 25%, 26 - 30%, 31 - 35%, Over 35%
    funding_source An array with the following available values earnings, pension, gift, sale_of_business_or_property, insurance, inhertiance, social_security_benefits, home_equity_line_of_credit, other
    funding_source_other Please explain if any other funding sources
    Investment  
    objectives An array with all the following 4 values ordered by priority: capital_appreciation, preservation_of_capital, income, speculation
    risk_tolerance One of the following values low, moderate, aggressive, speculative
    liquidity_needs One of the following values Very Important (Less Than 1 Year), Important (1 - 5 Years), Somewhat Important (5 - 15 Years), Does Not Matter (Over 15 Years)
    time_horizon One of the following values Less than 1 Year, 1 to 5 Years, 5 to 10 Years, 10 to 15 Years, Over 15 Years
    knowledge limited, good, excellent
    experience An object that describes experience in different investment areas. The following properties are available: stocks, option, margin, short_sales, mutual_funds. Each property can have one of the following values: None, Less than 1 Year, 1 to 5 Years, 6 to 10 Years, Over 10 Years.
    Affiliations  
    employee_of_exchange A member of or employee of any securities, options or commodities Exchange or other Self-Regulatory Organization including a registered securities associations, registered clearing organization or the Municipal Securities Rulemaking Board
    employee_of_brokerdealer An employee of a broker/dealer or other member of the FINRA
    employee_of_regulator An employee of a state or federal securities regulator
    employee_of_advisor An employee of an investment advisor
    person_to_influence_securities A person in a position to influence or whose activities directly or indirectly involve, or are related to, the function of buying or selling securities
    person_to_contribute_major_capital A person who has contributed to the equity or capital of a broker/dealer, directly or indirectly, in an amount that exceeds 10% of the broker/dealer's equity or capital
    senior_officer_of_financial_institution A senior officer of a bank, savings, loan institution, insurance company, investment advisory firm or any other financial institution
    senior_officer_of_public_company An executive officer of a public company, whether US or non-US
    director_of_public_company A director of a public company, whether US or non-US
    major_shareholder_of_public_company A 10% shareholder of a public company, whether US or non-US
    senior_officer_foreign A current or former senior official of a foreign government or political party, or senior executive of a foreign goverment-owned commercial enterprise, or a family member or close associate of such person
    relationship_to_another_account Have relationship with another account at Just2Trade that you control, have a beneficial interest in or with which you coordinate trading
    relationship_to_another_entity Have relationship with entity which has an account at Just2Trade
    Legal Issues  
    bankruptcy Have you ever been the subject to a bankruptcy proceeding, receivership, or similar action
    legal_dispute Have you ever been in a legal dispute, arbitration, or reparations action related to a securities or commodities account
    unpaid_balance Have you ever closed an account with an unpaid balance at a securities or commodity firm
    comment Mandatory comment if any of the above is true
    Agreements  
    just2trade Just2Trade Market Agreement
    vision Vision Account Agreement
    vision_margin Vision Margin Supplement
    nyse NYSE Market Data Agreement
    nasdaq NASDAQ Market Data Agreement
    extended_hours Extended Hours Trading Risk Agreement
    otc OTC Market Data Agreement
    Documents  
    type Type of the document, only one type is supported: identity
    file File name of the document, should include extenstion. For example, scan.jpg
    content Base-64 encoded content of the file

    Accounts

    Get accounts balances

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/accounts'
    

    Response example

    [
        {
            "account_number": "12345678@vision",
            "trade_platform": "ETNA",
            "margin_type": "marginx2",
            "restriction": "none",
            "daytrades_count": 0,
            "account_value_total": 9880.6806,
            "cash": 5283.44,
            "day_trading_buying_power": 0,
            "margin_buying_power": 15243,
            "non_margin_buying_power": 7621.5,
            "position_market_value": 4597.2406,
            "unsettled_cash": 0,
            "cash_to_withdraw": 7621.5
        },
        {
            "account_number": "11111111@cor",
            "trade_platform": "ETNA",
            "margin_type": "daytrader",
            "restriction": "restricted",
            "restriction_reason": "please fund the account",
            "daytrades_count": 0,
            "account_value_total": 0,
            "cash": 0,
            "day_trading_buying_power": 0,
            "margin_buying_power": 0,
            "non_margin_buying_power": 0,
            "position_market_value": 0,
            "unsettled_cash": 0,
            "cash_to_withdraw": 0
        }
    ]
    

    Get balance information for all user accounts as an array of the following json structures:

    name description
    account_number the account number
    trade_platform the trading platform this account is traded on
    margin_type the margin type, possible values are cash, marginx1, marginx2, daytrader
    restriction restriction level effective on the account, possible values are none - no restrictions, restricted - opening transactions are not allowed but closing orders are accepted, disabled - no activity is allowed in the account, closed - the account is closed
    restriction_reason optional description explaining why the account is restricted
    daytrades_count day trades counter
    account_value_total total account liquidation value
    cash account debit balance when negative, credit balance when positive
    day_trading_buying_power day trading buying power for marginable securities
    margin_buying_power the buying power for marginable securities
    non_margin_buying_power the buying power for non-marginable securities
    position_market_value sum of all positions current market values. The value is negative for short positions
    unsettled_cash unsettled cash for cash accounts
    cash_to_withdraw cash available to withdraw from the account

    Get account positions

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/accounts/{account_number}/positions?date={date}'
    
    [
        {
            "symbol": "KEYS",
            "quantity": 90,
            "average_open_price": 26.061,
            "current_price": 42.17,
            "security_type": "common_stock"
        },
        {
            "symbol": "GRNH",
            "quantity": 1,
            "average_open_price": 0.0975,
            "current_price": 0.040600000000000004,
            "security_type": "common_stock"
        },
        {
            "symbol": "TWTR",
            "quantity": 13,
            "average_open_price": 17.74043,
            "current_price": 17.38,
            "security_type": "common_stock"
        },
        {
            "symbol": "RAD",
            "quantity": 1,
            "average_open_price": 2.37,
            "current_price": 1.87,
            "security_type": "common_stock"
        }
    ]
    

    Query parameters are:

    name description
    account_number Required. The account number
    date Optional. Date in the format of yyyy-MM-dd. If not specified, the method returns current intraday positions

    Returns an array of the following json structures:

    name description
    symbol security symbol
    quantity number of shares or option contracts
    average_open_price average historical cost basis
    current_price current price
    security_type the type of security, the most common values are common_stock, preferred_stock, option

    Get account trades

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/accounts/{account_number}/trades/{mode}?limit={limit}&skip={skip}'
    

    Response example

    {
        "trades": [
            {
                "symbol": "AAPL",
                "timestamp": 1507735400,
                "quantity": 40,
                "price": 156.6699,
                "amount": 6266.8,
                "side": "buy"
            },
            {
                "symbol": "BAC",
                "timestamp": 1506680904,
                "quantity": -1,
                "price": 25.43,
                "amount": -25.43,
                "side": "sell_short"
            },
            {
                "symbol": "BAC",
                "timestamp": 1506680852,
                "quantity": 1,
                "price": 25.49,
                "amount": 25.49,
                "side": "buy_to_cover"
            }
        ],
        "count": 237
    }
    

    Get the trades history on the specified account, ordered by descending timestamp. Query parameters are:

    name description
    account_number Required. The account number
    mode Optional. Possible options are close, current or empty by default. close denotes the historical mode to return the trades by the end of the previous trading day, current shows the intraday activity, empty combines both
    limit Optional, 10 by default. The number of items to return on one page
    skip Optional, 0 by default. The number of items to skip

    Response

    Returns an array of trades and a counter of total trades matching the criteria. Every trade has the following structure:

    name description
    symbol security symbol
    timestamp unix time stamp of the trade
    quantity number of shares or option contracts, negative for sells, positive for buys
    price the trade price
    amount the trade amount, which is the quantity multiplied by the lot size and price,
    side buy, sell, sell_short or buy_to_cover

    Get account holder info - not live yet

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/accounts/{account_number}/holders'
    

    Response example

    {
        "account_type": "Joint WROS",
        "account_name": "John Doe and Jane Doe Joint WROS"
        "holders":
        [
            {
                "name": "John Doe",
                "primary": true,
                "address": "One Penn Plaza suite 1614, New York, NY, 10119",
                "phone": "111-22-3333",
                "email_address": "email@email.com"
            },
            {
                "name": "Jane Doe",
                "primary": false,
                "address": "One Penn Plaza suite 1614, New York, NY, 10119",
                "phone": "111-22-3333",
                "email_address": "email@email.com"
            }
        ]
    }
    

    Returns non-trading account information, including holders contact info

    Transactions journal

    curl
        -X GET
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/accounts/{account_number}/transactions?start_date={start_date}&end_date={end_date}&limit={limit}&skip={skip}'
    

    Response example

    {
        "transactions":
        [
            {
                "id": "1644455",
                "type": "MONEY:OUT:CHRG",
                "description": "CHRG MANDATORY REORG FEE REF:11111-222222,PUT PROSHARES",
                "date": "2018-06-30",
                "cash": {
                    "gross_amount": -30.00,
                    "net_amount": -30.00
                }
            },
            {
                "id": "1681283",
                "type": "INSTRUM:IN:EXP",
                "description": "EXP PUT SOLAREDGE TECHS A $25 EXP 06/15/18",
                "date": "2018-06-18",
                "asset": {
                    "symbol": "SEDG  180615P00025000",
                    "symbol_description": "SEDG Jun 2018 25 Put",
                    "quantity": 8,
                    "price": 0
                },
                "cash": {
                    "gross_amount": 0,
                    "net_amount": 0
                },
                "fees": []
            },
            {
                "id": "1681278",
                "type": "INSTRUM:IN:ASG",
                "description": "ASG CALL RUBICON PROJECT INC $2.50 EXP 06/15/18",
                "date": "2018-06-18",
                "asset": {
                    "symbol": "RUBI  180615C00002500",
                    "symbol_description": "RUBI Jun 2018 2.5 Call",
                    "quantity": 20,
                    "price": 0
                },
                "cash": {
                    "gross_amount": 0,
                    "net_amount": 0
                },
                "fees": []
            },
            {
                "id": "1681293",
                "type": "SALE:EXCH:ASG",
                "description": "ASG CALL RUBICON PROJECT INC $2.50 EXP 06/15/18",
                "date": "2018-06-18",
                "asset": {
                    "symbol": "RUBI",
                    "symbol_description": "THE RUBICON PROJECT Inc",
                    "quantity": -2000,
                    "price": 2.5
                },
                "cash": {
                    "gross_amount": 5000,
                    "net_amount": 4980
                },
                "fees": [
                    { "name": "Broker fee", "amount": -20 }
                ]
            },
            {
                "id": "1677793",
                "type": "SELL-SHORT:EXCH:STD",
                "description": "Sell to Open 20 'NCMI Dec 2018 7.5 Call' @0.75",
                "date": "2018-06-15",
                "asset": {
                    "symbol": "NCMI  181221C00007500",
                    "symbol_description": "NCMI Dec 2018 7.5 Call",
                    "quantity": -20,
                    "price": 0.75
                },
                "cash": {
                    "gross_amount": 1500,
                    "net_amount": 1486.6845
                },
                "fees": [
                    { "name": "Broker fee", "amount": -2.5 },
                    { "name": "Broker fee", "amount": -9 },
                    { "name": "TAF", "amount": -0.04 },
                    { "name": "ORF", "amount": -0.756 },
                    { "name": "OCC fee", "amount": -1 },
                    { "name": "SEC fee", "amount": -0.0195 }
                ]
            },
        ],
        "count": 237
    }
    

    Query parameters are:

    name description
    account_number Required. The account number
    start_date Required. The period start date in the format of yyyy-MM-dd
    end_date Required. The period end date in the format of yyyy-MM-dd
    limit Optional, 10 by default. The number of items to return on one page
    skip Optional, 0 by default. The number of items to skip

    Returns an array of trasnactions and a counter of total transactions in the specified time period. Every transaction has the following structure:

    name description
    id internal transaction id. It is globally unique and it is not necessarily sequentually incremented
    type transaction type
    description human-readable transaction description
    date date in the format of yyyy-MM-dd
    asset a structure describing the asset side of the transaction
    asset.symbol symbol
    asset.symbol_description company name for stocks or human-readable name for options
    asset.quantity transaction quantity, can be positive or negative
    asset.price the price for each unit
    cash describes the cash side of the transaction
    cash.gross_amount dollar amount not including fees, can be positive or negative
    cash.net_amount net dollar amount including fees charged for the transaction, can be positive or negative
    fees array of fees charged by the current transaction. Every fee item has a name and amount properties

    Trading

    Validate an order

    curl -X POST
      --header 'Content-Type: application/json'
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      -d '{ \ 
       "account_number": "12345678@vision", \ 
       "symbol": "string", \ 
       "quantity": 1, \ 
       "price": 21.0, \ 
       "stop_price": 0, \ 
       "time_in_force": "day", \ 
       "order_type": "limit", \ 
       "side": "buy", \ 
       "comment": "string", \ 
       "exchange": "string" \ 
     }' 'https://api.just2trade.com/orders/validate'
    
    void ValidateOrder(string access_token, string account_number)
    {
      //--- REST client's HTTP vars
      string uri = "https://api.just2trade.com/orders/validate";
      char post[];
      char result[];
      string headersResult;
      string header;
      int res;
    
      //--- Form the request body 
      header = "Content-Type: application/json\r\n"; 
      header += "Accept: application/json\r\n";     
      header += "Authorization: Bearer "+access_token+"\r\n";
      string postData = "{ \"account_number\": \"" + account_number + "\", \"symbol\": \"ZVZZT\", \"quantity\": 50, \"price\": 10.00, \"order_type\": \"limit\", \"side\": \"buy\" }";
    
      ArrayResize(post, StringToCharArray(postData, post, 0, WHOLE_ARRAY, CP_UTF8) - 1);
    
      //--- reset last error
      ResetLastError();
    
      //--- post data to REST API
      res = WebRequest("POST", uri, header, 50, post, result, headersResult);
    
      //--- check errors
      if (res == -1)
      {
        Print("Error code =", GetLastError());
      }
      else
      {
        //--- successful
        Print("Server response: ", CharArrayToString(result, 0, -1));
      }          
    }
    

    Request example

    {
      "account_number": "12345678@vision",
      "symbol": "BAC",
      "quantity": 1,
      "price": 21.0,
      "stop_price": 0,
      "time_in_force": "day",
      "order_type": "limit",
      "side": "buy",
      "comment": "any comment",
      "exchange": "Auto"
    }
    

    Response example

    {
      "is_valid": false,
      "validation_message": "You cannot sell more shares than your effective long position (effective long position = long position less open sell orders) using one order ticket. Please check your pending order(s) for potential outstanding duplicate order(s). Industry regulations require that two order tickets be submitted: one to sell your effective long position and one to sell your desired short position."
    }
    

    The method verifies an order and responds with the validation message if the order can not be placed at the moment. The order is not sent to market.

    Request

    parameter description
    account_number Required. The account number in the format of 123456578@vision
    symbol Required. The security symbol, stocks in Nasdaq CMS convention, options in OCC
    quantity Required. The positive decimal, number of shares or contracts
    price Required positive decimal if the order_type is limit or stop_limit
    stop_price Required positive decimal if the order_type is stop or stop_limit
    time_in_force Optional, day by default. Specifies how long the order remains in effect. Possible values are day, good_till_cancel, good_till_crossing
    order_type Optional, market by default. Possible values are market, limit, stop, stop_limit, market_on_close, limit_on_close
    side Optional, buy by default. Available values are buy and sell. buy opens long position, sell closes the position. The system will detemine the proper side according to the current position, but you are still required to place two orders to revert the position from long to short and the other way around.
    comment Optional, any string
    exchange Optional, auto by default. The routing instructions for order execution. The actual values are dynamic and depend on the account settings. Some of the possible values are NASDAQ or ARCA

    Response

    The method returns the following json structure:

    parameter description
    is_valid true or false
    validation_message Optional reject reason

    Place an order

    curl -X POST
      --header 'Content-Type: application/json'
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      -d '{ \ 
       "account_number": "12345678@vision", \ 
       "symbol": "BAC", \ 
       "quantity": 1, \ 
       "price": 20, \ 
       "stop_price": 0, \ 
       "time_in_force": "day", \ 
       "order_type": "limit", \ 
       "side": "buy", \ 
       "comment": "any comment", \ 
       "exchange": "Auto" \ 
     }' 'https://api.just2trade.com/orders/place'
    
    void PlaceOrder(string access_token, string account_number)
    {
      //--- REST client's HTTP vars
      string uri = "https://api.just2trade.com/orders/place";
      char post[];
      char result[];
      string headersResult;
      string header;
      int res;
    
      //--- Form the request body 
      header = "Content-Type: application/json\r\n"; 
      header += "Accept: application/json\r\n";     
      header += "Authorization: Bearer "+access_token+"\r\n";
      string postData = "{ \"account_number\": \"" + account_number + "\", \"symbol\": \"ZVZZT\", \"quantity\": 50, \"price\": 10.00, \"order_type\": \"limit\", \"side\": \"buy\" }";
    
      ArrayResize(post, StringToCharArray(postData, post, 0, WHOLE_ARRAY, CP_UTF8) - 1);
    
      //--- reset last error
      ResetLastError();
    
      //--- post data to REST API
      res = WebRequest("POST", uri, header, 50, post, result, headersResult);
    
      //--- check errors
      if (res == -1)
      {
        Print("Error code =", GetLastError());
      }
      else
      {
        //--- successful
        Print("Server response: ", CharArrayToString(result, 0, -1));
      }          
    }
    

    Request example

    {
      "account_number": "12345678@vision",
      "symbol": "BAC",
      "quantity": 1,
      "price": 20.0,
      "stop_price": 0,
      "time_in_force": "day",
      "order_type": "limit",
      "side": "buy",
      "comment": "any comment",
      "exchange": "Auto"
    }
    

    Response example

    {
      "success": true,
      "data": "201710041710516537"
    }
    

    The order is accepted immediately, the method returns assigned id. The order is still validated with exactly same logic as in validate method and is sent to market on successful validation pass. Otherwise, the order will reject asynchronously and you can query its status by calling the details method.

    Response

    name value
    success true
    data the id assigned to the order

    Get order details

    curl -X GET
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      'https://api.just2trade.com/orders/{id}'
    
    string GetOrderDetails(string access_token, string id)
    {
      //--- REST client's HTTP vars
      string header;
      char result[];
      char post[];
      string headersResult;
      int res;
      string uri = "https://api.just2trade.com/orders/" + id;
    
      //--- Form the request body 
      header += "Accept: application/json\r\n";     
      header += "Authorization: Bearer " + access_token + "\r\n";
    
      //--- post data to REST API
      res = WebRequest("GET", uri, header, 5000, post, result, headersResult);
    
      if(res == -1)
      {
        Print("Error code = ", GetLastError());
      }
      else
      {
        Print("Successful, server response: " + CharArrayToString(result, 0, -1) + " Res: " + (string)res);
      }  
      return CharArrayToString(result, 0, -1);
    }
    

    Response example

    {
      "account_number": "12345678@vision",
      "client_id": "20171003209384646",
      "exchange": "Auto",
      "quantity": 1,
      "executed_quantity": 0,
      "order_status": "new",
      "price": 20,
      "stop_price": 0,
      "time_in_force": "day",
      "order_type": "limit",
      "order_side": "buy",
      "symbol": "BAC"
    }
    

    Get the order details by the specified order id

    Request

    name description
    id Required. The order id

    Response

    name description
    account_number the account number in the format of 123456578@vision
    client_id the order id
    exchange the routing instructions
    quantity number of shares or contracts requested by the order
    executed_quantity number of shares or contracts executed by this time
    order_status the order status. Possible values are new, pending_new, partially_filled, filled, pending_cancel, canceled, pending_replace, replaced, rejected, done_for_day, expired
    price limit price if applicable
    stop_price stop price is applicable
    time_in_force order duration instructions
    order_type type of the order
    order_side side of the order
    symbol security symbol

    Get active orders

    curl -X GET
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      'https://api.just2trade.com/accounts/{account_number}/activeorders'
    

    Response example

    [
      {
        "account_number": "12345678@vision",
        "client_id": "20171003209384646",
        "exchange": "Auto",
        "quantity": 1,
        "executed_quantity": 0,
        "order_status": "new",
        "price": 20,
        "stop_price": 0,
        "time_in_force": "day",
        "order_type": "limit",
        "order_side": "buy",
        "symbol": "BAC"
      }
    ]
    

    Get an array of active orders

    Cancel an order

    curl -X POST
      --header 'Content-Type: application/json'
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      -d '{ \ 
       "message": "string" \ 
     }' 'https://api.just2trade.com/orders/20171003209384646/cancel'
    

    Response example

    {
      "success": true,
      "data": "201710041710516537"
    }
    

    Cancel the specified order

    Request

    the order is identified by its id on the url. The request can also contain optional info

    name description
    message Optional, any string

    Response

    name value
    success true
    data the cancellation request id

    Estimate fee charges - not live yet

    curl -X POST
      --header 'Content-Type: application/json'
      --header 'Accept: application/json'
      --header 'Authorization: Bearer {token here}'
      -d '{ \ 
       "commission_plan": "per_trade", \ 
       "symbol": "TSLA", \ 
       "quantity": 50, \ 
       "side": "sell", \ 
       "direct_route": true \ 
     }' 'https://api.just2trade.com/pricing/fees'
    

    Response example

    [
      {
        "amount": "2.5000",
        "type": "Broker commission"
      },
      {
        "amount": "0.1500",
        "type": "ECN"
      },
      {
        "amount": "0.1827",
        "type": "SEC"
      },
      {
        "amount": "0.0060",
        "type": "TAF"
      }
    ]
    

    The method returns estimated fees for specified order parameters, breaking down all charges by type

    Request

    name description
    commission_plan Optional. Available values are per_share, per_trade, zero. Default is per_trade
    symbol Required. A stock or an option
    quantity Required. Order quantity
    side Required. Available values are buy, sell, sell_short, buy_to_cover
    direct_route Optional boolean value. false by default.

    Response

    An array of items breaking down all charges

    name description
    amount Dollar amount
    type Charge description

    Market data

    Get current quote

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/marketdata/quote?symbol=AAPL'
    

    Returns the following structure:

    {
      "symbol": "AAPL",
      "ask": 154.61,
      "ask_size": 5,
      "bid": 154.6,
      "bid_size": 14,
      "last": 154.61,
      "last_size": 100,
      "volume": 9461271,
      "date": 1507049383,
      "high": 155.09,
      "low": 153.91,
      "open": 154.01,
      "close": 153.81,
      "week52_high": 164.94,
      "week52_low": 104.08,
      "change": 0.52,
      "change_pc": 0,
      "open_interest": 0
    }
    

    The query retrieves current realtime quote for the specified symbol.

    Request

    parameter description
    symbol Required. The security symbol

    Response

    The data depends on current time of day.

    Get current quotes array

    curl
        -X POST
        --header 'Content-Type: application/json'
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
      -d '["GOOG", "AAPL", "MSFT"]'
      'https://api.just2trade.com/marketdata/quotes'
    

    Returns an array of quotes:

    [
        {
            "symbol": "GOOG",
            ...
        },
        {
            "symbol": "AAPL",
            ...
        },
        {
            "symbol": "MSFT",
            ...
        }
    ]
    

    The query retrieves current realtime quotes for all symbols specified on the request array

    Get quotes history

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/marketdata/history?symbol=AAPL&period=day&from=1483228800&to=1483488000'
    

    Returns an array of candles:

    [
      {
        "timestamp": 1483074000,
        "period": "day",
        "open": 116.65,
        "high": 117.2,
        "low": 115.43,
        "close": 115.82,
        "volume": 24541183
      },
      {
        "timestamp": 1483419600,
        "period": "day",
        "open": 115.8,
        "high": 116.33,
        "low": 114.76,
        "close": 116.15,
        "volume": 24719541
      }
    ]
    

    The query returns candle structures aggregated by specified period

    Request

    parameter description
    symbol Required. The security symbol, stocks in Nasdaq CMS convention. Options are not supported
    period Required. The supported periods are: minute, minute_5, minute_15, minute_30, hour, day, week, month, quarter, year
    from Required. Start of the period, unix timestamp
    to Required. End of the period, unix timestamp

    Get trading schedule - not live yet

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/marketdata/schedule'
    

    Response example:

    {
        "session": "regular_market"
    }
    

    Returns trading session info depending on current date and time:

    name description
    session One of the following values: pre_market, regular_market, after_market, closed.

    Lookup securities

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/securities?query=ba&limit=4'
    

    Response

    {
        "securities": [
            {
                "symbol": "BA",
                "description": "BOEING COMPANY"
            },
            {
                "symbol": "BAC",
                "description": "BANK OF AMERICA CORPORATION"
            },
            {
                "symbol": "BAX",
                "description": "BAXTER INTERNATIONAL Inc"
            },
            {
                "symbol": "BAP",
                "description": "CREDICORP Ltd"
            }
        ],
        "count": 2492
    }
    

    Searches the securities reference by the specified criteria. The criteria can be a symbol, part of a symbol or part of a company name. Query parameters are:

    name description
    query Required. The search criteria.
    limit Optional, 10 by default. The number of items to return on one page

    Get time and sales - not live yet

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/marketdata/trades?symbol=IBM&limit=4&from=1513362185&to=1513362190'
    

    Response example:

    {
        "trades": [
            {
                "timestamp": 1513362190,
                "quantity": 100,
                "price": 152.44,
                "market": "BOS"
            },
            {
                "timestamp": 1513362190,
                "quantity": 100,
                "price": 152.44,
                "market": "EDGA"
            },
            {
                "timestamp": 1513362188,
                "quantity": 22,
                "price": 152.4699,
                "market": "NDD"
            },
            {
                "timestamp": 1513362185,
                "quantity": 100,
                "price": 152.45,
                "market": "NASDAQ"
            }
        ],
        "count": 12
    }
    

    Retrieves the time and sales history, ordered by descending timestamp. Query parameters are:

    name description
    symbol Required. The security symbol, stocks in Nasdaq CMS convention. Options are not supported
    from Required. Start of the period, unix timestamp
    to Required. End of the period, unix timestamp
    limit Optional, 10 by default. The number of items to return on one page
    skip Optional, 0 by default. The number of items to skip

    Get option series

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/securities/VXX/options/series'
    

    Response

    [
        "VXX",
        "VXX1",
        "VXX2"
    ]
    

    Returns an array of option series by the specified underlying security's symbol. Contains at least one element which is the default series. Option Series is a specific set of calls or puts on the same underlying security, with the same strike price and expiration date. For the most part there is just one series name that matches the symbol but in some cases related to corporate actions on the underlying security additional series are issued.

    Get option expirations

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/securities/{symbol}/options/expirations?series={series}'
    

    Response

    [
        "2017-11-17",
        "2017-11-24",
        "2017-12-01",
        "2017-12-15",
        "2018-01-19",
        "2018-02-16",
        "2018-04-20",
        "2018-06-15",
        "2018-09-21",
        "2019-01-18"
    ]
    

    Returns an array of all available option expiration dates formatted as yyyy-mm-dd. Parameters are:

    name description
    symbol Required. The root symbol.
    series Optional. By default the series is the same as the the root symbol

    Get option chain

    curl
        -X GET
        --header 'Accept: application/json'
        --header 'Authorization: Bearer {token here}'
        'https://api.just2trade.com/securities/{symbol}/options?expiration={expiration}&series={series}'
    

    Response example

    [
        {
            "symbol": "VXX2  171117C00008000",
            "type": "call",
            "strike": 8
        },
        {
            "symbol": "VXX2  171117P00008000",
            "type": "put",
            "strike": 8
        },
        {
            "symbol": "VXX2  171117C00009000",
            "type": "call",
            "strike": 9
        },
        ...
    ]
    

    Returns an array of option contracts by the specified expiration date and series. Parameters are:

    name description
    symbol Required. The root symbol.
    expiration Required. Contract expiration date, formatted as yyyy-mm-dd
    series Optional. By default the series is the same as the the root symbol

    Errors

    We use standard HTTP codes to indicate the result of a request. Generally speaking, codes in 2xx range indicate successful call, codes 4xx indicate that the request failed with the information provided (authentication not accepted, parameters formatted incorrectly, a trade is not accepted) and codes 5xx indicate internal server errors with no further explanation. The standard codes are clearly not enough, that is why the API can also respond with a json object with the following optional fields:

    parameter description
    code not_found, validation_error, api_error
    message the error description

    HTTP Status Codes

    code description
    200 OK all good
    400 BAD REQUEST the request is not accepted most likely due to formatting issues
    401 UNAUTHORIZED authorization denied, access token is incorrect or revoked
    404 NOT FOUND the requested resource is not found
    500 SERVER ERROR internal server error, something on our end

    Appendix

    CMS symbols

    The CMS convention is used to code stocks and ETFs. There is a space between the root and the suffix.

    As an example, the Bank of America warrant class A will be coded as BAC WSA, Berkshire Hathaway class B is coded as BRK B

    Security Categorization CMS Suffix
    Preferred PR
    Preferred Class class A PRA
    Class “A” A
    Preferred when distributed PRWD
    When distributed WD
    Warrants WS
    Warrants Class “A” WSA
    Called CL
    Class “A” Called ACL
    Preferred called PRCL
    Preferred “A” called PRACL
    Preferred “A” when issued PRAWI
    Emerging Company Marketplace EC
    Partial Paid PP
    Convertible CV
    Convertible called CVCL
    Class Convertible ACV
    Preferred (class A) Convertible PRACV
    Preferred (class A) when Distributed PRAWD
    Rights RT
    Units U
    When issued WI
    Rights when issued RTWI
    Preferred when issued PRWI
    Class "A" when issued AWI
    Warrrant when issued WSWI

    OCC symbols

    For example, symbol AAPL 171103C00155000 is translated to a call on AAPL expiring on November 3rd 2017, with its strike price of $155.00

    Option symbols are coded according to the OCC standard. The OCC option symbol consists of 4 parts: