Trade Information eXchange (TIX) API

The Trade Information eXchange (TIX) is the communications protocol supported by the World Stock Exchange (WSE). The WSE 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,000,000 (5 billion). After you purchase it, you will retain this access even after you 'reset' by installing Augmentations.

getStockPrice(sym)
Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol is a sequence of two to four capital letters. The symbol argument must be a string.

Example:

getStockPosition(sym)
Returns an array of four elements that represents the player's position in a stock. The argument passed in must be a string containing the stock's symbol.

The first element in the 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 is the average price of the player's Short position

All elements in the returned array are numeric.

Example:

buyStock(sym, shares)
Attempts to purchase shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the number of shares to purchase.

If the player does not have enough money to purchase specified number of shares, then no shares will be purchased (it will not purchase the most you can afford). 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(sym, shares)
Attempts to sell shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the number of shares to sell.

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(sym, shares)
Attempts to purchase a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the number of shares to purchase.

In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every 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(sym, shares)
Attempts to sell a Short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the number of shares to sell.

In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

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 was successful, this function will return the stock price at which each sale was sold. Otherwise, it will return 0.

placeOrder(sym, shares, price, type, pos)
Places an order on the stock market. This function only works for Limit and Stop Orders. Use the buyStock/sellStock/shortStock/sellShort functions to place Market Orders. In order to use this function the player must be in BitNode-8 or must have Level 3 of Source-File 8.

The 'sym' argument must be a string with the symbol of the stock. The 'shares' and 'price' arguments specify the number of shares and the execution price for the order. They must be numeric.

The 'type' argument is a string that specifies the type of order. It must specify either 'limit' or 'stop', and must also specify 'buy' or 'sell'. This argument is NOT case-sensitive. Here are four examples that will work:

limitbuy, limitsell, stopbuy, stopsell

The last argument, 'pos', is a string that specifies whether the order is a 'Long' or 'Short' position. The values 'L' and 'S' can also be used. This argument is NOT case-sensitive.

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

cancelOrder(sym, shares, price, type, pos)
Cancels an oustanding order on the stock market. In order to use this function the player must be in BitNode-8 or must have Level 3 of Source-File 8. This function uses the same arguments as placeOrder