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.
See: Community - Release 18.104.22.168
The trivial fix would have helped, but it wasn't the right one. The real fix was somewhere else, being also mostly trivial.
The SMMA and EMA indicators rely on the previous value to calculate the new one. As soon as one value is NaN, the result will always be the same and NaN. Non-recursive indicators, mostly every other, will recover after a number of calcualtions which is what made it possible for the error to remain undetected for a long while.
The code will work now without having to create null delay object as in
alias = ('RV',)
lines = ('rv', 'nU', 'nD',)
params = dict(
stddev = bt.ind.StdDev(self.data, period=self.p.p1)
u = bt.If(self.data > self.data(-1), stddev, 0.0)
d = bt.If(self.data < self.data(-1), stddev, 0.0)
self.l.nU = nU = self.p.movav(u, period=self.p.p2)
self.l.nD = nD = self.p.movav(d, period=self.p.p2)
self.l.rv = 100.0 * nU / (nU + nD)