mementum / bta-lib Goto Github PK
View Code? Open in Web Editor NEWTechnical Analysis library in pandas for backtesting algotrading and quantitative analysis
License: MIT License
Technical Analysis library in pandas for backtesting algotrading and quantitative analysis
License: MIT License
BTA-LIB is running into compatibility issues with Numpy. From backtrader forum:
bta-lib adx() error
@run-out I found the library version incompatibility! I was running with numpy v1.20.1, the latest version. I installed an older version, the version of numpy available right around when btalib v1.0.0 was released, numpy v1.18.2. It worked ππΌ So that means bta-lib needs to be updated to work with the latest versions of pandas and numpy.
Thanks again for taking the time to work this out with me ππΌπ·
Here's my output now:
(sandbox) 13:13 β’ screener β’ master β’ d5822cb β
β― python bta-adx.py
numpy v1.18.2
pandas v1.0.4
btalib v1.0.0
Open High Low ... Volume rsi adx
Date ...
2021-03-22 79.989998 81.269997 79.220001 ... 39648600 44.939105 26.393616
2021-03-23 80.129997 80.339996 77.949997 ... 40466600 41.737588 26.112061
2021-03-24 77.550003 78.800003 76.400002 ... 43753600 38.792404 26.252038
2021-03-25 75.849998 76.949997 74.959999 ... 44735100 38.393151 26.729348
2021-03-26 76.620003 77.500000 75.029999 ... 49109400 41.367524 26.915669
Traceback (most recent call last):
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1014, in setitem
self._set_with_engine(key, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1054, in _set_with_engine
self.index._engine.set_value(values, key, value)
File "pandas/_libs/index.pyx", line 96, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 106, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 116, in pandas._libs.index.IndexEngine.get_loc
TypeError: 'slice(11, None, None)' is an invalid key
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/cosmos/GitHub/haasomeapitools/btalibtest.py", line 23, in
mama, fama = btalib.mama(data.High,data.Low,fastlimit=10,slowlimit=5)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/indicator.py", line 152, in call
b_init(self, *args, **kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/indicators/mama.py", line 79, in init
_mama = p0._ewm(alpha=alpha, span=1, _seed=SEED_ZERO)._mean()
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/meta/lines.py", line 357, in _mean
return self._apply(_dynalpha) # triggers getattr for _apply
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/meta/lines.py", line 379, in call_op
result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1042, in setitem
self._set_with(key, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1064, in _set_with
return self._set_values(indexer, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1111, in _set_values
self._data = self._data.setitem(indexer=key, value=value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 561, in setitem
return self.apply("setitem", **kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 442, in apply
applied = getattr(b, f)(**kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 877, in setitem
check_setitem_lengths(indexer, value, values)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/indexers.py", line 124, in check_setitem_lengths
"cannot set using a slice indexer with a "
When I print this:
btalib.stochrsi(df['close'],period=8).df
I only get one column called "stochrsi". But in all trading platforms the "Stoch RSI" is 2 curves. How do I get the values of those 2 curves?
(The parameters for the Stoch RSI would be "Smooth K", "Smooth D", "RSI Length", "Stoch Length")
I am trying to calculate the ema with the default periods.
import btalib
import pandas as pd
df = pd.read_csv("C:\\data\\nifty2019.csv")
df['Date'] = pd.to_datetime(df['Date'])
kama = btalib.ema(df.Close)
This is giving me an error trace like below. Can you help me to see if something is wrong with the way I am using it?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
C:\app\Anaconda3\lib\site-packages\pandas\core\series.py in __setitem__(self, key, value)
1013 try:
-> 1014 self._set_with_engine(key, value)
1015 except com.SettingWithCopyError:
C:\app\Anaconda3\lib\site-packages\pandas\core\series.py in _set_with_engine(self, key, value)
1053 try:
-> 1054 self.index._engine.set_value(values, key, value)
1055 return
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.set_value()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.set_value()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: 'slice(29, None, None)' is an invalid key
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-3-3a859967fb56> in <module>
----> 1 kama = btalib.ema(df.Close)
C:\app\Anaconda3\lib\site-packages\btalib\indicator.py in __call__(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.__init__ for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes
C:\app\Anaconda3\lib\site-packages\btalib\indicators\ema.py in __init__(self, poffset)
37 def __init__(self, poffset=0): # see above for poffset
38 span, seed, poff = self.p.period, self.p._seed, poffset
---> 39 self.o.ema = self.i0._ewm(span=span, _seed=seed, _poffset=poff).mean()
C:\app\Anaconda3\lib\site-packages\btalib\meta\lines.py in call_op(*args, **kwargs)
377 sargs.append(arg)
378
--> 379 result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
380 result = result.astype(r.dtype, copy=False)
381 return self._line._clone(result, period=self._minperiod)
C:\app\Anaconda3\lib\site-packages\pandas\core\series.py in __setitem__(self, key, value)
1040 pass
1041
-> 1042 self._set_with(key, value)
1043
1044 if cacher_needs_updating:
C:\app\Anaconda3\lib\site-packages\pandas\core\series.py in _set_with(self, key, value)
1062 if isinstance(key, slice):
1063 indexer = self.index._convert_slice_indexer(key, kind="getitem")
-> 1064 return self._set_values(indexer, value)
1065
1066 elif is_scalar(key) and not is_integer(key) and key not in self.index:
C:\app\Anaconda3\lib\site-packages\pandas\core\series.py in _set_values(self, key, value)
1109 if isinstance(key, Series):
1110 key = key._values
-> 1111 self._data = self._data.setitem(indexer=key, value=value)
1112 self._maybe_update_cacher()
1113
C:\app\Anaconda3\lib\site-packages\pandas\core\internals\managers.py in setitem(self, **kwargs)
559
560 def setitem(self, **kwargs):
--> 561 return self.apply("setitem", **kwargs)
562
563 def putmask(self, **kwargs):
C:\app\Anaconda3\lib\site-packages\pandas\core\internals\managers.py in apply(self, f, filter, **kwargs)
440 applied = b.apply(f, **kwargs)
441 else:
--> 442 applied = getattr(b, f)(**kwargs)
443 result_blocks = _extend_blocks(applied, result_blocks)
444
C:\app\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py in setitem(self, indexer, value)
875
876 # length checking
--> 877 check_setitem_lengths(indexer, value, values)
878 exact_match = (
879 len(arr_value.shape)
C:\app\Anaconda3\lib\site-packages\pandas\core\indexers.py in check_setitem_lengths(indexer, value, values)
121 if len(value) != length_of_indexer(indexer, values):
122 raise ValueError(
--> 123 "cannot set using a slice indexer with a "
124 "different length than the value"
125 )
ValueError: cannot set using a slice indexer with a different length than the value
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?
https://www.backtrader.com/home/helloalgotrading/
Exception has occurred: FileNotFoundError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
[Errno 2] No such file or directory: 'MSFT'
File "D:\anaconda3\Lib\site-packages\backtrader\feed.py", line 674, in start
self.f = io.open(self.p.dataname, 'r')
File "D:\anaconda3\Lib\site-packages\backtrader\feeds\yahoo.py", line 94, in start
super(YahooFinanceCSVData, self).start()
File "D:\anaconda3\Lib\site-packages\backtrader\feeds\yahoo.py", line 355, in start
super(YahooFinanceData, self).start()
File "D:\anaconda3\Lib\site-packages\backtrader\feed.py", line 203, in _start
self.start()
File "D:\anaconda3\Lib\site-packages\backtrader\cerebro.py", line 1210, in runstrategies
data._start()
File "D:\anaconda3\Lib\site-packages\backtrader\cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "D:\code\digifinex\backTrader\1.py", line 37, in <module>
cerebro.run() # run it all
File "D:\anaconda3\Lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\anaconda3\Lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "D:\anaconda3\Lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "D:\anaconda3\Lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\anaconda3\Lib\runpy.py", line 194, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
Hello, I'm trying to use btalib and I'm having some trouble when having it run from inside a thread.
The below code works fine:
import [...]
symbol = 'BTCEUR'
with open('./data/' + symbol + '/' + symbol + '_kline.p', 'rb') as handle:
kline_df = pickle.load(handle)
sma = btalib.sma(kline_df).df
print(sma)
But when I try to use threads...
import [...]
symbol = 'BTCEUR'
with open('./data/' + symbol + '/' + symbol + '_kline.p', 'rb') as handle:
kline_df = pickle.load(handle)
def thread():
sma = btalib.sma(kline_df).df
print(sma)
time.sleep(5)
x = threading.Thread(target=thread)
x.start()
... I get the following error:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/nick/storage/Documents/_Projects/Python/Crypto/btalib_test.py", line 13, in thread
sma = btalib.sma(kline_df).df
File "/home/nick/storage/Documents/_Projects/Python/Crypto/venv/lib/python3.9/site-packages/btalib/indicator.py", line 110, in __call__
self.outputs = self.o = meta.outputs._from_class(cls)
File "/home/nick/storage/Documents/_Projects/Python/Crypto/venv/lib/python3.9/site-packages/btalib/meta/outputs.py", line 30, in _from_class
return _CLSOUTPUTS[cls]() # defvals params in dict format
File "/home/nick/storage/Documents/_Projects/Python/Crypto/venv/lib/python3.9/site-packages/btalib/meta/lines.py", line 630, in __init__
metadata.minperiods[self] = [1] * len(self)
AttributeError: '_thread._local' object has no attribute 'minperiods'
Any help would be appreciated!
Im trying to use bta-lib to calculate rsi indicator although it was fine with the sma function but through an error on rsi function
'''
df=pd.read_csv('prices.csv')
sma=btalib.sma(df,period=9)#works fine
rsi=btalib.rsi(df,period=14)#through an error
'''
error= ValueError: cannot set using a slice indexer with a different length than the value... my df len is enough.
As I have mentioned on the community forum:
https://community.backtrader.com/topic/3687/bta-lib-and-bt-indicators-deliver-different-values-when-using-indicator-on-indicator
The bta-lib indicator on indicator gives different results than when using this in backtrader internally.
The problem surfaces when you use RSI on ATR for example.
atr14 = ATR(High, Low, Close, period=14)
This will return a pandas dataframe containing NaN values.
When you feed this to the next indicator, this results in different values from Backtrader:
rsi_atr = RSI(atr14, period=7)
In order to come up with the same results, one should implement the dataframe without the NaN values.
rsi_atr = RSI(atr14.dropna(), period=7)
I am uncertain considering the setup of the bta-lib framework if the dataframe returned from the functions should be stripped of NaN values (losing the index compatibility, don't think that is good) or if bta-lib functions should drop NaN values before computations.
However, in the Backtrader implementation this is done correctly. I feel bta-lib should deliver exactly the same results.
https://btalib.backtrader.com/introduction/
Cannot be accessed anymore.
I am trying to create trailing ATR with fixed multiplier using mult
function but I failed as it throws AttributeError: 'float' object has no attribute 'index'
and that makes sense.
My Question is how to do that? Should I need to add index and perform or is there a simple way to do that.
Looking for a direction.
SMMA Function is working good when calling in not threading modus however when code is running in muli thread we get the following error:
File "/home/engine.traderbot/src/indicators/smma.py", line 192, in __calculate_smma
tmp = btalib.smma(self.ohlc_data[self.source], period=self.length)
File "/home/anaconda/envs/traderbot/lib/python3.7/site-packages/btalib/indicator.py", line 110, in call
self.outputs = self.o = meta.outputs._from_class(cls)
File "/home/anaconda/envs/traderbot/lib/python3.7/site-packages/btalib/meta/outputs.py", line 30, in _from_class
return _CLSOUTPUTScls # defvals params in dict format
File "/home/anaconda/envs/traderbot/lib/python3.7/site-packages/btalib/meta/lines.py", line 630, in init
metadata.minperiods[self] = [1] * len(self)
https://www.metatrader5.com/en/terminal/help/indicators/bw_indicators/fractals
Can you add a Bill Williams fractals indicator to the library please?
import btalib
import pandas as pd
df = pd.read_csv('2006-day-001.txt', parse_dates=True, index_col='Date')
sma = btalib.sma(df)
gives AttributeError: module 'btalib' has no attribute 'sma'
Hi,
Thanks for this project! very convenient to use.
I am wondering if it supports dynamic update the indicator values as I feed more newly incoming data. If it is supported, how to do it? I seem not finding the information in the document. If not, is there a suggestion w.r.t how to implement the functionality in my own application on top of bta-lib? Thanks!
When I run
btalib.dx(btc_df.high, btc_df.low, btc_df.close)
or
btalib.dm(btc_df.high, btc_df.low)
with btc_df.high, btc_df.low and btc_df.close being columns from a pandas data frame (series of floats).
I get:
TypeError Traceback (most recent call last)
in
1 # import talib
2
----> 3 btalib.dx(btc_df.high, btc_df.low, btc_df.close)
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicators/directionalmove.py in init(self)
95 if self._plus: # upvmoe > 0 and where upmove > downmove
96 pdm = upmove.clip(lower=0.0) * (upmove > downmove)
---> 97 self._pdm = self._smoother(pdm, **smoothargs)
98
99 if self._minus: # downmove > 0 and where downmove > upmove
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicators/directionalmove.py in init(self)
50 p = self.p.period
51 _ewm = self.i0._ewm(span=p, _pearly=self.p._pearly, _seed=self.p._seed)
---> 52 self.o.smacc = _ewm._lfilter(alpha=1.0, beta=(p - 1) / p)
53
54 def _talib(self, kwdict):
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/meta/lines.py in _lfilter(self, alpha, beta)
341 return scipy.signal.lfilter([alpha], [1.0, -beta], x)
342
--> 343 return self._apply(_sp_lfilter) # trigger getattr for _apply
344
345 def _mean(self): # meant for ewm with dynamic alpha
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/meta/lines.py in call_op(*args, **kwargs)
377 sargs.append(arg)
378
--> 379 result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
380 result = result.astype(r.dtype, copy=False)
381 return self._line._clone(result, period=self._minperiod)
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply(self, func, name, numba_cache_key, **kwargs)
467 return result
468
--> 469 return self._apply_blockwise(homogeneous_func, name)
470
471 def aggregate(self, func, *args, **kwargs):
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply_blockwise(self, homogeneous_func, name)
382 """
383 if self._selected_obj.ndim == 1:
--> 384 return self._apply_series(homogeneous_func, name)
385
386 obj = self._create_data(self._selected_obj)
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply_series(self, homogeneous_func, name)
371 raise DataError("No numeric types to aggregate") from err
372
--> 373 result = homogeneous_func(values)
374 return obj._constructor(result, index=obj.index, name=obj.name)
375
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in homogeneous_func(values)
459 result = np.apply_along_axis(calc, self.axis, values)
460 else:
--> 461 result = calc(values)
462 result = np.asarray(result)
463
~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in calc(x)
453 closed=self.closed,
454 )
--> 455 return func(x, start, end, min_periods)
456
457 with np.errstate(all="ignore"):
TypeError: _sp_lfilter() takes 1 positional argument but 4 were given
Python version 3.8.2
Package versions:
bta-lib 1.0.0
numpy 1.19.5
pandas 1.2.1
scipy 1.6.0
I am getting bunch of errors :
result[minidx:] = r = binop(other, *args, **kwargs) # exec / store
Traceback (most recent call last):
File "C:\IB\pyGame\ALGO_AMD.py", line 30, in
mama(amdDF).df
^^^^^^^^^^^
File "C:\IB\pyGame\venv\Lib\site-packages\btalib\indicator.py", line 152, in call
b_init(self, *args, **kwargs)
File "C:\IB\pyGame\venv\Lib\site-packages\btalib\indicators\mama.py", line 79, in init
_mama = p0._ewm(alpha=alpha, span=1, _seed=SEED_ZERO)._mean()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\IB\pyGame\venv\Lib\site-packages\btalib\meta\lines.py", line 357, in _mean
return self._apply(_dynalpha) # triggers getattr for _apply
^^^^^^^^^^^^^^^^^^^^^^
File "C:\IB\pyGame\venv\Lib\site-packages\btalib\meta\lines.py", line 379, in call_op
result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
^^^^^^^^^^^^^^^^^^^^
TypeError: BaseWindow._apply() missing 1 required positional argument: 'name'
My code:
from ib_insync import *
import btalib
import pandas
from btalib import *
from btalib import bbands
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=0)
amd_contract = Stock('AMD', 'SMART', 'USD')
ib.qualifyContracts(amd_contract)
data = ib.reqMktData(amd_contract)
ib.sleep(1)
print(data.marketPrice())
historical_data_amd = ib.reqHistoricalData(
amd_contract,
'',
barSizeSetting='3 mins',
durationStr='2 D',
whatToShow='TRADES',
useRTH=True
)
amdDF = util.df(historical_data_amd)
#amdH = amdDF.filter(['high','low'])
#amdL = amdDF.fi
#print(amdDF.high)
#print (bbands(amdDF).df)
mama(amdDF).df
I Apricate your help .
Thanks
Murthy
btalib.macd(df.close,pfast=12,pslow=26,psignal=9)
TypeError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in setitem(self, key, value)
1013 try:
-> 1014 self._set_with_engine(key, value)
1015 except com.SettingWithCopyError:
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in _set_with_engine(self, key, value)
1053 try:
-> 1054 self.index._engine.set_value(values, key, value)
1055 return
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.set_value()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.set_value()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: 'slice(11, None, None)' is an invalid key
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in
----> 1 btalib.macd(df.close,pfast=12,pslow=26,psignal=9)
~/anaconda3/lib/python3.7/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes
~/anaconda3/lib/python3.7/site-packages/btalib/indicators/macd.py in init(self)
38
39 def init(self):
---> 40 ma1 = self.p._ma(self.i0, period=self.p.pfast, **self._talibkw)
41 ma2 = self.p._ma(self.i0, period=self.p.pslow)
42 self.o.macd = ma1 - ma2
~/anaconda3/lib/python3.7/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes
~/anaconda3/lib/python3.7/site-packages/btalib/indicators/ema.py in init(self, poffset)
37 def init(self, poffset=0): # see above for poffset
38 span, seed, poff = self.p.period, self.p._seed, poffset
---> 39 self.o.ema = self.i0._ewm(span=span, _seed=seed, _poffset=poff).mean()
~/anaconda3/lib/python3.7/site-packages/btalib/meta/lines.py in call_op(*args, **kwargs)
377 sargs.append(arg)
378
--> 379 result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
380 result = result.astype(r.dtype, copy=False)
381 return self._line._clone(result, period=self._minperiod)
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in setitem(self, key, value)
1040 pass
1041
-> 1042 self._set_with(key, value)
1043
1044 if cacher_needs_updating:
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in _set_with(self, key, value)
1062 if isinstance(key, slice):
1063 indexer = self.index._convert_slice_indexer(key, kind="getitem")
-> 1064 return self._set_values(indexer, value)
1065
1066 elif is_scalar(key) and not is_integer(key) and key not in self.index:
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in _set_values(self, key, value)
1109 if isinstance(key, Series):
1110 key = key._values
-> 1111 self._data = self._data.setitem(indexer=key, value=value)
1112 self._maybe_update_cacher()
1113
~/anaconda3/lib/python3.7/site-packages/pandas/core/internals/managers.py in setitem(self, **kwargs)
559
560 def setitem(self, **kwargs):
--> 561 return self.apply("setitem", **kwargs)
562
563 def putmask(self, **kwargs):
~/anaconda3/lib/python3.7/site-packages/pandas/core/internals/managers.py in apply(self, f, filter, **kwargs)
440 applied = b.apply(f, **kwargs)
441 else:
--> 442 applied = getattr(b, f)(**kwargs)
443 result_blocks = _extend_blocks(applied, result_blocks)
444
~/anaconda3/lib/python3.7/site-packages/pandas/core/internals/blocks.py in setitem(self, indexer, value)
875
876 # length checking
--> 877 check_setitem_lengths(indexer, value, values)
878 exact_match = (
879 len(arr_value.shape)
~/anaconda3/lib/python3.7/site-packages/pandas/core/indexers.py in check_setitem_lengths(indexer, value, values)
122 if len(value) != length_of_indexer(indexer, values):
123 raise ValueError(
--> 124 "cannot set using a slice indexer with a "
125 "different length than the value"
126 )
ValueError: cannot set using a slice indexer with a different length than the value
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.