Finally, in your code, make sure you have something like the following lines:
# import the file at the top of your code where "BasicTradeStats" is the name of the class
from extensions.analyzers import BasicTradeStats
# add the strategy to cerebro
opt_runs = cerebro.run(maxcpus=1, runonce=False)
for run in opt_runs:
for strategy in run:
# finally, this will print the analyzer
As for good practices - don't have much - it works pretty well as it is. As with all databases there are many ways of performance tuning in the InfluxDB database itself - starting with engine parameters, indexing, proper tags selection, hardware upgrade (in case you are serious about your data) and so on - however this is a far bigger topic and is not suitable for a simple post (just google 'influxdb performance tuning' - there are a lot of resources and tutorials)
AFAIK IB could only be requested to provide either ticks (default) or real-time 5 sec bars ( if rtbar parameter is set to True in getdata method). In case of ticks, backtrader is transforming it to look like bars with open/high/low/close prices set to the tick price.
In your case the ticks are requested ( rtbar is false by default) so you may get the 'tick' bar every time it is available ( could be much faster than 1 second depending on what your are trading). The fact that both timeframe and compression arguments were provided to the getdata method is irrelevant for live feed (they only used for getting the historical data AFAIR).
As for replay anomaly, I'm not sure here - probably others may help.
Any updates on this topic? I am trying to obtain simpler risk management except that when the current close price is greater than 5% of my entry price, I want to be able to amend my initial stop loss to breakeven stop.
I tried using the bracket example in backtrader and manually add orders when the TP1 is obtained. Then I place a new order. However, when the trade is closed, that newly issued breakeven stop is still dangling.
Is there any example that shows how I can implement bracket order with amdendent?