Parsing.ContractIdParser

Classes

ContractIdParser() Class to convert a futures contract format into an object of type ContractMaturity.
ContractMaturity(month: int, year: int) Container class representing the notion of a futures contract maturity.
ContractMonthCodes Enum to represent the futures month codes.
class Parsing.ContractIdParser.ContractIdParser[source]

Class to convert a futures contract format into an object of type ContractMaturity.

Methods

parse(...) Convert a futures contract format into an object of type ContractMaturity.
parse(contract_id_str: str) → Backends.ContractMaturity.ContractMaturity[source]

Convert a futures contract format into an object of type ContractMaturity.

Parameters:

contract_id_str : str

Futures contract description in the format contract month code + year

Returns:

contract_maturity : ContractMaturity

The representation of the futures maturity in a ContractMaturity format

Examples

>>> from Parsing.ContractIdParser import ContractIdParser
>>> contract_id_parser = ContractIdParser()
>>> futures_format = "m17"
>>> contract_maturity = contract_id_parser.parse(futures_format)
>>> print(contract_maturity)
Contract Maturity: Jun-17