-3

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:

  1. 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)
           ...
    
  2. 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?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Thdh
  • 81
  • 4

1 Answers1

0

Let me guess, you have a directory for libs and other directory for the programs, haven't you? If that's the case, you have a problem with your path.

In StackOverflow you have already similar questions with the answer:

Community
  • 1
  • 1