self.create_asset

lumibot.strategies.strategy.Strategy.create_asset(self, symbol: str, asset_type: str = 'stock', expiration: datetime = None, strike: float = None, right: str = None, multiplier: float | None = None)

Creates an asset object. This is used to create an asset object.

Parameters:
  • symbol (str) – The symbol of the asset.

  • asset_type (str) – The type of the asset. Can be either “stock”, “option”, or “future”, “crytpo”.

  • expiration (datetime.datetime) – The expiration date of the asset (optional, only required for options and futures).

  • strike (str) – The strike price of the asset (optional, only required for options).

  • right (str) – The right of the option (optional, only required for options).

  • multiplier (float) – Contract price multiplier. When omitted, defaults to 100 for options and 1 for other asset types. Explicit provider contract terms are preserved.

Returns:

The asset object.

Return type:

Asset

Example

>>> # Will create a stock object
>>> asset = self.create_asset("AAPL", asset_type="stock")
>>> # Will create an option object
>>> asset = self.create_asset("AAPL", asset_type="option", expiration=datetime.datetime(2020, 1, 1), strike=100, right="CALL")
>>> # Will create a future object
>>> asset = self.create_asset("AAPL", asset_type="future", multiplier=100)
>>> # Will create a FOREX asset
>>> asset = self.create_asset(symbol="EUR", asset_type="forex")
>>> # Will create a CRYPTO asset
>>> asset = self.create(symbol="BTC", asset_type="crypto"),
>>> asset = self.create(symbol="USDT", asset_type="crypto"),
>>> asset = self.create(symbol="EUR", asset_type="crypto"),
>>> asset = self.create(symbol="ETH", asset_type="crypto"),