Skip to content
This repository has been archived by the owner on May 29, 2021. It is now read-only.

Latest commit

 

History

History

orders

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Skip to API reference -->

See Examples in Code

Orders

The orders module can be described as the most exciting module in wstrade-api because you have the ability to:

  • buy and sell securities (Market, Limit, and Stop limit all supported)
  • cancel one or all pending orders
  • View pending, cancelled, filled, or all orders
Note: All operations in orders module require talking to Wealthsimple Trade endpoints. So make sure you are authenticated through the auth module.

API Reference


orders.page

Collects orders (filled, pending, cancelled) for the provided page and account id. A page is a maximum of 20 orders.

  • page must be >=1. An empty list will be returned by orders.page if the page exceeds the total number of pages.
  • accountId must be one returned by accounts.all

View examples

orders.page(accountId, page) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  total: 170,
  orders: [
    {
      object: 'order',
      created_at: '1970-01-01T13:42:52.422Z',
      completed_at: null,
      user_id: 00000,
      account_id: 'tfsa-zzzzzzz',
      external_order_id: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
      order_type: 'sell_quantity',
      order_sub_type: 'market',
      status: 'posted',
      quantity: 7,
      fill_quantity: 7,
      symbol: 'AAPL',
      security_name: 'Apple Inc',
      ...
    },
    19 more items...
  ]
}

See also: accounts.all


orders.all

Collects all orders (filled, pending, cancelled) for the specific open account.

  • accountId must be one returned by accounts.all

View examples

orders.all(accountId) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  total: 170,
  orders: [
    {
      object: 'order',
      created_at: '1970-01-01T13:42:52.422Z',
      completed_at: null,
      user_id: 00000,
      account_id: 'tfsa-zzzzzzz',
      external_order_id: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
      order_type: 'sell_quantity',
      order_sub_type: 'market',
      status: 'posted',
      quantity: 7,
      fill_quantity: 7,
      symbol: 'AAPL',
      security_name: 'Apple Inc',
      ...
    },
    70 more items...
  ]
}

See also: accounts.all


orders.pending

Retrieves pending orders for the specified security in the open account. If ticker is provided, only pending orders that match the security are returned.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.

View examples

orders.pending(accountId, [ticker]) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  total: 3,
  orders: [
    {
      object: 'order',
      created_at: '1970-01-01T13:42:52.422Z',
      completed_at: null,
      user_id: 00000,
      account_id: 'tfsa-zzzzzzz',
      external_order_id: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
      order_type: 'sell_quantity',
      order_sub_type: 'market',
      status: 'submitted',
      quantity: 7,
      symbol: 'AAPL',
      security_name: 'Apple Inc',
      ...
    },
    2 more items...
  ]
}

See also: accounts.all


orders.filled

Retrieves filled orders for the specified security in the open account. If ticker is provided, only filled orders that match the security are returned.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.

View examples

orders.filled(accountId, [ticker]) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  total: 9,
  orders: [
    {
      object: 'order',
      created_at: '1970-01-01T13:42:52.422Z',
      user_id: 00000,
      account_id: 'tfsa-zzzzzzz',
      external_order_id: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
      order_type: 'sell_quantity',
      order_sub_type: 'market',
      status: 'posted',
      quantity: 7,
      fill_quantity: 7,
      symbol: 'AAPL',
      security_name: 'Apple Inc',
      ...
    },
    8 more items...
  ]
}

See also: accounts.all


orders.cancelled

Retrieves cancelled orders for the specified security in the open account. If ticker is provided, only cancelled orders that match the security are returned.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.

View examples

orders.cancelled(accountId, [ticker]) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  total: 2,
  orders: [
    {
      object: 'order',
      created_at: '1970-01-01T13:42:52.422Z',
      completed_at: null,
      user_id: 00000,
      account_id: 'tfsa-zzzzzzz',
      external_order_id: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
      order_type: 'sell_quantity',
      order_sub_type: 'market',
      status: 'cancelled',
      quantity: 7,
      symbol: 'AAPL',
      security_name: 'Apple Inc',
      ...
    },
    1 more item...
  ]
}

See also: accounts.all


orders.cancel

Cancels the pending order specified by the order id.

  • orderId may be retrieved from orders.page, orders.all, orders.pending, orders.filled, or orders.cancelled.

View examples

orders.cancel(orderId) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  order: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
  response: {} // The API returns nothing.
}

See also: orders.page, orders.all, orders.pending, orders.filled, orders.cancelled


orders.cancelPending

Cancels all pending orders under the open account specified by accountId

  • accountId must be one returned by accounts.all

View examples

orders.cancelPending(accountId) -> Promise<any>
* This is not the full returned object - it has been cut.
[
  // Cancelled Order 1
  {
    order: 'order-zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzz',
    response: {} // The API returns nothing.
  },

  // Cancelled Order 2
  {
    order: 'order-yyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyy',
    response: {} // The API returns nothing.
  },
  ...
]

See also: accounts.all


orders.marketBuy

Purchase a security with a market order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • quantity is the number of shares you wish to purchase

View examples

orders.marketBuy(accountId, ticker, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the market buy
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all


orders.limitBuy

Purchase a security with a limit order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • limit is the highest price you are willing to pay for the security
  • quantity is the number of shares you wish to purchase

View examples

orders.limitBuy(accountId, ticker, limit, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the limit buy
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all


orders.stopLimitBuy

Purchase a security with a stop limit order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • stop is the price of the security at which the order converts to a limit order
  • limit is the highest price you are willing to pay for the security
  • quantity is the number of shares you wish to purchase

View examples

orders.stopLimitBuy(accountId, ticker, stop, limit, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the stop limit buy
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all


orders.marketSell

Sell a security with a market order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • quantity is the number of shares you wish to sell

View examples

orders.marketSell(accountId, ticker, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the market sell
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all


orders.limitSell

Sell a security with a limit order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • limit is the lowest price you are willing to sell the security for
  • quantity is the number of shares you wish to sell

View examples

orders.limitSell(accountId, ticker, limit, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the limit sell
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all


orders.stopLimitSell

Sell a security with a stop limit order.

  • accountId must be one returned by accounts.all
  • ticker is an identifier for a security. Read this document to learn how to construct a valid ticker.
  • stop is the price of the security at which the order converts to a limit order
  • limit is the lowest price you are willing to sell the security for
  • quantity is the number of shares you wish to sell

View examples

orders.stopLimitSell(accountId, ticker, stop, limit, quantity) -> Promise<any>
* This is not the full returned object - it has been cut.
{
  // Confirmation and details of the stop limit sell
  object: 'order',
  created_at: '1970-01-01T13:42:52.422Z',
  completed_at: null,
  user_id: 00000,
  account_id: 'tfsa-zzzzzzz',
  ...
}

See also: accounts.all