See Docs - Plotting
You can control subplotting with the option: subplot. You can pass it directly to the constructor of the indicator. It will be used as a plotting option if it doesn't conflict with a defined parameter or you can set it like:
myindicator.plotinfo.subplot = False
I would like to contribute in docs to start with by fixing typos etc. Please advise where and how I can help.
You can for example submit pull-requests to:
https://github.com/backtrader/backtrader (if the problem is in a docstring)
https://github.com/backtrader/backtrader-docs (if the problem is in in the main text)
You ma also open a topic with your findings providing some context as to where the typos are (for example, page link and the sentence with the typo ... you can easily highlight the typo in the Communty using markdown)
@asuralm said in strategy performance on multi-data:
do the two different data have to be the same length? e.g., one data starts from 2000 and the other is from 2010
No, but your system won't start trading until 2010. Because the system is only active when all data feeds are delivering. You can hook into prenext, but in this method it is no guaranteed that you can access the buffers of data feeds, indicators and others.
how do I obtain the performance of the strategy on the two data respectively?
https://www.backtrader.com/docu/cerebro.html (Section: Returning the results)
result = cerebro.run(**kwargs)
The format of result returned by run will vary depending on whether optimization is used (a strategy was added with optstrategy):
All strategies added with addstrategy
result will be a list of the instances run during the backtesting
1 or more strategies were added with optstrategy
result will be a list of list. Each internal list will contain the strategies after each optimization run
within the strategy, is there a way to know how many datafeeds are added to the cerebro?
No magic here. Standard Python. Trying it is faster as asking (believe it)
You then need to have 5 optimizations (the sample shows 2) and the StFetcher instantiating the appropriate strategy with the appropriate parameters. In the example idx is used as the key to decide which strategy to return. The same idx can be used to decide which strategy to instantiate and with which parameters.
There is no handling of unlisted stocks, because that information is not part of the payload of data feeds.
Data feeds are extensible which means you can add a line named (for example) delisted which has a value of (for example) 1 if the stock becomes delisted (and 0 if not). At that moment in time you can close the position.
The challenge here:
If the 1 is aligned with the end of the listing, the order won't be executed because there is no more data.
Use cheat-on-close. But this will affect the entire lifetime of all the listings
Add the 1 just one days before the asset is delisted
The referenced link from above seems to indicate so. But for backtrader there is no distinction as to what is a live and a paper account. Everything is a TCP connection. Data delivery, trading and everything is controlled by TWS.
Things that could help in diagnosing your problem:
Run ibtest.py against your live account. As long as you don't provide the --broker (create an IBBroker) and --trade (engage into actual trading) nothing will be done
If you don't want to blindly trust not using the options mentioned above, you can also:
Set the API to read-only in the TWS settings. Even if backtrader wanted to issue orders, these would be rejected.
Remove the trading code from ibtest.py
You can also show:
The command line you used to run ibtest.py
The output the command produced
Note: See the top of the forum for formatting your code (Place ``` in a line before and *after your code)
You only issue buy orders if not in the market, so once in the market you won't execute any more orders.
Oh, nothing in particular - I retrieved backtrader via git and I got errors about the aforementioned lines during the conversion to .pyc files during the installation process.
I supposed that maybe someone else encountering the same problem might benefit from the corrections.
One thing you can try:
cygwin (i.e.: bash in mintty) as the shell
Have Anaconda or WinPython installed somewhere
Put the location of the python.exe from your chosen distribution in the PATH
And you get the best of both worlds
I also wonder about the discrepancy. The closing price is 26.27. The sell creation order is 26.27. But then price and cost of that order is 27.25. There could be something like slippage, but in the tutorial no slippage is being set. The value 27.25 is not in the CSV either so it's generated somehow.
2000-01-13, Close, 26.27
2000-01-13, SELL CREATE, 26.27
2000-01-14, SELL EXECUTED, Price: 27.25, Cost: 27.25, Comm 0.03 ## Note the change in Cost here!
The ta-lib developer has been so kind as to re-expose the interface that made automatic parsing of ta-lib functions possible.
PyPi Package: https://pypi.python.org/pypi/TA-Lib/0.4.15
Issue #176: https://github.com/mrjbq7/ta-lib/issues/176
Upgrading to 0.4.15 should solve the problem.