Open moritzgun opened 3 years ago
Same problem on my end!
Same problem on my end as well. Does anybody have a fix for this? Maybe we can create a fork and publish it on pypi ... seems like the developer is not updating this library anymore. :(
with btalib.stochastic(df) same problem, memory leak very fast.
https://stackoverflow.com/questions/13784192/creating-an-empty-pandas-dataframe-then-filling-it
This may solve the issue? Never append a row to a dataframe
Every indicator with btalib inside a loop is filling memory, even if we use del to free variables returned. This is a big issue.
I am running a MultiplexSocket on Binance API to get 5 minute klines of around 200 symbols. On every new completed candle I call a "run_technical_analysis" function. Inside that function I calculate indicators for each symbol like this:
period = 14 value = btalib.ema(candlesticks_df.tail(period + 1), period=period) ## Version A
value = candlesticks_df.Close.tail(14).ewm(span=14).mean() ## Version B
After that I append value.df.tail(1) to a list. On Version A my RAM goes up almost 10 MB every 5 minutes. It seems like the allocated memory for 'value' is not beeing freed. When I use Version B instead there is no such issue.
What can I do to reduce that memory usage?