I am moving from a functional approach to a more object oriented approach for building a library of valuation models for (derivative) financial instruments in Python. I keep getting error messages that I do not understand.
Let me first explain what I am doing:
I create a class where I define and store the common attributes of the product for which I am building a valuation model. As an example, let’s work with the class
Option
:class Option(object): def _init_ (self, S0, ..., params): self.So = S0 ... self.div = params.get('div',0) ...
I then build a class for the valuation of the option (let’s work with a binomial model)
from Option import Option class BinomialOption(Option): def _setup_parameters_(self): self.X = ... ........
When I do this, get an import error:
ImportError: No module named 'Option'
I do not understand why this happens. I created a class, and I ran it before running the BinomialOption class.
Why do I get this error message? And how do I prevent it?