Implement a string representation of the options chain

This commit is contained in:
moshferatu 2024-02-13 08:36:20 -08:00
parent 7119af4e34
commit a0f4b62f65

View File

@ -35,4 +35,7 @@ class OptionsChain:
def closest_contract_by_strike(self, target_strike: float, option_type: OptionType):
options = self.options_by_type(option_type)
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)