Skip to content

Commit 8d8924b

Browse files
committed
docs: configuration
1 parent 3bc47d9 commit 8d8924b

File tree

2 files changed

+223
-0
lines changed

2 files changed

+223
-0
lines changed

.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineConfig({
2121
{ text: 'Docker Tooling', link: '/docker-tooling' },
2222
{ text: 'Project Structure', link: '/project-structure' },
2323
{ text: 'Core Concepts', link: '/core-concepts' },
24+
{ text: 'Configuration', link: '/configuration' },
2425
]
2526
}
2627
],

configuration.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# Configuration
2+
3+
Stochastix uses a hierarchical configuration system that allows for sensible global defaults which can be easily overridden for specific backtest runs. The primary configuration file for your project is `config/packages/stochastix.yaml`.
4+
5+
This document outlines the available parameters within that file. Any of these settings can be overridden at runtime via CLI options or API request parameters.
6+
7+
## Global Defaults (`stochastix.defaults`)
8+
9+
This is the main root key for all global backtesting parameters.
10+
11+
12+
### `bc_scale`
13+
14+
* **Description**: The default scale (number of decimal places) for all high-precision `bcmath` operations throughout the framework.
15+
* **Type**: `integer`
16+
* **Default**: `8`
17+
18+
```yaml
19+
stochastix:
20+
defaults:
21+
bc_scale: 8
22+
```
23+
24+
### `initial_capital`
25+
26+
* **Description**: The starting capital for each backtest.
27+
* **Type**: `float`
28+
* **Default**: `10000.0`
29+
30+
```yaml
31+
stochastix:
32+
defaults:
33+
initial_capital: 50000.0
34+
```
35+
36+
### `stake_currency`
37+
38+
* **Description**: The currency to use for all calculations, portfolio value, and staking.
39+
* **Type**: `string`
40+
* **Default**: `'USDT'`
41+
42+
```yaml
43+
stochastix:
44+
defaults:
45+
stake_currency: 'USDT'
46+
```
47+
48+
### `symbols`
49+
50+
* **Description**: A default list of trading symbols (e.g., pairs) to use for a backtest if not otherwise specified.
51+
* **Type**: `array`
52+
* **Default**: `['BTC/USDT']`
53+
54+
```yaml
55+
stochastix:
56+
defaults:
57+
symbols: ['BTC/USDT', 'ETH/USDT']
58+
```
59+
60+
### `timeframe`
61+
62+
* **Description**: The default candle timeframe for the backtest. Must be a valid timeframe recognized by the framework (e.g., `1m`, `5m`, `1h`, `4h`, `1d`).
63+
* **Type**: `string`
64+
* **Default**: `'1d'`
65+
66+
```yaml
67+
stochastix:
68+
defaults:
69+
timeframe: '4h'
70+
```
71+
72+
### `start_date` / `end_date`
73+
74+
* **Description**: The default date range for the backtest, in `YYYY-MM-DD` format. If `null`, the backtest will use all available data from the beginning (`start_date`) or to the very end (`end_date`).
75+
* **Type**: `string|null`
76+
* **Default**: `null`
77+
78+
```yaml
79+
stochastix:
80+
defaults:
81+
start_date: '2023-01-01'
82+
end_date: '2024-01-01'
83+
```
84+
85+
### `commission`
86+
87+
* **Description**: Defines the commission (trading fee) model for the simulation.
88+
* **Type**: `array`
89+
* **Default Model**:
90+
* `type`: `percentage`
91+
* `rate`: `0.001` (which is 0.1%)
92+
93+
There are three commission types available:
94+
1. **`percentage`**: A percentage of the total trade value.
95+
2. **`fixed_per_trade`**: A flat fee for every trade.
96+
3. **`fixed_per_unit`**: A fee based on the amount of the asset traded.
97+
98+
**Examples:**
99+
100+
```yaml
101+
# Example 1: 0.075% fee per trade
102+
stochastix:
103+
defaults:
104+
commission:
105+
type: 'percentage'
106+
rate: 0.00075
107+
108+
# Example 2: Flat $1.50 fee per trade
109+
stochastix:
110+
defaults:
111+
commission:
112+
type: 'fixed_per_trade'
113+
amount: 1.50
114+
asset: 'USDT'
115+
116+
# Example 3: $0.002 fee per unit of the base asset traded
117+
stochastix:
118+
defaults:
119+
commission:
120+
type: 'fixed_per_unit'
121+
rate: 0.002
122+
```
123+
124+
### `data_source`
125+
126+
* **Description**: Specifies where the backtester should find its market data files.
127+
* **Type**: `array`
128+
* **Default**:
129+
* `exchange_id`: `'binance'`
130+
* `type`: `'stchx_binary'`
131+
132+
```yaml
133+
stochastix:
134+
defaults:
135+
data_source:
136+
exchange_id: 'okx'
137+
```
138+
139+
## Metrics Configuration (`stochastix.metrics`)
140+
141+
This section allows for fine-tuning the parameters of specific performance metrics.
142+
143+
### `beta`
144+
145+
* **Description**: Configures the Beta calculation.
146+
* **Type**: `array`
147+
* **Parameters**:
148+
* `rolling_window`: The number of data points to include in the rolling window for calculating the covariance and variance needed for Beta.
149+
* **Type**: `integer`
150+
* **Default**: `30`
151+
152+
```yaml
153+
stochastix:
154+
metrics:
155+
beta:
156+
rolling_window: 60
157+
```
158+
159+
## Full configuration example
160+
161+
This is a complete example of the `stochastix.yaml` configuration file with all possible keys set to their default values.
162+
163+
```yaml
164+
stochastix:
165+
# Global default settings for all backtests.
166+
# These can be overridden via CLI options or API requests.
167+
defaults:
168+
# The default scale (number of decimal places) for all bcmath operations.
169+
bc_scale: 8
170+
171+
# Default trading symbols.
172+
symbols: ['BTC/USDT']
173+
174+
# Default timeframe (e.g., 1m, 5m, 1h, 1d, 1w, 1M).
175+
timeframe: '1d'
176+
177+
# Default start date (YYYY-MM-DD). If null (~), the backtest uses all available historical data.
178+
start_date: ~
179+
180+
# Default end date (YYYY-MM-DD). If null (~), the backtest runs to the end of the data.
181+
end_date: ~
182+
183+
# Default initial capital.
184+
initial_capital: 10000.0
185+
186+
# Default currency for staking and reporting.
187+
stake_currency: 'USDT'
188+
189+
# Default stake amount per trade. Can be a fixed value (e.g., 1000) or a percentage ("2.5%").
190+
# If null, the strategy must handle position sizing itself.
191+
stake_amount: ~
192+
193+
# Default commission (trading fee) model.
194+
commission:
195+
# Type can be 'percentage', 'fixed_per_trade', or 'fixed_per_unit'.
196+
type: 'percentage'
197+
# Rate for 'percentage' (e.g., 0.001 for 0.1%) or 'fixed_per_unit'.
198+
rate: 0.001
199+
# Amount for 'fixed_per_trade' (e.g., 1.5 for $1.50).
200+
amount: ~
201+
# The asset in which the commission is charged (e.g., USDT).
202+
asset: ~
203+
204+
# Default data source configuration.
205+
data_source:
206+
# The exchange identifier used for locating data files (e.g., 'binance', 'okx').
207+
exchange_id: 'binance'
208+
# The type of data source. Currently, only 'stchx_binary' is supported.
209+
type: 'stchx_binary'
210+
# Options specific to the 'stchx_binary' data source type.
211+
stchx_binary_options: []
212+
# Placeholders for future data source types.
213+
csv_options: []
214+
database_options: []
215+
216+
# Configuration for specific performance metrics.
217+
metrics:
218+
# Configuration for the Beta calculation.
219+
beta:
220+
# The number of data points for the rolling window calculation.
221+
rolling_window: 30
222+
```

0 commit comments

Comments
 (0)