@ed-bartosh ccxt had some unique properties that made it possible to implement the broker straight from BrokerBase and give access to more then 1 exchange simultaneously in a way that feel very integrated and easy to use. remember that ccxt project is all about unifying the variety of exchanges under one api.
and a key part of my development was that the feed had some exchange info inside it.
but to make a more generic broker means to really create a broker that hold a collection of brokers inside (that are not really unified) and switching between them like you proposed before.
The biggest problem this way, is that there are still methods that will get called by Backtrader in the background on the 'active' broker without the intention of the user.
A better solution that may work more like what i wrote is if every feed will hold some broker information in a well known way and then you don't need to guess on what broker.
@gminorcoles I am just a user of the bt, not an owner. Sometimes I share pieces of the code. @backtrader is an owner.
if you want/can offer any enhancements, then just create pull request with that enhancement. @backtrader will check it and incorporate if it will be suitable from his point of view.
@blonc said in Strategy Selection Pattern:
The concept I am trying to achieve is to have many strategies all being monitored by a master strategy. This way, the master strategy could be using a markov chain to monitor returns to turn on and off individual strategies based on the total returns of all strategies. It seems the best path is to , correct me if wrong, put the strategies logic into indicators and bring them into one master strategy.
@backtrader said in Strategy Selection Pattern:
Sub-strategies is not a pattern which does exist in backtrader. Using Indicator instances could do the trick.
Was also thinking about utilizing the concept of having a "master" strategy turning on and off "micro strategies", so I'm glad I found this post :)
I can think of a lot of use cases for using a master strategy that based on a wide overview of a market/s can control what micro strategies are suited to be used.
the idea of using indicators as sub-strategies seem brilliant (haven't tested it yet).
but from my understanding strategies can be better analyzed and give valuable insights. I hope we can wider the discussion just to explore more solutions (as @backtrader mentioned nested strategies are not supported)
one idea I have that I don't think break backtrader structure is:
declaring a 'master' that run first and based on whatever user logic it creates a 'signal dictionary' that is then passed to all other micro strategies. allowing them to decide if to run or not in next().
this way all strategies are kept in the same level of operation (not nested)
I'm learn to use backtrader ,and I'm trying to use the Oandatest.py with some problem. errormsg is the same with you.
I want to know how to run oandatest.py succeed, I have oanda account and token. and pip install oandapy.
but I can't run it succeed. please give me a hand. thanks very much.
So I can loop through all my data in the Next..
self.datas is an array and you can loop over it.
How do I plot the portfolio performance? instead of backtrader printing 1000 different charts...
Depends on what you have defined as performance for your portfolio. There is for example a TimeReturn observer which is intended to plot exactly what the name implies.
If you want to plot other performance indicator, you will need to define it as an indicator or observer
The default is to plot the evolution of the cash and the actual portfolio value which should give a quick indication as to where the system is
And only a single chart will be printed per strategy.
Is there an integrated solution to do this in Backtrader?
There are several samples, blog and documentation pages. See for example:
Docs - Benchmarking
Here the performance is defined as the comparison against another asset.
@bernardlin said in How do I set up correct position close logic?:
Hi, would you mind providing me a link on how 'define a CommissionInfo object which converts the profit and loss (and commissions) of the given pair to your base currency' is done
"Discussed" is not the same as developed.
The problem here is that the broker, being unaware of the order being issued during next_open, tries to see if you are submitting an order which exceeds your current cash reserves (and the current price is already the close)
You can disable the submission check with checksubmit=False. See Docs - Broker
And this other topic for example: https://community.backtrader.com/topic/782/help-with-simple-bband-strategy