Skip to content

Commit

Permalink
Merge pull request #232 from cvxgrp/231-organisation-notebooks
Browse files Browse the repository at this point in the history
231 organisation notebooks
  • Loading branch information
tschm authored Dec 3, 2023
2 parents 96afe1f + bf49d89 commit 10b753f
Show file tree
Hide file tree
Showing 11 changed files with 1,005 additions and 89,651 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,31 @@ We discuss this in

### Create the builder object

The user defines a builder object by loading a frame of prices
and initialize the amount of cash used in our experiment:
The user defines a builder object by loading prices
and initialize the amount of cash used in an experiment:

```python
from pathlib import Path

import pandas as pd
from cvx.simulator.builder import builder

prices = pd.read_csv(Path("resources") / "price.csv",
index_col=0, parse_dates=True, header=0).ffill()
prices = pd.read_csv("prices.csv", index_col=0, parse_dates=True, header=0)
b = builder(prices=prices, initial_cash=1e6)
```

Prices have to be valid, there may be NaNs only at the beginning and the end of
each column in frame.
There can be no NaNs hiding in the middle of any time series.

It is also possible to specify a model for trading costs.
The builder helps to fill up the frame of positions. Only once done
we construct the actual portfolio.

### Loop through time

We have overloaded the `__iter__` and `__setitem__` methods
to create a custom loop. Let's start with a first strategy. Each day we choose
two names from the universe at random. Buy one (say 0.1 of your
portfolio wealth) and short one the same amount.
We have overloaded the `__iter__` and `__setitem__` methods to create a custom loop.
Let's start with a first strategy. Each day we choose two names from the
universe at random.
Buy one (say 0.1 of your portfolio wealth) and short one the same amount.

```python
for t, state in b:
Expand All @@ -80,7 +81,7 @@ The state gives access to the currently available cash, the current prices
and the current valuation of all holdings.

Here's a slightly more realistic loop. Given a set of $4$ assets we want to
implmenent the popular $1/n$ strategy.
implemenent the popular $1/n$ strategy.

```python
for t, state in b:
Expand All @@ -95,7 +96,7 @@ The builder class also exposes setters for such alternative conventions.
```python
for t, state in b:
# each day we invest a quarter of the capital in the assets
b.weights = 0.25*np.ones(4)
b.weights = np.ones(4)*0.25
```

### Build the portfolio
Expand Down
167 changes: 0 additions & 167 deletions book/docs/index.md

This file was deleted.

1 change: 1 addition & 0 deletions book/docs/index.md
File renamed without changes.
71,722 changes: 0 additions & 71,722 deletions book/docs/notebooks/demo.ipynb

This file was deleted.

4 changes: 2 additions & 2 deletions book/docs/notebooks/difference.ipynb

Large diffs are not rendered by default.

1,625 changes: 13 additions & 1,612 deletions book/docs/notebooks/monkey.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 10b753f

Please sign in to comment.