A Collection of public tutorials published in the qubitquants.pro blog.
The data required for running the tutorial is in the data/
folder.
vectorbtpro
A Collection of public tutorials published in the qubitquants.pro blog
License: MIT License
Renamed latest_at_index to realign, resample_opening to realign_opening, and resample_closing to realign_closing
The issue happens when running signal_data = signal_data.transform(transform_signal_data)
in notebook Discretionary_Signal_Backtesting.ipynb
python: 3.11.7
vbt.version: '2024.1.30'
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\base.py:3791](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3791), in Index.get_loc(self, key)
[3790](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3790) try:
-> [3791](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3791) return self._engine.get_loc(casted_key)
[3792](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3792) except KeyError as err:
File index.pyx:152, in pandas._libs.index.IndexEngine.get_loc()
File index.pyx:181, in pandas._libs.index.IndexEngine.get_loc()
File pandas\_libs\hashtable_class_helper.pxi:7080, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas\_libs\hashtable_class_helper.pxi:7088, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Symbol'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Cell In[129], [line 18](vscode-notebook-cell:?execution_count=129&line=18)
[14](vscode-notebook-cell:?execution_count=129&line=14) df = df[df["EntryPrice"] > 0]
[16](vscode-notebook-cell:?execution_count=129&line=16) return df
---> [18](vscode-notebook-cell:?execution_count=129&line=18) signal_data = signal_data.transform(transform_signal_data)
[20](vscode-notebook-cell:?execution_count=129&line=20) print("Final Signal DF Shape:",signal_data.wrapper.shape)
File [c:\Users\wayne\.conda\envs\vectorbtpro\Lib\site-packages\vectorbtpro\data\base.py:3348](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3348), in Data.transform(self, transform_func, per_feature, per_symbol, pass_frame, key_wrapper_kwargs, template_context, *args, **kwargs)
[3346](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3346) new_concat_data = pd.concat(new_concat_data, axis=1)
[3347](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3347) else:
-> [3348](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3348) new_concat_data = _transform(concat_data)
[3349](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3349) checks.assert_meta_equal(new_concat_data, concat_data, axis=1)
[3350](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3350) native_concat_data = pd.concat(self.data.values(), axis=1, keys=None)
File [c:\Users\wayne\.conda\envs\vectorbtpro\Lib\site-packages\vectorbtpro\data\base.py:3248](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3248), in Data.transform.<locals>._transform(data, _template_context)
[3246](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3246) _args = substitute_templates(args, _template_context, sub_id="args")
[3247](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3247) _kwargs = substitute_templates(kwargs, _template_context, sub_id="kwargs")
-> [3248](file:///C:/Users/wayne/.conda/envs/vectorbtpro/Lib/site-packages/vectorbtpro/data/base.py:3248) return _transform_func(data, *_args, **_kwargs)
Cell In[129], [line 5](vscode-notebook-cell:?execution_count=129&line=5)
[3](vscode-notebook-cell:?execution_count=129&line=3) # Select only one symbol, the one we fetched the data for
[4](vscode-notebook-cell:?execution_count=129&line=4) print("DF All Columns:",df.columns.tolist())
----> [5](vscode-notebook-cell:?execution_count=129&line=5) df = df[df["Symbol"] == symbol]
[7](vscode-notebook-cell:?execution_count=129&line=7) # Select columns of interest
[8](vscode-notebook-cell:?execution_count=129&line=8) df = df.iloc[:, [0, 3, 4, 5, 6, 7, 8 , 9]]
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\frame.py:3892](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3892), in DataFrame.__getitem__(self, key)
[3890](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3890) if is_single_key:
[3891](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3891) if self.columns.nlevels > 1:
-> [3892](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3892) return self._getitem_multilevel(key)
[3893](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3893) indexer = self.columns.get_loc(key)
[3894](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3894) if is_integer(indexer):
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\frame.py:3950](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3950), in DataFrame._getitem_multilevel(self, key)
[3948](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3948) def _getitem_multilevel(self, key):
[3949](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3949) # self.columns is a MultiIndex
-> [3950](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3950) loc = self.columns.get_loc(key)
[3951](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3951) if isinstance(loc, (slice, np.ndarray)):
[3952](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/frame.py:3952) new_columns = self.columns[loc]
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\multi.py:2925](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2925), in MultiIndex.get_loc(self, key)
[2922](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2922) return mask
[2924](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2924) if not isinstance(key, tuple):
-> [2925](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2925) loc = self._get_level_indexer(key, level=0)
[2926](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2926) return _maybe_to_slice(loc)
[2928](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2928) keylen = len(key)
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\multi.py:3276](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3276), in MultiIndex._get_level_indexer(self, key, level, indexer)
[3273](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3273) return slice(i, j, step)
[3275](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3275) else:
-> [3276](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3276) idx = self._get_loc_single_level_index(level_index, key)
[3278](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3278) if level > 0 or self._lexsort_depth == 0:
[3279](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3279) # Desired level is not sorted
[3280](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3280) if isinstance(idx, slice):
[3281](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:3281) # test_get_loc_partial_timestamp_multiindex
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\multi.py:2865](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2865), in MultiIndex._get_loc_single_level_index(self, level_index, key)
[2863](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2863) return -1
[2864](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2864) else:
-> [2865](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/multi.py:2865) return level_index.get_loc(key)
File [~\AppData\Roaming\Python\Python311\site-packages\pandas\core\indexes\base.py:3798](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3798), in Index.get_loc(self, key)
[3793](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3793) if isinstance(casted_key, slice) or (
[3794](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3794) isinstance(casted_key, abc.Iterable)
[3795](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3795) and any(isinstance(x, slice) for x in casted_key)
[3796](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3796) ):
[3797](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3797) raise InvalidIndexError(key)
-> [3798](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3798) raise KeyError(key) from err
[3799](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3799) except TypeError:
[3800](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3800) # If we have a listlike key, _check_indexing_error will raise
[3801](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3801) # InvalidIndexError. Otherwise we fall through and re-raise
[3802](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3802) # the TypeError.
[3803](https://file+.vscode-resource.vscode-cdn.net/c%3A/project/tmp/vectorbt_pro_tutorials/~/AppData/Roaming/Python/Python311/site-packages/pandas/core/indexes/base.py:3803) self._check_indexing_error(key)
KeyError: 'Symbol'
That file is missing
Hi,
This website is no long valid, I was using it to learn vectorbt pro, I was at the section that do plotting so I need somehow get access to the code which is not available here either. Would you be kind enough to post the codes here, thanks
Plot OHLCV data first
kwargs1 = {"title_text" : "OHLCV Plot", "title_font_size" : 18}
h4_ohlc_sample = df[["Open", "High", "Low", "Close"]].iloc[100:200]#.dropna()
f = h4_ohlc_sample.vbt.ohlcv.plot(**kwargs1)
f.show()
<
`df.iloc[100:200].plot(fig = f,
lowerband_trace_kwargs=dict(fill=None, name = 'BB_Price_Lower'),
upperband_trace_kwargs=dict(fill=None, name = 'BB_Price_Upper'),
middleband_trace_kwargs=dict(fill=None, name = 'BB_Price_Middle')).show()
`
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.