For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
After optimization, how to obtain optimization results ?
-
I usually use:
def stop(self): print("stop(): ", self.params.Para0, self.broker.getvalue(), self.broker.get_cash())
After optimization, It just print message. how to obtain opt results?
-
please go over the following docs:
- https://www.backtrader.com/docu/cerebro/#returning-the-results
- https://www.backtrader.com/docu/optimization-improvements/#results-management
some example from the docs:
def runstrat(pargs=None): args = parse_args(pargs) cerebro = bt.Cerebro() data = bt.feeds.BacktraderCSVData(dataname=args.data) cerebro.adddata(data) cerebro.addanalyzer(bt.analyzers.Returns) cerebro.optstrategy(StFetcher, idx=StFetcher.COUNT()) results = cerebro.run(maxcpus=args.maxcpus, optreturn=args.optreturn) strats = [x[0] for x in results] # flatten the result for i, strat in enumerate(strats): rets = strat.analyzers.returns.get_analysis() print('Strat {} Name {}:\n - analyzer: {}\n'.format( i, strat.__class__.__name__, rets))
-
thanks, it is useful to me.