Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PicklingError in 00_dx_quickstart, 06_dx and 13_dx notebooks #2

Closed
finmod opened this issue Jan 7, 2016 · 2 comments
Closed

PicklingError in 00_dx_quickstart, 06_dx and 13_dx notebooks #2

finmod opened this issue Jan 7, 2016 · 2 comments

Comments

@finmod
Copy link

finmod commented Jan 7, 2016

Running dx-master locally on Windows 8.2, Anaconda 2.4.1 and python 2.7, the following error arises at ln[34]


PicklingError Traceback (most recent call last)
in ()
----> 1 port.get_values()

C:\Users\Denis\Finmod\dx-master\dx\dx_valuation.pyc in get_values(self, fixed_seed)
905 if self.parallel is True:
906 self.underlying_objects =
--> 907 simulate_parallel(self.underlying_objects.values())
908 results = value_parallel(self.valuation_objects.values())
909 # iterate over all positions in portfolio

C:\Users\Denis\Finmod\dx-master\dx\dx_valuation.pyc in simulate_parallel(objs, fixed_seed)
1130 for o in objs:
1131 procs.append(mp.Process(target=worker, args=(o, output)))
-> 1132 [pr.start() for pr in procs]
1133 [pr.join() for pr in procs]
1134 results = [output.get() for o in objs]

C:\Users\Denis\Anaconda3\envs\py27\lib\multiprocessing\process.pyc in start(self)
128 else:
129 from .forking import Popen
--> 130 self._popen = Popen(self)
131 _current_process._children.add(self)
132

C:\Users\Denis\Anaconda3\envs\py27\lib\multiprocessing\forking.pyc in init(self, process_obj)
275 try:
276 dump(prep_data, to_child, HIGHEST_PROTOCOL)
--> 277 dump(process_obj, to_child, HIGHEST_PROTOCOL)
278 finally:
279 del Popen._tls.process_handle

C:\Users\Denis\Anaconda3\envs\py27\lib\multiprocessing\forking.pyc in dump(obj, file, protocol)
197
198 def dump(obj, file, protocol=None):
--> 199 ForkingPickler(file, protocol).dump(obj)
200
201 #

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in dump(self, obj)
222 if self.proto >= 2:
223 self.write(PROTO + chr(self.proto))
--> 224 self.save(obj)
225 self.write(STOP)
226

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save(self, obj)
329
330 # Save the reduce() output and finally memoize the object
--> 331 self.save_reduce(obj=obj, *rv)
332
333 def persistent_id(self, obj):

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save_reduce(self, func, args, state, listitems, dictitems, obj)
423
424 if state is not None:
--> 425 save(state)
426 write(BUILD)
427

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save(self, obj)
284 f = self.dispatch.get(t)
285 if f:
--> 286 f(self, obj) # Call unbound method with explicit self
287 return
288

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save_dict(self, obj)
653
654 self.memoize(obj)
--> 655 self._batch_setitems(obj.iteritems())
656
657 dispatch[DictionaryType] = save_dict

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in _batch_setitems(self, items)
685 for k, v in tmp:
686 save(k)
--> 687 save(v)
688 write(SETITEMS)
689 elif n:

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save(self, obj)
284 f = self.dispatch.get(t)
285 if f:
--> 286 f(self, obj) # Call unbound method with explicit self
287 return
288

C:\Users\Denis\Anaconda3\envs\py27\lib\pickle.pyc in save_global(self, obj, name, pack)
752 raise PicklingError(
753 "Can't pickle %r: it's not found as %s.%s" %
--> 754 (obj, module, name))
755 else:
756 if klass is not obj:

PicklingError: Can't pickle <function worker at 0x0000000020680668>: it's not found as dx.dx_valuation.worker

The same arises in 06-dx-prtfolio-parallel notebook and 13_dx_quite_ complex_portfolio notebook, in short everytime port.et_values or port.Get_statistics is used.

In addition, the recently updated vc.vega('gbm1') in 04_dx_valuation notebook and others produces this error:


TypeError Traceback (most recent call last)
in ()
----> 1 vc.vega('gbm1')

C:\Users\Denis\Finmod\dx-master\dx\dx_valuation.pyc in vega(self, key, interval)
513 def vega(self, key, interval=0.01):
514 if len(self.instrument_values) == 0:
--> 515 self.get_instrument_values()
516 asset = self.underlying_objects[key]
517 if interval < asset.volatility / 50.:

C:\Users\Denis\Finmod\dx-master\dx\dx_valuation.pyc in get_instrument_values(self, fixed_seed)
471 for obj in self.underlying_objects.values():
472 if obj.instrument_values is None:
--> 473 obj.generate_paths(fixed_seed=fixed_seed)
474
475 def update(self, key=None, initial_value=None, volatility=None,

C:\Users\Denis\Finmod\dx-master\dx\dx_models.pyc in generate_paths(self, fixed_seed, day_count)
186 ran = np.dot(self.cholesky_matrix, rand[:, t, :])
187 ran = ran[self.rn_set]
--> 188 dt = (self.time_grid[t] - self.time_grid[t - 1]).days / day_count
189 # difference between two dates as year fraction
190 rt = (forward_rates[t - 1] + forward_rates[t]) / 2

TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'float'

Thank you for your attention.

@yhilpisch
Copy link
Owner

Fixed the vega bug. Cannot replicate the pickling errors (works under Ubuntu as desired). The multiprocessing module might not work as desired under Windows. Setting parallel=False should circumvent the problem even if it does not solve it.

@finmod
Copy link
Author

finmod commented Jan 8, 2016

Thank you Yves for your prompt intervention. Superb work.

From: Yves Hilpisch [mailto:notifications@github.com]
Sent: Friday, January 8, 2016 1:40 PM
To: yhilpisch/dx dx@noreply.github.com
Cc: finmod denis.richard@dr.com
Subject: Re: [dx] PicklingError in 00_dx_quickstart, 06_dx and 13_dx notebooks (#2)

Fixed the vega bug. Cannot replicate the pickling errors (works under Ubuntu as desired). The multiprocessing module might not work as desired under Windows. Setting parallel=False should circumvent the problem even if it does not solve it.


Reply to this email directly or view it on GitHub #2 (comment) . https://github.com/notifications/beacon/AMHyItvjskrfa5aDsGKeGo07ORX7BkB_ks5pX6WjgaJpZM4HAuPh.gif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants