@yelloww said in Save cerebro data to file for later plotting it on another computer:
I found this package, dill which successfully saves a pickle of cerebro.
However, upon trying to unpickle or load, it fails :(
# open a file, where you stored the pickled data
pickled_file = open('pickled_cerebro_willy-v0.07', 'rb')
# pull information into the world
eat_the_pickle = dill.load(pickled_file)
# close the file
AttributeError Traceback (most recent call last)
<ipython-input-8-1c94c425ea19> in <module>()
5 # pull information into the world
----> 6 eat_the_pickle = dill.load(pickled_file)
8 # close the file
/anaconda3/lib/python3.6/site-packages/dill-0.2.9.dev0-py3.6.egg/dill/_dill.py in load(file, ignore)
302 # apply kwd settings
303 pik._ignore = bool(ignore)
--> 304 obj = pik.load()
305 if type(obj).__module__ == getattr(_main_module, '__name__', '__main__'):
306 if not ignore:
/anaconda3/lib/python3.6/site-packages/dill-0.2.9.dev0-py3.6.egg/dill/_dill.py in find_class(self, module, name)
463 return type(None) #XXX: special case: NoneType missing
464 if module == 'dill.dill': module = 'dill._dill'
--> 465 return StockUnpickler.find_class(self, module, name)
467 def __init__(self, *args, **kwds):
AttributeError: Can't get attribute 'AutoInfoClass_LineRoot_LineMultiple_LineSeries_LineIterator_DataAccessor_StrategyBase_Strategy_BigWillyStyle' on <module 'backtrader.metabase' from '/anaconda3/lib/python3.6/site-packages/backtrader/metabase.py'>
In order to read in as a dataframe what I really want is a row of headers that contain the labels for each data point and then each subsequent row represents the value at a point in time.
I looked into subclassing bt.Writer but the Header and each line of values comes pre-populated from the Strategy and DataSeries classes and the way that it is formatted doesn't provide anyway of knowing where each indicator starts and ends.
What I ended up doing instead was to override the getWriterHeaders and getWriterValues function in the Strategy. This allowed me to format the header and the values in the way I wanted.
This works for the indicators and any data coming from the Strategy, however it doesn't solve the problem for the data series. I can't see any easy way to override these functions for the data series.
@backtrader said in TradeAnalyzer with bracket orders problem?:
If you look at the documentation: Docs - Analyzer Reference - Sharpe Ratio, you will see that the default timeframe is Years. This is because this is what people use.
I think w.r.t. SharpeRatio, I need to better understand how people use Sharpe ratios when trading smaller timeframes, or perhaps how to configure the backtrader Sharpe ratio for 5 Minute timeframe candles...
The convention in backtrader is to give you the time at which the candle ends. The reason is that this makes sense when looking at how the candle is constructed in real-time or using replaydata. The last incoming data point is the last one adding info to the candle, not only in terms of price action and volume, but also at which time it has happened.
It would be weird, imho, if a data point which happened at 00:03:59:59.9999 were to be shown in a candle with a timestamp of 00:00:00.0000
@backtrader said in Does Backtrader support multiple brokers?:
As long as your wrapper looks and conforms to what's expected from the broker.
to give some context to my question I want to use @Ed-Bartosh ccxt development for backtrader.
ccxt is already a wrapper for multiple crypto brokers, so as I see it, all that is needed is to change the 'exchange' value at the store.
I'm trying to understand what will be the implications (if any) of making those switches at runtime?
(backtesting, analyzers, observers...)
@tw00000 said in Trailing take profit:
It does seem in times of volatility the StopTrailLimit would be very disadvantageous - are there any advantages?
It can be problematic. I've had markets go right over my limit. The only thing I do is have a OCO stop market order further than the trail in case markets go crazy and I'm not there to do something.
With multiple cores and processes, a new cerebro per process is created. When you restrict things to a single core, the same cerebro and broker are reused.
It was not foreseen that someone would be accessing the broker from outside the methods.
His/Her marks were NOT missing, because no operations were executed.
In your case, you may want to share:
Which would be the minimum to ascertain that you indeed are missing your marks.