@jimmyliu @ThatBlokeDave @BernardLin @jf @Amien-Johaadien this may have been an addition since this thread was started - but using the a CommInfo object you can set mult to scale your profit/loss. In the FOREX sense, you can update your commission scheme during next with the relevant exchange rate in order to 'scale' your profits/losses back to your account currency.
Strategies DO NOT loop. They are passive and called by the system, i.e.: they are event based.
If something is wrong in your code ... it is in the code you don't show.
In any case ... all these if something is True tests are WRONG
@Joshua-Cheong said in Strategy runs with no end - is it looping?:
if self.view[d] is True:
You don't know if a True value is being stored. You want to test for something to be true and not for something to be True. Hence
here is a prototyped attempt to this - it has been tested live and does the job for my needs, but code clean up required.
it's a WIP and considering this is not "crucial for me", I cannot guarantee I ll work beyond that proto.
Really nice discussion. Check out this talk by John Reese on multithreading out of GIL and asyncio (be warned that your laptop may spontaneously combust :P ) : https://www.youtube.com/watch?v=0kXaLh8Fz3k&feature=youtu.be&t=10m30s
To learn more on asyncio : https://realpython.com/async-io-python/#the-asyncio-package-and-asyncawait
To learn more on GIL : https://realpython.com/python-gil/
Keep the good work guys ;)
@Sasha consider using the replay datafeeds functionality of Backtrader. This allows you to make trading decisions on a lower timeframe while your higher level algorithm still operates on the higher timeframe. For instance, my system looks at indicators to make choices on the 1D candle, but my entries and exits are made on the 1H level. This way I can place a trade 1H before the close of the 1D candle and my trading results will be much more accurate.
It's difficult to quote an image ... it seems posting images it's the new black these days.
In any case I didn't know that ta-lib had safediv parameters and in any case the exception catcher you have is non-relevant. Things are lazily evaluated and you get to the evaluated result in next
I suggest you look at the RSI code to see how to handle potential div by zero.
Although your real problem is data variability which no code can fix.