@sp I'm looking into same thing right now and would like to see if you guys figured it out.
Can you drop me a line if you had any progress with this.
Thanks!
@sp I'm looking into same thing right now and would like to see if you guys figured it out.
Can you drop me a line if you had any progress with this.
Thanks!
Re: Example code for live trading using binance
I'm trying to use the CCXTStore library to create a Strategy that uses multiple timeframes (1h and 5m). For that I need to figure out how to add additional datafeeds into Cerebro.
With CSV data it is easy, I can simply create two data objects and add them to Cerebro one-by-one with adddata method. However, this does not work with CCXTStore.
Is it possible to add multiple timeframes using CCXTStore and how?
Okay, so I figured out getting the name part as well. Instead of using iterator directly, we can get a tuple of lines defined inside the indicator with _getlines() method. Then we can loop over that tuple and each time call _getline() method with line name to return the actual lines object from which we can get the data sample.
Example code:
for ind in self._owner.getindicators():
line_names=ind._getlines()
ind_name=type(ind).__name__
for line_name in line_names:
line=ind._getline(line_name)
print("Indicator "+ind_name+" line "+str(line_name)+" value is "+str(line[0]))
Still working on the other issue with LinePlotterIndicator() method as mentioned above so if anybody can help then that would be greatly appreciated!
I figured out part of this on my own.
So, when inside observers next() method we have reference to strategy object (via self._owner). Strategy object has a method getindicators() which returns an iterator, so we can plug this straight into for-loop and loop over all indicators one-by-one. To access data (lines) inside those indicator objects we can access lines attribute which again returns an iterator so when plugged into for-loop we can loop over all defined lines one-by-one.
Example code:
for ind in self._owner.getindicators():
for line in ind.lines:
print(line[0])
Right now I'm trying to figure out how can I get the indicator lines name so I know which data I'm dealing with.
Also, if indicators are not defined as a separate class, but are calculated inside the strategy and then plotted using LinePlotterIndicator() method then I'm not sure yet how to access those samples. This is next thing that I hope to figure out
Hey,
Is it possible to somehow get a list of all indicators that are added to the strategy when inside the observer next() method. I know that we can access datas, broker, trades and orders data via
self._owner attribute. The indicator objects are listed there as well, so we can access them.
However, is there an attribute which holds a list of all indicators that are added to this strategy? So we could actually loop over indicators and would not need to have a prior knowledge of what indicators are added.
@sp I'm looking into same thing right now and would like to see if you guys figured it out.
Can you drop me a line if you had any progress with this.
Thanks!
Hi,
I want to implement forward/paper trading using the backtrader. I have already more-or-less figured out how I will get the latest data. I will write a custom module which will monitor ticker-time pairs that user specifies on tradingView and if any of those has a new candle released then it will retrieve that and append to data set.
I was thinking that in my strategies Next method I will check if the current sample is the last one and if it is then it will just block until there is a new sample in the data feed. Before that it will run as normal so we can start with historic data and then transit into forward testing (good because then all the SMA and other such indicators are already up and running).
However, the difficult part is how to append those new candles into backtrader data feed while the test is running. Is there a way to append data into data feed while the test is running or would that break the test?