Netscript Trade Information eXchange (TIX) API

The Trade Information eXchange (TIX) is the communications protocol supported by the World Stock Exchange (WSE). The WESE provides an API that allows you to automatically communicate with the Stock Market. This API lets you write code using Netscript to build automated trading systems and create your own algorithmic trading strategies. Access to this TIX API can be purchased by visiting the World Stock Exchange in-game.

Access to the TIX API currently costs $5 billion. After you purchase it, you will retain this access even after you 'reset' by installing Augmentations

getStockPrice

getStockPrice(sym)
Arguments:
  • sym (string) -- Stock symbol

Returns the price of a stock, given its symbol (NOT the company name). The symbol is a sequence of two to four capital letters.

Example:

getStockPrice("FISG");

getStockPosition

getStockPosition(sym)
Arguments:
  • sym (string) -- Stock symbol

Returns an array of four elements that represents the player's position in a stock.

The first element is the returned array is the number of shares the player owns of the stock in the Long position. The second element in the array is the average price of the player's shares in the Long position.

The third element in the array is the number of shares the player owns of the stock in the Short position. The fourth element in the array is the average price of the player's Short position.

All elements in the returned array are numeric.

Example:

pos = getStockPosition("ECP");
shares      = pos[0];
avgPx       = pos[1];
sharesShort = pos[2];
avgPxShort  = pos[3];

buyStock

buyStock(sym, shares)
Arguments:
  • sym (string) -- Symbol of stock to purchase
  • shares (number) -- Number of shares to purchased. Must be positive. Will be rounded to nearest integer

Attempts to purchase shares of a stock using a Market Order.

If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every transaction on the stock exchange costs a certain commission fee.

If this function successfully purchases the shares, it will return the stock price at which each share was purchased. Otherwise, it will return 0.

sellStock

sellStock(sym, shares)
Arguments:
  • sym (string) -- Symbol of stock to sell
  • shares (number) -- Number of shares to sell. Must be positive. Will be rounded to nearest integer

Attempts to sell shares of a stock using a Market Order.

If the specified number of shares in the function exceeds the amount that the player actually owns, then this function will sell all owned shares. Remember that every transaction on the stock exchange costs a certain commission fee.

The net profit made from selling stocks with this function is reflected in the script's statistics. This net profit is calculated as:

shares * (sell price - average price of purchased shares)

If the sale is successful, this function will return the stock price at which each share was sold. Otherwise, it will return 0.

shortStock

shortStock(sym, shares)
Arguments:
  • sym (string) -- Symbol of stock to short
  • shares (number) -- Number of shares to short. Must be positive. Will be rounded to nearest integer

Attempts to purchase a short position of a stock using a Market Order.

The ability to short a stock is not immediately available to the player and must be unlocked later on in the game.

If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every transaction on the stock exchange costs a certain commission fee.

If the purchase is successful, this function will return the stock price at which each share was purchased. Otherwise, it will return 0.

sellShort

sellShort(sym, shares)
Arguments:
  • sym (string) -- Symbol of stock to sell
  • shares (number) -- Number of shares to sell. Must be positive. Will be rounded to nearest integer

Attempts to sell a short position of a stock using a Market Order.

The ability to short a stock is not immediately available to the player and must be unlocked later on in the game.

If the specified number of shares exceeds the amount that the player actually owns, then this function will sell all owned shares. Remember that every transaction on the stock exchange costs a certain commission fee.

If the sale is successful, this function will return the stock price at which each share was sold. Otherwise it will return 0.

placeOrder

placeOrder(sym, shares, price, type, pos)
Arguments:
  • sym (string) -- Symbol of stock to player order for
  • shares (number) -- Number of shares for order. Must be positive. Will be rounded to nearest integer
  • price (number) -- Execution price for the order
  • type (string) --

    Type of order. It must specify "limit" or "stop", and must also specify "buy" or "sell". This is NOT case-sensitive. Here are four examples that will work:

    • limitbuy
    • limitsell
    • stopbuy
    • stopsell
  • pos (string) -- Specifies whether the order is a "Long" or "Short" position. The Values "L" or "S" can also be used. This is NOT case-sensitive.

Places an order on the stock market. This function only works for Limit and Stop Orders.

The ability to place limit and stop orders is not immediately available to the player and must be unlocked later on in the game.

Returns true if the order is successfully placed, and false otherwise.

cancelOrder

cancelOrder(sym, shares, price, type, pos)
Arguments:
  • sym (string) -- Symbol of stock to player order for
  • shares (number) -- Number of shares for order. Must be positive. Will be rounded to nearest integer
  • price (number) -- Execution price for the order
  • type (string) --

    Type of order. It must specify "limit" or "stop", and must also specify "buy" or "sell". This is NOT case-sensitive. Here are four examples that will work:

    • limitbuy
    • limitsell
    • stopbuy
    • stopsell
  • pos (string) -- Specifies whether the order is a "Long" or "Short" position. The Values "L" or "S" can also be used. This is NOT case-sensitive.

Cancels an oustanding Limit or Stop order on the stock market.

The ability to use limit and stop orders is not immediately available to the player and must be unlocked later on in the game.