MiniXC / simple-back

A simple daily python backtester that works out of the box.
Mozilla Public License 2.0
59 stars 12 forks source link

update order_pct with long/short #17

Closed natemoser closed 4 years ago

natemoser commented 4 years ago

I cloned master today and went wandering into the simple-back/examples/, and running this notebook got me

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-f7b1664cae11> in <module>
      4         jnug_ma = b.prices['JNUG',-20:]['close'].mean()
      5         if b.price('JNUG') > jnug_ma:
----> 6             b.order_pct('JNUG', 1)  # positive == long
      7         if b.price('JNUG') < jnug_ma:
      8             b.order_pct('JNUG', -1) # negative == short

AttributeError: 'Backtester' object has no attribute 'order_pct'

So here I've simply replaced order_pct with simple_back.backtester.Backtester.long and simple_back.backtester.Backtester.short and re-run the notebook.

Granted, most of this same content is covered in https://minixc.github.io/simple-back/intro/quickstart.html with more documentation, so you may want to just want to remove this notebook.

MiniXC commented 4 years ago

That particular notebook has already been moved to the documentation, so I will remove it in the next release, your fix will be fine for now though. I can't guarantee the other examples work at the moment as well, I will migrate them to the docs in the next release and check they are still working. The build failing also reminds me I should fix #8 for future pull requests