Skip to content

Fetching Assets Blueshift®

The asset object

On Blueshift®, a central concept is an asset. An asset is the instrument or security that we can buy and sell in our strategy. An asset has a symbol, which identifies the instrument (like stock, or Forex or futures etc.). It also encapsulates other details on the instruments - like if it is available for trading, what the entity that it refers to (the company name for a stock, for example) etc. We usually define a universe of assets in our strategy. All ordering functions accept an asset object (and not a trading symbol) for trading orders.

See the API Reference for more details on various types of asset objects and available attributes.

Fetching assets

A strategy can get a reference to a particular trading instrument by its trading symbol using the API function symbol1. This function takes in a string, the trading symbol of the asset and returns an object that corresponds to that asset, like below

def initialize(context):
    context.universe = [symbol("AAPL"), symbol("MSFT")]

See the API Reference for more on these.

Asset fetching errors

The most common error is to try to fetch an asset with a wrong symbol name. This can happen if we are using a symbol name that does not exists within our chosen dataset for backtesting, or if there is no broker support for live trading. For example, if we are using a stock broker, and try to fetch the EUR/USD forex asset, we may get an error (typically SymbolNotFound error).

  1. The symbol function searches Blueshift® database for mapping to a particular traded instruments in case of a backtest. For live run, it searches the supported instruments by the broker.