SymbolRepresentation
QuantConnect.SymbolRepresentation
Bases: Object
Public static helper class that does parsing/generation of symbol representations (options, futures)
OPTION_CODE_LOOKUP
OPTION_CODE_LOOKUP: IReadOnlyDictionary[
str, Tuple[int, OptionRight]
]
A dictionary that maps option symbols to a tuple containing the option series number and the option right (Call or Put). The key represents a single character option symbol, and the value contains the series number and the associated option right.
FUTURES_MONTH_CODE_LOOKUP
FUTURES_MONTH_CODE_LOOKUP: IReadOnlyDictionary[str, int]
Provides a lookup dictionary for mapping futures month codes to their corresponding numeric values.
FUTURES_MONTH_LOOKUP
FUTURES_MONTH_LOOKUP: IReadOnlyDictionary[int, str]
Provides a lookup dictionary for mapping numeric values to their corresponding futures month codes.
FutureTickerProperties
Bases: Object
Class contains future ticker properties returned by ParseFutureTicker()
underlying
underlying: str
Underlying name
expiration_year_short
expiration_year_short: int
Short expiration year
expiration_year_short_length
expiration_year_short_length: int
Short expiration year digits
expiration_month
expiration_month: int
Expiration month
expiration_day
expiration_day: int
Expiration day
OptionTickerProperties
Bases: Object
Class contains option ticker properties returned by ParseOptionTickerIQFeed()
underlying
underlying: str
Underlying name
option_strike
option_strike: float
Option strike
expiration_date
expiration_date: datetime
Expiration date
generate_option_ticker_osi
generate_option_ticker_osi(
symbol: Union[Symbol, str, BaseContract],
) -> str
generate_option_ticker_osi(
underlying: str,
right: OptionRight,
strike_price: float,
expiration: Union[datetime, date],
) -> str
Returns option symbol ticker in accordance with OSI symbology More information can be found at http://www.optionsclearing.com/components/docs/initiatives/symbology/symbology_initiative_v1_8.pdf
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract]]
|
Symbol object to create OSI ticker from |
None
|
underlying
|
Optional[str]
|
Underlying string |
None
|
right
|
Optional[OptionRight]
|
Option right |
None
|
strike_price
|
Optional[float]
|
Option strike |
None
|
expiration
|
Optional[Union[datetime, date]]
|
Option expiration date |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The OSI ticker representation. |
generate_option_ticker_osi_compact
generate_option_ticker_osi_compact(
symbol: Union[Symbol, str, BaseContract],
) -> str
generate_option_ticker_osi_compact(
underlying: str,
right: OptionRight,
strike_price: float,
expiration: Union[datetime, date],
) -> str
Returns option symbol ticker in accordance with OSI symbology More information can be found at http://www.optionsclearing.com/components/docs/initiatives/symbology/symbology_initiative_v1_8.pdf
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract]]
|
Symbol object to create OSI ticker from |
None
|
underlying
|
Optional[str]
|
Underlying string |
None
|
right
|
Optional[OptionRight]
|
Option right |
None
|
strike_price
|
Optional[float]
|
Option strike |
None
|
expiration
|
Optional[Union[datetime, date]]
|
Option expiration date |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The OSI ticker representation. |
parse_option_ticker_osi
parse_option_ticker_osi(
ticker: str,
security_type: SecurityType = ...,
market: str = ...,
) -> Symbol
parse_option_ticker_osi(
ticker: str,
security_type: SecurityType,
option_style: OptionStyle,
market: str,
) -> Symbol
Parses the specified OSI options ticker into a Symbol object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The OSI compliant option ticker string |
required |
security_type
|
SecurityType
|
The security type |
...
|
market
|
str
|
The associated market |
...
|
option_style
|
Optional[OptionStyle]
|
The option style |
None
|
Returns:
| Type | Description |
|---|---|
Symbol
|
Symbol object for the specified OSI option ticker string. |
try_decompose_option_ticker_osi
try_decompose_option_ticker_osi(
ticker: str,
option_ticker: Optional[str],
expiry: Optional[Union[datetime, date]],
right: Optional[OptionRight],
strike: Optional[float],
) -> Tuple[
bool, str, Union[datetime, date], OptionRight, float
]
try_decompose_option_ticker_osi(
ticker: str,
security_type: SecurityType,
option_ticker: Optional[str],
underlying_ticker: Optional[str],
expiry: Optional[Union[datetime, date]],
right: Optional[OptionRight],
strike: Optional[float],
) -> Tuple[
bool,
str,
str,
Union[datetime, date],
OptionRight,
float,
]
Tries to decompose the specified OSI options ticker into its components
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The OSI option ticker |
required |
option_ticker
|
Optional[str]
|
The option ticker extracted from the OSI symbol |
required |
expiry
|
Optional[Union[datetime, date]]
|
The option contract expiry date |
required |
right
|
Optional[OptionRight]
|
The option contract right |
required |
strike
|
Optional[float]
|
The option contract strike price |
required |
security_type
|
Optional[SecurityType]
|
The option security type |
None
|
underlying_ticker
|
Optional[Optional[str]]
|
The underlying ticker |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[bool, str, Union[datetime, date], OptionRight, float] | Tuple[bool, str, str, Union[datetime, date], OptionRight, float]
|
True if the OSI symbol was in the right format and could be decomposed. |
generate_future_ticker
generate_future_ticker(
underlying: str,
expiration: Union[datetime, date],
double_digits_year: bool = True,
include_expiration_date: bool = True,
) -> str
Returns future symbol ticker from underlying and expiration date. Function can generate tickers of two formats: one and two digits year.
Format
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
underlying
|
str
|
String underlying |
required |
expiration
|
Union[datetime, date]
|
Expiration date |
required |
double_digits_year
|
bool
|
True if year should represented by two digits; False - one digit |
True
|
include_expiration_date
|
bool
|
True if expiration date should be included |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The user friendly future ticker. |
generate_option_ticker
generate_option_ticker(
symbol: Union[Symbol, str, BaseContract],
) -> str
Function returns option ticker from IQFeed option ticker For example CSCO1220V19 Cisco October Put at 19.00 Expiring on 10/20/12 Symbology details: http://www.iqfeed.net/symbolguide/index.cfm?symbolguide=guide&displayaction=support%C2%A7ion=guide&web=iqfeed&guide=options&web=IQFeed&type=stock
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
THe option symbol |
required |
Returns:
| Type | Description |
|---|---|
str
|
The option ticker. |
parse_future_option_symbol
parse_future_option_symbol(
ticker: str, strike_scale: int = 1
) -> Symbol
Creates a future option Symbol from the provided ticker
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The future option ticker, for example 'ESZ0 P3590' |
required |
strike_scale
|
int
|
Optional the future option strike scale factor |
1
|
parse_future_symbol
parse_future_symbol(
ticker: str, future_year: Optional[int] = None
) -> Symbol
Helper method to parse and generate a future symbol from a given user friendly representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The future ticker, for example 'ESZ1' |
required |
future_year
|
Optional[int]
|
Clarifies the year for the current future |
None
|
Returns:
| Type | Description |
|---|---|
Symbol
|
The future symbol or null if failed. |
parse_future_ticker
parse_future_ticker(ticker: str) -> FutureTickerProperties
Function returns underlying name, expiration year, expiration month, expiration day for the future contract ticker. Function detects if
the format used is either 1 or 2 digits year, and if day code is present (will default to 1rst day of month). Returns null, if parsing failed.
Format
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
FutureTickerProperties
|
Results containing 1) underlying name, 2) short expiration year, 3) expiration month. |
parse_option_ticker_iq_feed
parse_option_ticker_iq_feed(
ticker: str,
) -> OptionTickerProperties
Function returns option contract parameters (underlying name, expiration date, strike, right) from IQFeed option ticker Symbology details: http://www.iqfeed.net/symbolguide/index.cfm?symbolguide=guide&displayaction=support%C2%A7ion=guide&web=iqfeed&guide=options&web=IQFeed&type=stock
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
IQFeed option ticker |
required |
Returns:
| Type | Description |
|---|---|
OptionTickerProperties
|
Results containing 1) underlying name, 2) option right, 3) option strike 4) expiration date. |