Implement a string representation of the options chain
This commit is contained in:
parent
7119af4e34
commit
a0f4b62f65
@ -35,4 +35,7 @@ class OptionsChain:
|
|||||||
def closest_contract_by_strike(self, target_strike: float, option_type: OptionType):
|
def closest_contract_by_strike(self, target_strike: float, option_type: OptionType):
|
||||||
options = self.options_by_type(option_type)
|
options = self.options_by_type(option_type)
|
||||||
options['Strike Distance'] = abs(options['Strike'] - target_strike)
|
options['Strike Distance'] = abs(options['Strike'] - target_strike)
|
||||||
return options.loc[options['Strike Distance'].idxmin()]
|
return options.loc[options['Strike Distance'].idxmin()]
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return str(self.options_chain)
|
Loading…
Reference in New Issue
Block a user