Skip to content

Commit 5117e47

Browse files
committed
docs: introduction pages and homepage
0 parents  commit 5117e47

File tree

13 files changed

+3041
-0
lines changed

13 files changed

+3041
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
3+
.vitepress/dist/
4+
.vitepress/cache/
5+
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

.vitepress/config.mts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "Stochastix",
6+
description: "High-Performance Quantitative Backtesting Engine",
7+
themeConfig: {
8+
// https://vitepress.dev/reference/default-theme-config
9+
nav: [
10+
{ text: 'Home', link: '/' },
11+
{ text: 'Guide', link: '/getting-started' }
12+
],
13+
14+
sidebar: [
15+
{
16+
text: 'Guide',
17+
items: [
18+
{ text: 'Getting Started', link: '/getting-started' },
19+
{ text: "What's Stochastix?", link: '/introduction' },
20+
{ text: 'Docker Tooling', link: '/docker-tooling' },
21+
{ text: 'Project Structure', link: '/project-structure' },
22+
]
23+
}
24+
],
25+
26+
socialLinks: [
27+
{ icon: 'github', link: 'https://github.com/phpquant/stochastix-core' }
28+
],
29+
30+
footer: {
31+
message: 'Released under the MIT License.',
32+
copyright: 'Copyright © 2025-present William Arin'
33+
}
34+
}
35+
})

.vitepress/theme/custom.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
:root {
2+
--vp-c-brand-1: #0a347e;
3+
--vp-c-brand-2: #0cac32;
4+
--vp-c-brand-3: #0a347e;
5+
}
6+
7+
.dark {
8+
--vp-c-brand-1: #0cac32;
9+
--vp-c-brand-2: #0a347e;
10+
--vp-c-brand-3: #0cac32;
11+
}

.vitepress/theme/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import DefaultTheme from 'vitepress/theme';
2+
import './custom.css';
3+
4+
export default DefaultTheme;

docker-tooling.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Docker Tooling with Makefile
2+
3+
To simplify interaction with the Docker environment, Stochastix comes with a pre-configured `Makefile` in the root of your project. It contains convenient shortcuts for most common operations, from managing containers to running Composer and Symfony commands.
4+
5+
::: info
6+
All `make` commands should be run from the root directory of your project (the same directory where the `Makefile` is located).
7+
:::
8+
9+
## General
10+
11+
### Displaying Help
12+
13+
This is the most useful command to start with. It lists all available commands directly from the `Makefile` along with their descriptions.
14+
15+
```bash
16+
make help
17+
```
18+
19+
## Docker Container Management
20+
21+
These commands are wrappers around `docker compose` to manage the lifecycle of your development environment.
22+
23+
* **`make start`**
24+
Builds the Docker images if they don't exist and starts all containers in detached mode. This is the typical command to start your work session.
25+
26+
* **`make up`**
27+
Starts the containers without rebuilding them. Useful if you've previously run `make down`.
28+
29+
* **`make down`**
30+
Stops and removes all running containers for this project.
31+
32+
* **`make build`**
33+
Forces a rebuild of the Docker images, pulling the latest base images and ignoring any cache. Use this if you've changed the `Dockerfile` or need to ensure you have the latest updates.
34+
35+
* **`make logs`**
36+
Attaches to the logs of all running containers so you can see their output in real-time. Press `Ctrl+C` to detach.
37+
38+
* **`make sh` or `make bash`**
39+
Opens an interactive shell session inside the main `php` container. This is the primary way to run commands within the Dockerized environment. `make bash` is often preferred as it provides better support for command history (using arrow keys).
40+
41+
* **`make spawn c="..."`**
42+
Spawns a new, temporary container to run a single command and then exits. This is useful for one-off tasks without attaching to a long-running container.
43+
44+
```bash
45+
# Example: Check the installed PHP modules
46+
make spawn c="php -m"
47+
```
48+
49+
* **`make test c="..."`**
50+
Runs the PHPUnit test suite inside a dedicated test environment. You can pass additional arguments to `phpunit` using the `c=` parameter.
51+
52+
```bash
53+
# Run all tests
54+
make test
55+
56+
# Run a specific group of tests and stop on the first failure
57+
make test c="--group e2e --stop-on-failure"
58+
```
59+
60+
## Application & Dependencies
61+
62+
These commands help you manage your project's dependencies and application state without needing to type long `docker compose exec` commands.
63+
64+
### Composer
65+
66+
* **`make install`**
67+
Installs all PHP dependencies based on your `composer.lock` file.
68+
69+
* **`make update`**
70+
Updates your PHP dependencies to their latest allowed versions according to `composer.json`.
71+
72+
* **`make composer c="..."`**
73+
Runs any arbitrary Composer command.
74+
75+
```bash
76+
# Require a new package
77+
make composer c="require symfony/orm-pack"
78+
79+
# Show information about a package
80+
make composer c="show symfony/console"
81+
```
82+
83+
### Symfony Console
84+
85+
* **`make sf c="..."`**
86+
The main shortcut for executing Symfony commands via `bin/console`.
87+
88+
::: details Example: Running Stochastix Commands
89+
This is the recommended way to run all `stochastix:*` commands documented throughout this site.
90+
```bash
91+
# Download market data
92+
make sf c="stochastix:data:download binance BTC/USDT 1d --start-date=2023-01-01"
93+
94+
# Run a backtest
95+
make sf c="stochastix:backtesting ema_cross"
96+
```
97+
:::
98+
99+
* **`make cc`**
100+
A quick shortcut for clearing the Symfony cache (`make sf c=cache:clear`).
101+
102+
* **`make xsf c="..."`**
103+
Runs a Symfony command with Xdebug enabled, allowing you to connect a debugger for step-by-step analysis.

getting-started.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Getting Started
2+
3+
Welcome to Stochastix\! This guide will walk you through setting up the framework so you can start backtesting your first trading strategy. We offer two installation paths: a one-command Docker setup (recommended for new projects) and a manual setup for integrating Stochastix into existing Symfony applications.
4+
5+
## Docker Installation <Badge type="tip" text="Recommended" />
6+
7+
::: tip The Easy Way
8+
This is the fastest and easiest way to get started with a fresh Stochastix project. The installer handles the creation of a new Symfony application, installation of the Stochastix bundle, and Docker configuration in a single command.
9+
:::
10+
11+
Open your terminal and run the following command. Replace `your-project-name` with the desired directory name for your new project.
12+
13+
```bash
14+
docker run --rm -it --pull=always -e HOST_PWD="$PWD" \
15+
-v "$PWD":/app -v /var/run/docker.sock:/var/run/docker.sock \
16+
ghcr.io/phpquant/stochastix-installer your-project-name
17+
```
18+
19+
The installer will:
20+
21+
1. Create a new directory named `your-project-name`.
22+
2. Set up a new Symfony project inside it.
23+
3. Install the `stochastix/core` bundle and its dependencies.
24+
4. Create `compose.yaml` file for a ready-to-use development environment.
25+
26+
Once the process is complete, your Stochastix environment is now running and ready for use.
27+
28+
You can access https://localhost in your web browser to access the user interface.
29+
30+
Next step: visit the [Docker tooling](/docker-tooling.md) page to understand how to manage your Docker environment, including starting and stopping the containers, and launching commands inside the container.
31+
32+
## Manual Installation
33+
34+
Use this method if you want to integrate Stochastix into an existing Symfony project or prefer to manage your environment manually.
35+
36+
### Requirements
37+
38+
Before you begin, ensure your environment meets the following criteria:
39+
40+
* **PHP 8.4** or newer.
41+
* The following PHP extensions must be enabled:
42+
* `bcmath` (for high-precision financial calculations)
43+
* `trader` (for technical analysis indicators)
44+
* `ds` (for high-performance data structures)
45+
* `pdo_sqlite` (for SQLite database support)
46+
* `gmp` (for arbitrary precision arithmetic)
47+
* **Composer** installed globally.
48+
49+
### Step 1. Install the Bundle
50+
51+
Navigate to your Symfony project's root directory and run the following command to add Stochastix as a dependency:
52+
53+
```bash
54+
composer require stochastix/core
55+
```
56+
57+
This bundle requires `williarin/cook` Composer plugin to run in order to install the package's necessary files to your project. At installation, it will automatically prompt you to allow the plugin to run.
58+
59+
### Step 2. Download the UI assets
60+
61+
To use the Stochastix web interface, you need to download the UI assets. Visit the Stochastix UI repository and download the latest release: https://github.com/phpquant/stochastix-ui/releases
62+
63+
Extract the contents of the downloaded archive into the `.ui/` directory of your Symfony project.
64+
65+
### Step 3. Configure your web server
66+
67+
Ideally you should use FrankenPHP for easy installation. You can copy the configuration files from the Stochastix Docker installer into your project: https://github.com/phpquant/stochastix/tree/master/templates/frankenphp
68+
69+
### Step 4. Run the Symfony Messenger worker
70+
71+
All backtesting and data processing tasks are handled by Symfony Messenger. To start the worker, run the following command in your project root:
72+
73+
```bash
74+
bin/console messenger:consume stochastix --time-limit=3600 --memory-limit=512M -vv
75+
```
76+
77+
### Verifying the Installation
78+
79+
You can verify that the framework is correctly installed by listing the available commands. From your project root, run:
80+
81+
```bash
82+
bin/console list stochastix
83+
```
84+
85+
You should see a list of all the `stochastix:*` commands, such as `stochastix:backtesting` and `stochastix:data:download`.
86+
87+
## Headless & CLI-Driven
88+
While the web interface provides a powerful and user-friendly way to launch backtests and visualize results, it is entirely optional.
89+
90+
The Stochastix engine is designed to be fully operational from the command line. Every feature, from downloading data to running complex backtests can be executed in a terminal.

index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
layout: home
3+
4+
hero:
5+
name: "Stochastix"
6+
text: "High-Performance Quantitative Backtesting Engine"
7+
tagline: "From hypothesis to statistical proof. A professional-grade PHP framework to build, test, and analyze your crypto-currencies trading strategies."
8+
image:
9+
src: /logo.svg
10+
alt: Stochastix
11+
actions:
12+
- theme: brand
13+
text: Get Started
14+
link: /getting-started
15+
- theme: alt
16+
text: View on GitHub
17+
link: https://github.com/phpquant/stochastix-core
18+
19+
features:
20+
- title: "Realistic Simulation Engine"
21+
details: "Process data bar-by-bar with a sophisticated order management system supporting Market, Limit, and Stop orders with automated Stop-Loss/Take-Profit handling."
22+
- title: "Institutional-Grade Metrics"
23+
details: "Go beyond P/L. Automatically calculate dozens of metrics like Sharpe & Sortino Ratios, Alpha, Beta, CAGR, and Max Drawdown to truly understand your strategy's risk and reward."
24+
- title: "Optimized for Performance"
25+
details: "Leverages custom binary formats for market and results data, combined with high-performance PHP extensions (ds, bcmath) to process massive datasets with maximum speed and precision."
26+
- title: "Modern Developer Experience"
27+
details: "Built on the robust Symfony framework. Define strategies and their inputs with simple, clean PHP attributes for a seamless and intuitive development workflow."
28+
---

introduction.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# What's Stochastix?
2+
3+
Stochastix is a high-performance, open-source quantitative **backtesting framework** dedicated exclusively to **crypto-currencies trading**. Engineered in PHP and Symfony, it is designed to provide developers and quantitative analysts with a robust, precise, and extensible environment to build, test, and analyze algorithmic trading strategies.
4+
5+
The framework's primary mission is to enable rigorous, data-driven research by providing tools that ensure simulation realism, computational precision, and deep performance insight.
6+
7+
## The Core Principles
8+
9+
Trading strategy development requires rigorous analysis. Stochastix is founded on three fundamental principles that make this possible:
10+
11+
1. **Realism:** A backtest is only as good as its simulation. Stochastix favors a realistic, event-driven approach that processes data bar-by-bar, handles complex order types natively, and manages portfolio state with precision.
12+
2. **Performance:** Quantitative analysis involves massive datasets. The framework is architected for speed and memory efficiency, from its custom binary data formats to its use of high-performance PHP extensions, ensuring that your research is not bottlenecked by I/O or processing time.
13+
3. **Developer experience:** A powerful tool should not be difficult to use. Built on modern PHP and the Symfony framework, Stochastix provides an intuitive, attribute-based system for strategy creation, clear separation of concerns, and a fully automatable command-line interface.
14+
15+
## Key Features at a Glance
16+
17+
* **Event-driven backtesting engine:** Simulates trading on a bar-by-bar basis, providing a realistic environment for strategies that react to market changes as they happen.
18+
* **Advanced order management:** Native support for `Market`, `Limit`, and `Stop` orders, including automated intra-bar execution of Stop-Loss and Take-Profit levels, partial exits, and programmatic order cancellation.
19+
* **Multi-timeframe analysis:** Natively request and access secondary timeframes (e.g., 4-hour data within a 1-hour strategy). Data is automatically resampled and aligned with the primary series.
20+
* **Comprehensive performance analytics:** Go far beyond simple Profit/Loss. The framework automatically generates dozens of institutional-grade summary and time-series metrics, including Sharpe Ratio, Sortino Ratio, Calmar Ratio, CAGR, Max Drawdown, Alpha, and Beta.
21+
* **High-performance data formats:** Custom binary file formats (`.stchx`, `.stchxi`, `.stchxm`) for storing market data, indicators, and metrics, ensuring minimal storage footprint and maximum read performance.
22+
* **Integrated data downloader:** A built-in CLI command to fetch high-quality historical OHLCV data from major exchanges via the CCXT library.
23+
* **Asynchronous & real-time:** Leverages Symfony Messenger and Mercure to run backtests asynchronously while pushing live progress updates to the UI.
24+
25+
## Engineered for Performance
26+
27+
Stochastix is meticulously optimized to handle the demands of quantitative research.
28+
29+
### Optimized Data Storage: The Binary Formats
30+
31+
Text-based data formats like CSV are inefficient for backtesting. They are slow to parse and consume significant disk space. Stochastix solves this with its own family of binary formats:
32+
33+
* **`.stchx`**: For OHLCV market data.
34+
* **`.stchxi`**: For indicator time-series data.
35+
* **`.stchxm`**: For performance metric time-series data (e.g., equity curve).
36+
37+
These formats provide several key advantages:
38+
39+
* **Compact:** They use a fraction of the disk space of a comparable CSV file.
40+
* **Fast:** Data can be read directly into memory without any parsing overhead.
41+
* **Efficient:** The fixed-size record structure allows for extremely fast time-range lookups using binary search, meaning the engine only reads the data it needs.
42+
43+
### Efficient In-Memory Operations: The `ds` Extension
44+
45+
For operations that occur in memory, such as handling time-series data during a backtest, Stochastix uses the `ext-ds` PHP extension. The `Ds\Vector` object provides a more memory-efficient and performant alternative to standard PHP arrays for large, contiguous lists of numerical data, which is precisely what a time-series is.
46+
47+
## Designed for Developers
48+
49+
Power and performance are meaningless without a great developer experience (DX).
50+
51+
### Intuitive Strategy Creation
52+
53+
Creating a strategy is simple and clean. By extending `AbstractStrategy`, you gain access to a rich set of helper methods. Strategy metadata and configurable parameters are defined with simple PHP attributes, reducing boilerplate and keeping your code declarative and easy to read.
54+
55+
```php
56+
#[AsStrategy(alias: 'my_strategy', name: 'My Awesome Strategy')]
57+
class MyStrategy extends AbstractStrategy
58+
{
59+
#[Input(description: 'The period for my indicator.')]
60+
private int $myPeriod = 20;
61+
62+
public function onBar(OhlcvSeries $bars): void
63+
{
64+
// ... your logic here
65+
}
66+
}

0 commit comments

Comments
 (0)