Regardless of the joke, you seem to completely miss the point, because you post the chart from the main page. To what purpose, unknown.
If you do something and the results are not the expected ones ... a chart IS NOT the answer. Any attempt at being profitable at algotrading will require producing lots of information.
How do you think that I quickly identified the problem and why the actual data delivered by Yahoo doesn't match what is displayed as an example on the main page?
As you may see the first thing was producing output to understand that the moving averages were converging during two days to have exactly the same values 21.38 and 21.36. That's why the original definition of the CrossOver indicator is not able to cope with the scenario, because when sma1 > sma2, the condition for the previous day isn't met (it was sma1 < sma2), because the moving averages had exactly the same value.
Hence the need to change the definition and make the crossover formula consider the last non-zero-difference between the input data feeds, which as shown in the data is -0.08 from 2011-12-15 where the values are 21.31 and 21.39
You have to consider additionally that the input data will keep on changing, fact which you apparently ignore because you seem fixed on the chart from the main pge, because the prices will be adjusted for dividends and splits. In one year, the prices from MSFT may be halved or doubled and bear no apparent relationship to the chart from the main page.
This adjustment is what actually created the no-difference conundrum which shows that the simple formula to define a crossover (present in the documentation) was too simple and needed to be extended.
Thank you very much for your reply.
I have just found out the solution, and am coming to explain it.
You are perfectly right, the trouble comes from the date format that is written in the csv file 1st.
So to the interested reader, no modification is required in backtrader python script.
Only a single line does the job in the script to write the csv file, that is found in backtest-rookies blog:
data = [[exchange.iso8601(candle)] + candle[1:] for candle in data]
solution comes actually from CCXT bugtracker:
I will post this as a comment to the backtest-rookies blog as well.
Thanks again @backtrader
Have a good afternoon.
To the interested readers: maybe to confirm there are some other users interested, and to see how many, can you take part to the poll and vote for this feature?
The button to vote is quite hidden actually: you have to look at it in the right top corner of Justin Zhang's initial post:
there is one tiny ^ ,
next to it the number of votes,
and then a as tiny v next to it
like this: ^ 1 v for instance
To vote up, you have logically to click on ^ symbol :).
I thank you for your involvement.
@pipeline-punch said in Struggling to implement custom Pandas data feed:
If the custom Pandas DataFrame contained the same columns as we have been working with, but multiple "assets" instead of just one (as in the example we've been working with) - how would everything work? Similar to how we've done it above, or something a bit different to deal with the dual-indexing?
bt's PandasData requires separate DataFrame for each stock ticker. But since
Now that I know the structure of how to do this, I feel confident I can now pull in any custom Pandas data frame I would like!
than you can write your own Pandas data feed which will take care about multiple assets in the single DataFrame.
It depends on the amount of time you have and your python skills.
You are absolutely right, the problem is not with backtrader, but rather with matplotlib. Taking a look at the (excellent) documentation and previous questions have highlighted that for me.
I will post my workaround as soon as I am done.
For others who are stuggeling here, take a look at: