Base and quote currencies
I want to use multiple live data feeds. All but one have BTC as quote currency(LTC/BTC, XRP/BTC, ADA/BTC, ...). The last data feed has BTC as a base currency (BTC/USDT). How can I let cerebro know that the last data pair has to be swapped ?
Does it actually matter? My understanding is that Backtrader is agnostic to such considerations insofar as calculations go.
I think it does matter. In the context that I described above my cash currency is BTC. With BTC, I buy other cryptocurrencies, including USDT. All coins but USDT are listed in the BTC market. BTC is listed in the USDT market.
So instead of returning the price of 1 USDT in BTC (currently 0.00009557), the exchange API returns the price of 1 BTC in USDT (currently 10666).
What I mean is, why don't you just invert it yourself? You can also create an indicator that inverses it and use that as one of your lines (I think, not 100% sure on this).
The best way seems to apply a filter to the data feed and invert the value.
With a filter you intercept each data point and deliver it changed.
They are easy to implement. See Docs - Filters
To double the closing price
class CloseDoubler(object): def __init__(self, data): pass def __call__(self, data): data.close *= 2.0
@backtrader This looks like the right way.
Thanks to both of you! This looks like exactly what I was looking for. I am going to try it out.