@run-out said in How to get the index of the current iteration in next?:
@borutf You can get the current bar but using
len(self)
Thanks.
@run-out said in How to get the index of the current iteration in next?:
@borutf You can get the current bar but using
len(self)
Thanks.
2022-05-17 23:59:59.999989
This happens to every datetime??
I always use bt.feeds.PandasData , it can work on yfinance downloads as well.
@varsha-shingade with the help of analyzers:
cerebro.addanalyzer(bt.analyzers.PyFolio, _name='pyfolio')
strat = cerebro.run(tradehistory=True)
pyfoliozer = strat[0].analyzers.getbyname('pyfolio')
returns, positions, transactions, gross_lev = pyfoliozer.get_pf_items()
transactions.to_csv("transactions.csv")
There are other options with analyzers, because there is so much data you can save.
Seems unusual to me.
May I ask why do you even call super().sell_bracket ?
Why not just self.sell_bracket ? Did you change sell_bracket somehow?
I want to inherit some functions in my strategy from a parent class (BaseStrategy).
Let's use this example:
def notify_cashvalue(self, cash, value):
if value < starting_cash * self.terminate_threshold:
self.log(f'Stopping strategy at due drop below {self.terminate_threshold * 100}% of initial cash.')
self.cerebro.runstop()
This would be the function inside BaseStrategy and my actual strategy would inherit. This function requires that the terminate_threshold is defined in the child strategy. This could be a nuisance if I want to inherit the BaseStrategy, but I don't want that particular method. I know I could rewrite notify_cashvalue, however I would prefer to add the methods I want inherit instead of removing them. I want to customly compose the strategy instead of inheriting everything.
I have seen this before. I don't know how to make it work.
On the other hand I know
data = bt.feeds.PandasData(dataname=yf.download('ORCL', '2011-01-01', '2021-12-01'))
this works.
2022-05-17 23:59:59.999989
This happens to every datetime??
I always use bt.feeds.PandasData , it can work on yfinance downloads as well.
Let's say I want the most readable output for each analyzer that I add to the strategy. Namely, I don't want to go in detail for each specific analyzer.
I know you can call get_analysis() but that prints some orderedDicts.
Right now the output varries between analyzers a lot.
I am using ccxtbt from: https://github.com/Dave-Vallance/bt-ccxt-store
Where do you specify the frequency of fetching the data?
It seems as if the data feed does not work if you only set the fromdate.
Possibly because the lines 309 and 313 backtrader/feeds/yahoo.py only compare if todate is not None. They do this two times, perhaps the second one should compare the fromdate.
OANDA Store , the store uses oandapy which is like a six year old library that uses the defunct version of the API(v1). I have not manage to get it to work, so I am starting to wonder whether it would be better to use some other library such as btoandav20.
What have your experiences been?
If I understand correctly you execute a short order by first executing sell().
I do that and it seems to work correctly based on the sum aggregated from trades.
However I noticed pending order gets executed when the price exceeds the entry price. I want it the other way around, so that it gets executed when the price is lower.