Skip to content

Commit

Permalink
Update CI pipeline for pages
Browse files Browse the repository at this point in the history
[ci deploy-pages]
  • Loading branch information
polakowo committed Aug 28, 2021
1 parent 4cfe099 commit 820edb8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ jobs:
- mv docs/vectorbt/* docs
- rmdir docs/vectorbt
- mv docs/site/* .
- touch CNAME
- echo 'vectorbt.dev' > CNAME
- touch .nojekyll
deploy:
- provider: pages
skip_cleanup: true
Expand Down
36 changes: 35 additions & 1 deletion vectorbt/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,51 @@
`settings` config is also accessible via `vectorbt.settings`.
Here are the main properties of the `settings` config:
* It's a nested config, that is, a config that consists of multiple sub-configs.
one per sub-package (e.g., 'data'), module (e.g., 'array_wrapper'), or even class (e.g., 'configured').
Each sub-config may consist of other sub-configs.
* It has frozen keys - you cannot add other sub-configs or remove the existing ones, but you can modify them.
* Each sub-config can either inherit the properties of the parent one by using `dict` or overwrite them
by using its own `vectorbt.utils.config.Config`. The main reason for defining an own config is to allow
adding new keys (e.g., 'plotting.layout').
For example, you can change default width and height of each plot:
```python-repl
>>> import vectorbt as vbt
>>> vbt.settings['plotting']['layout']['width'] = 800
>>> vbt.settings['plotting']['layout']['height'] = 400
```
Changes take effect immediately.
The main sub-configs such as for plotting can be also accessed/modified using the dot notation:
```
>>> vbt.settings.plotting['layout']['width'] = 800
```
Some sub-configs allow the dot notation too but this depends whether they inherit the rules of the root config.
```plaintext
>>> vbt.settings.data - ok
>>> vbt.settings.data.binance - ok
>>> vbt.settings.data.binance.api_key - error
>>> vbt.settings.data.binance['api_key'] - ok
```
Since this is only visible when looking at the source code, the advice is to always use the bracket notation.
!!! note
Any change takes effect immediately. But whether its reflected immediately depends upon the place
that accesses the settings. For example, changing 'array_wrapper.freq` has an immediate effect because
the value is resolved every time `vectorbt.base.array_wrapper.ArrayWrapper.freq` is called.
On the other hand, changing 'portfolio.fillna_close' has only effect on `vectorbt.portfolio.base.Portfolio`
instances created in the future, not the existing ones, because the value is resolved upon the construction.
But mostly you can still force-update the default value by replacing the instance using
`vectorbt.portfolio.base.Portfolio.replace`.
All places in vectorbt import `settings` from `vectorbt._settings.settings`, not from `vectorbt`.
Overwriting `vectorbt.settings` only overwrites the reference created for the user.
Consider updating the settings config instead of replacing it.
Expand Down
12 changes: 12 additions & 0 deletions vectorbt/portfolio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@
10
```
## Defaults
If you look at the arguments of each class method, you will notice that most of them default to None.
None has a special meaning in vectorbt: it's a command to pull the default value from the global settings config
- `vectorbt._settings.settings`. The branch for the `Portfolio` can be found under the key 'portfolio'.
For example, the default size used in `Portfolio.from_signals` and `Portfolio.from_orders` is `np.inf`:
```python-repl
>>> vbt.settings.portfolio['size']
inf
```
## Grouping
One of the key features of `Portfolio` is the ability to group columns. Groups can be specified by
Expand Down

0 comments on commit 820edb8

Please sign in to comment.