-1

I am trying to re-excecute the notebbok explained in this video. However I get the error message when I try to import to_datetime form utils library which is correctely installed on my system (Win 7 enterprise).

from QuantLib import *

import pandas as pd
import utils
from utils import to_datetime, format_rate
utils.set_default_plot_size()

from matplotlib.dates import MonthLocator, DateFormatter

What I get is the usual ImportError

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-19-230e0aaadc54> in <module>()
      3 import pandas as pd
      4 import utils
----> 5 from utils import to_datetime, format_rate
      6 utils.set_default_plot_size()
      7 

ModuleNotFoundError: No module named 'Stocazzo'

any idea for solution?

Oscar
  • 460
  • 3
  • 18
  • 1
    Don't post pictures of code. But do you have a file called utils.py, and does it contain a function called to_datetime? – Daniel Roseman Jun 04 '18 at 11:02
  • Sorry, it was meant as a picture of the error log. I am looking for such a file, but the one I find does not contain that function. – Oscar Jun 04 '18 at 12:02
  • what exactly is utils module? it may be some custom module, writrwn by video authors, or I'm wrong? what do `import utils` and `dir(utils)` say? – Evgeny Jun 05 '18 at 17:16
  • same for error log, it has to be text, not picture, @Oscar – Evgeny Jun 05 '18 at 17:19

1 Answers1

1

The module utils.py imported in the video contains a few small functions that I don't define explicitly in each notebook in order to reduce verbosity. It's available for download with the QuantLib Python Cookbook, together with the notebooks themselves. The module you have on your system is probably a different one with the same name.

If you don't want to get the cookbook, the function is simple enough to write yourself. Given a QuantLib Date object d, you have to return datetime.date(d.year(), d.month(), d.dayOfMonth()).

Luigi Ballabio
  • 4,128
  • 21
  • 29