Hi @Rodrigo Brito, On another note, have you faced any other major/minor issues/bugs while running the Backtrader+CCXT live so we need to be aware of before go live? Any special error handling or Binance broker specific issues we might face? Thanks
@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.
@run-out said in What are different between bta-lib, ta-lib and internal BackTrader indicators?:
@Quỳnh-H-Nguyễn This is still an awesome tool. And if you wanted to create a line preloading into cerebro, this would make it dead easy. Cheers
yeah, I got some times and don't know the reason. However, it is simple for a rookie like me to begin!
As mentioned by @ab_trader orders are executed on the same bar if you set coc=True in the broker. If not the bar is considered closed and order execution is deferred until the next bar. Two orders issued on the same bar with Market execution policy should be executed also on the same bar (be it the next or the current bar)
The system does a check of submitted orders before accepting them. To avoid for example having 2 consecutive orders which would go over the actual cash reserves on the same bar. If tries to take into account that if a long position is closed cash will be re-injected into the system to let you operate with another buy.
Deactivation of the check can be achieved in the broker with checksubmit=False
Sizers are called internally by buy and sell (close uses the actual existing position) but a Sizer can be subclassed to provide complex functionality.
In that documentation page there are examples of how the modification of _getsizing achieves policies, like for example reversing a position or keeping it long only.
Hopefully solved from the python side, not backtrader library. See answer in SO about one more stub class.
Overall abstract classes makes me a little bit of pain in python. Maybe sometimes I'll master metaclasses :)
An extra fix has been pushed to the development branch, because @randyt also checked it out and found a typo in the part which services historical data downloads between 2 dates (the part initially tested, downloads as much as possible and not between two given dates, which may happend during a disconnection/reconnection cycle)
The final implementation, already pushed to the development branch, respects the original implementation by Ehlers and rather than expecting the price component to have high and low it takes simply self.data (which unless changed is the close from regular data feeds)
Using it for the midpoint of the bar is easy:
midpoint = (self.data.high + self.data.low) / 2.0
lrsi = bt.ind.LRSI(midpoint)
The advantage of not having specifics like high and low in the code is that the LRSI can be calculated for anything which is a data feed or descendant of ... you could create the LRSI of a SimpleMovingAverage
You can also shoot yourself in the knee and then see if it hurts. The problem is the data provider and the amount of symbols requested from it. Blocking a thread 15 seconds to try to overcome a structural problem is not the way.
Feel free to do it yourself.
The default for notifications are accumulated and delivered before next is called. They are not delayed in any case with regards to what you see.
The design was so chosen to keep things in a straight line and users not having to care about asynchronous or threaded events.
In the most recent versions you can change that behavior if you wish by passing quicknotify=True to cerebro.
See Docs - Cerebro
Params just appears to be a dict. To pass arguments you would want kwargs. I believe what you are asking is "How do I convert a dict to kwargs?"
Here's a q&a that might help:
That I thought, Pythonized:
upw = dtr==false and dtr[-1] and utr
dnw = utr==false and dtr[-1] and dtr
Meaning upw is true if current dtr is false and utr is true and the previous dtr is false. This would mark an upward trend change.
upw = (not dtr) & dtr[-1] & utr
dnw = (not dtr) & dtr[-1] & utr
Hi! Nice plots. I was looking into Bokeh sometime ago, but wasn't able to do any valuable staff. Not a lot of experience with python.
Can you share more details on the plotting with alternative package? Do you pass bt data directly into it or pass it to pandas (for example) first and then use in the plotting package?