Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation to MKDocs #1450

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: docs-deploy
on:
push:
branches:
- master
- develop
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material pymdown-extensions
- run: mkdocs gh-deploy --force
16 changes: 8 additions & 8 deletions docs/IB.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Although this document is about Interactive Brokers, you should read it carefull

Related documents:

- [Storing futures and spot FX data](/docs/data.md)
- [Using pysystemtrade as a production trading environment](/docs/production.md)
- [Using pysystemtrade for backtesting](/docs/backtesting.md)
- [Storing futures and spot FX data](./data.md)
- [Using pysystemtrade as a production trading environment](./production.md)
- [Using pysystemtrade for backtesting](./backtesting.md)

*IMPORTANT: Make sure you know what you are doing. All financial trading offers the possibility of loss. Leveraged trading, such as futures trading, may result in you losing all your money, and still owing more. Backtested results are no guarantee of future performance. No warranty is offered or implied for this software. I can take no responsibility for any losses caused by live trading using pysystemtrade. Use at your own risk.*

Expand Down Expand Up @@ -107,14 +107,14 @@ See [here](#creating-and-closing-connection-objects) for more details.

There are three types of objects in the [sysbrokers/IB](/sysbrokers/IB/) area of pysystemtrade:

- Data source objects: Provide the standard data object API to the rest of the code, eg getting futures contracts prices is done with the same call whether they are coming from a database or IB. They are called by the `/sysproduction/data/broker/` [interface functions](/docs/data.md#production-interface). They are instanced with a *connection object*. They make calls to *client objects*.
- Data source objects: Provide the standard data object API to the rest of the code, eg getting futures contracts prices is done with the same call whether they are coming from a database or IB. They are called by the `/sysproduction/data/broker/` [interface functions](./data.md#production-interface). They are instanced with a *connection object*. They make calls to *client objects*.
- Client objects: These make calls to the ib_insync in specific domains (getting data, placing orders and so on). They are also instanced with a *connection object*.
- Connection objects. These contain a specific connection to an IB gateway via an ib_insync IB instance.


## Data source objects

We treat IB as another data source, which means it has to conform to the data object API (see [storing futures and spot FX data](/docs/data.md)). However we can't delete or write to IB. Normally these functions would be called by the `/sysproduction/data/broker/` [interface functions](/docs/data.md#production-interface); it's discouraged to call them directly as the interface abstracts away exactly which broker you are talking to.
We treat IB as another data source, which means it has to conform to the data object API (see [storing futures and spot FX data](./data.md)). However we can't delete or write to IB. Normally these functions would be called by the `/sysproduction/data/broker/` [interface functions](./data.md#production-interface); it's discouraged to call them directly as the interface abstracts away exactly which broker you are talking to.

The data source objects all inherit from the classes in the `sysbrokers/` directory, eg `broker*data.py`. This serves a few purposes: it means we can add additional non specific IB methods that only make sense when talking to a broker rather than to a database, and it illustrates the interface you'd need to implement to connect to a different broker.
Data source objects are instanced with and contain a *connection object* (and optionally a logger). They contain, and make calls to, *client objects*. They are in this [module](/sysbrokers/IB/)
Expand Down Expand Up @@ -249,7 +249,7 @@ ib_price_client.ib # live ib_inysnc.IB instance

## Connection objects

You wouldn't normally open a separate IB connection in pysystemtrade since they are opened by the [dataBlob](/docs/data.md#data-blobs) objects used in production. But it's useful to know how they work under the hood.
You wouldn't normally open a separate IB connection in pysystemtrade since they are opened by the [dataBlob](./data.md#data-blobs) objects used in production. But it's useful to know how they work under the hood.

### Creating and closing connection objects

Expand Down Expand Up @@ -280,11 +280,11 @@ conn = connectionIB(config)
Connection objects immediately try and connect to IB. So don't create them until you are ready to do this.


Again in production the connection would normally be closed by the [dataBlob](/docs/data.md#data-blobs) object that encapsulates the connection, or you can do it manually with `conn.close_connection()`.
Again in production the connection would normally be closed by the [dataBlob](./data.md#data-blobs) object that encapsulates the connection, or you can do it manually with `conn.close_connection()`.

### Using connections

We treat IB as another data source, which means it has to conform to the data object API (see [storing futures and spot FX data](/docs/data.md)). Since connection objects abstract what the broker is doing, it should be possible to use these object for other brokers with minimal changes.
We treat IB as another data source, which means it has to conform to the data object API (see [storing futures and spot FX data](./data.md)). Since connection objects abstract what the broker is doing, it should be possible to use these object for other brokers with minimal changes.

The main service the connection provides is that it encapsulates a live ib_inysnc.IB instance:

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--8<-- "README.md"
36 changes: 18 additions & 18 deletions docs/backtesting.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
This is the user guide for using pysystemtrade as a backtesting platform. Before reading this you should have gone through the [introduction.](/docs/introduction.md)
This is the user guide for using pysystemtrade as a backtesting platform. Before reading this you should have gone through the [introduction.](./introduction.md)

Related documents:

- [Storing futures and spot FX data](/docs/data.md)
- [Using pysystemtrade as a production trading environment](/docs/production.md)
- [Connecting pysystemtrade to interactive brokers](/docs/IB.md)
- [Recent undocumented changes](/docs/recent_changes.md)
- [Storing futures and spot FX data](./data.md)
- [Using pysystemtrade as a production trading environment](./production.md)
- [Connecting pysystemtrade to interactive brokers](./IB.md)
- [Recent undocumented changes](./recent_changes.md)


This guide is divided into four parts. The first ['How do I?'](#how_do_i)
Expand Down Expand Up @@ -402,7 +402,7 @@ you know what you're doing.

### Option 4: Create a `/private/private_config.yaml` file

This makes sense if you want to make a global change to a particular parameter rather than constantly including certain things in your configuration files. Anything in this file will overwrite the system defaults, but will in turn be overwritten by the backtest configuration .yaml file. This file will also come in very handy when it comes to [using pysystemtrade as a production trading environment](/docs/production.md)
This makes sense if you want to make a global change to a particular parameter rather than constantly including certain things in your configuration files. Anything in this file will overwrite the system defaults, but will in turn be overwritten by the backtest configuration .yaml file. This file will also come in very handy when it comes to [using pysystemtrade as a production trading environment](./production.md)


### Option 5: Change the project defaults (definitely not recommended)
Expand Down Expand Up @@ -556,11 +556,11 @@ If there are is no `instrument_weights` or `instruments` elements in the config,

## How do I.... Exclude some instruments from the backtest

Refer to the [instruments document](/docs/instruments.md).
Refer to the [instruments document](./instruments.md).

## How do I.... Exclude some instruments from having positive instrument weights

Refer to the [instruments document](/docs/instruments.md).
Refer to the [instruments document](./instruments.md).



Expand Down Expand Up @@ -787,15 +787,15 @@ There is more detail about using .csv files [here](#csv).

If you want to store your data in Mongo DB databases instead you need to [use a different data object](#arctic_data).

If you want to get your data from Quandl.com, then see the document [working with futures data](/docs/data.md)
If you want to get your data from Quandl.com, then see the document [working with futures data](./data.md)

If you want to get data from a different place (eg a database, yahoo finance,
broker, quandl...) you'll need to [create your own Data object](#create_data).

If you want to use a different set of data values (eg equity EP ratios,
interest rates...) you'll need to [create your own Data object](#create_data).

If you want to delve deeper into data storage see the document [working with futures data](/docs/data.md)
If you want to delve deeper into data storage see the document [working with futures data](./data.md)

## How do I... Save my work

Expand Down Expand Up @@ -862,7 +862,7 @@ particular **source** (for example .csv files, databases and so on).
Two kinds of specific data object is currently provided with the system in the
current version - `csvFuturesSimData` (.csv files) and `dbFuturesSimData` (database storage)

See [working with futures data](/docs/data.md)
See [working with futures data](./data.md)


#### Generic data objects
Expand Down Expand Up @@ -966,7 +966,7 @@ the instrument_code):
1. Static configuration and cost data- `instrument_config.csv` headings: Instrument, Pointsize,
AssetClass, Currency. Additional headings for costs: Slippage, PerBlock,
Percentage, PerTrade. See ['costs'](#costs) for more detail.
2. Roll parameters data. See [storing futures and spot FX data](/docs/data.md) for more detail.
2. Roll parameters data. See [storing futures and spot FX data](./data.md) for more detail.
3. Adjusted price data- `code.csv` (eg SP500.csv) headings: DATETIME, PRICE
4. Carry and forward data - `code.csv` (eg AEX.csv): headings:
DATETIME, PRICE,CARRY,FORWARD,CARRY_CONTRACT PRICE_CONTRACT, FORWARD_CONTRACT
Expand All @@ -991,7 +991,7 @@ See data in subdirectories [pysystemtrade/data/futures](/data/futures) for files
- [Futures specific carry and forward prices](/data/futures/multiple_prices_csv)
- [Spot FX prices](/data/futures/fx_prices_csv)

For more information see the [futures data document](/docs/data.md#csvFuturesSimData).
For more information see the [futures data document](./data.md#csvFuturesSimData).

<a name="arctic_data"> </a>

Expand All @@ -1002,14 +1002,14 @@ This is a simData object which gets it's data out of [Mongo DB](https://mongodb.
For production code, and storing large amounts of data (eg for individual futures contracts) we probably need something more robust than .csv files.
[MongoDB](https://mongodb.com) is a no-sql database which is rather fashionable at the moment, though the main reason I selected it for this purpose is that it is used by Arctic. [Arctic](https://github.com/manahl/arctic) is a superb open source time series database which sits on top of Mongo DB) and provides straightforward and fast storage of pandas DataFrames. It was created by my former colleagues at [Man AHL](https://www.ahl.com/) (in fact I beta tested a very early version of Arctic), and then very generously released as open source.

There is more detail on this in the [futures data documentation](/docs/data.md): [Mongo DB](/docs/data.md#mongoDB) and [Arctic](/docs/data.md#arctic).
There is more detail on this in the [futures data documentation](./data.md): [Mongo DB](./data.md#mongoDB) and [Arctic](./data.md#arctic).

##### Setting up your Arctic and Mongo DB databases

Obviously you will need to make sure you already have a Mongo DB instance running. You might find you already have one running, in Linux use `ps wuax | grep mongo` and then kill the relevant process. You also need to get [Arctic](https://github.com/manahl/arctic).

Because the mongoDB data isn't included in the github repo, before using this you need to write the required data into Mongo and Arctic.
You can do this from scratch, as per the ['futures data workflow'](/docs/data.md#a-futures-data-workflow). Alternatively you can run the following scripts which will copy the data from the existing github .csv files:
You can do this from scratch, as per the ['futures data workflow'](./data.md#a-futures-data-workflow). Alternatively you can run the following scripts which will copy the data from the existing github .csv files:

- [Instrument configuration and cost data](/sysinit/futures/repocsv_instrument_config.py)
- [Adjusted prices](/sysinit/futures/repocsv_adjusted_prices.py)
Expand Down Expand Up @@ -1061,7 +1061,7 @@ This might seem a hassle, and it's tempting to skip and just inherit from
convenient to have the possibility of multiple data sources and this process
ensures they keep a consistent API for a given data type.

It's worth reading the [documentation on futures data](/docs/data.md#modify_SimData) to understand how [csvFuturesSimData()](/sysdata/sim/csv_futures_sim_data.py) is constructed before modifying it or creating your own data objects.
It's worth reading the [documentation on futures data](./data.md#modify_SimData) to understand how [csvFuturesSimData()](/sysdata/sim/csv_futures_sim_data.py) is constructed before modifying it or creating your own data objects.

#### The Data() class

Expand Down Expand Up @@ -1634,7 +1634,7 @@ system, either from the config object if it contains instrument weights, or
from the data object.


These methods also get lists of instruments, see [instrument documentation](/docs/instruments.md) for more.
These methods also get lists of instruments, see [instrument documentation](./instruments.md) for more.
```
get_list_of_bad_markets
get_list_of_markets_not_trading_but_with_data
Expand Down Expand Up @@ -3233,7 +3233,7 @@ system.accounts.get_buffered_position("US10", roundpositions=True) ## get the bu

Note that in a live trading system buffering is done downstream of the
system module, in a process which can also see the actual current positions we
hold [the strategy order generation)](/docs/production.md).
hold [the strategy order generation)](./production.md).

Finally, if you set buffer_method to none there will be no buffering.

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--8<-- " CHANGELOG.md"
1 change: 1 addition & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--8<-- " CONTRIBUTING.md"
2 changes: 1 addition & 1 deletion docs/dashboard_and_monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This document describes how to monitor pysystemtrade in a production environment

It will make no sense unless you've already read:

- [Using pysystemtrade in production](/docs/production.md)
- [Using pysystemtrade in production](./production.md)

Table of Contents
=================
Expand Down
Loading