Contracts¶
This module contains all contract classes as well as helper methods for working with these.
-
class
algotradepy.contracts.AContract(symbol, con_id=None, exchange=<Exchange.SMART: 'SMART'>, currency=<Currency.USD: 'USD'>)¶ The abstract contract class defining the basic contract properties.
- Parameters
symbol (str) – The symbol for the contract.
con_id (int, optional, default None) – The contract ID.
exchange (~algotradepy.contracts.Exchange, default Exchange.SMART) – The exchange on which this contract is traded.
currency (~algotradepy.contracts.Currency, default Currency.USD) – The currency of the contract.
-
property
con_id¶
-
property
symbol¶
-
property
exchange¶
-
property
currency¶
-
class
algotradepy.contracts.StockContract(symbol, con_id=None, exchange=None, currency=<Currency.USD: 'USD'>)¶ Defines a stock contract.
- Parameters
symbol –
con_id –
exchange –
currency –
-
class
algotradepy.contracts.OptionContract(symbol, strike, right, multiplier, last_trade_date, con_id=None, exchange=None, currency=<Currency.USD: 'USD'>)¶ Defines an option contract.
- Parameters
symbol –
strike (float) – The option’s strike price.
right (Right) – The option’s right.
multiplier (float) – The option’s multiplier.
last_trade_date (datetime.date) – The option contract’s expiration date.
con_id –
exchange –
currency –
-
property
strike¶
-
property
right¶
-
property
multiplier¶
-
property
last_trade_date¶
-
class
algotradepy.contracts.Right(value)¶ Option right.
CALL
PUT
-
class
algotradepy.contracts.ForexContract(symbol, con_id=None, exchange=<Exchange.FOREX: 'FOREX'>, currency=<Currency.USD: 'USD'>)¶
-
class
algotradepy.contracts.PriceType(value)¶ The price type.
Used when requesting price updates for a given contract.
MARKET
ASK
BID
-
class
algotradepy.contracts.Exchange(value)¶ The available exchanges.
Automatic
SMART
North America
NYSE
NASDAQ
AMEX
ARCA
TSE
Europe
FWB
IBIS
VSE
LSE
BATEUK
ENEXT_BE
SBF
AEB
Asia/Pacific
SEHK
ASX
TSEJ
Global
FOREX
-
class
algotradepy.contracts.Currency(value)¶ The available currencies.
North America
USD
CAD
Europe
EUR
GBP
Asia/Pacific
AUD
HKD
JPY
-
algotradepy.contracts.are_loosely_equal_contracts(loose, well_defined)¶ Used to compare a loosely- and a well-defined contract.
This method is useful for tasks such as getting all positions for a given stock symbol, irrespective of the exchange.