Skip to content

Commit 976ad0c

Browse files
committed
feat: initial commit
0 parents  commit 976ad0c

File tree

194 files changed

+25183
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+25183
-0
lines changed

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/*.*proj.user
11+
**/*.dbmdl
12+
**/*.jfm
13+
**/compose.y*ml
14+
**/Dockerfile*
15+
**/vendor
16+
LICENSE
17+
README.md

.github/workflows/ci.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Stochastix CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- 'v*.*.*'
8+
pull_request:
9+
branches: [ master ]
10+
workflow_dispatch:
11+
12+
jobs:
13+
test:
14+
name: Run Test Suite
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: '8.4'
25+
extensions: bcmath, ds, gmp, trader
26+
tools: composer:v2
27+
28+
- name: Get Composer cache directory
29+
id: composer-cache
30+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
31+
32+
- name: Cache Composer dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: ${{ steps.composer-cache.outputs.dir }}
36+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-composer-
39+
40+
- name: Install dependencies
41+
run: composer install --prefer-dist --no-progress
42+
43+
- name: Run PHPUnit tests
44+
run: composer test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor/
2+
/.idea/
3+
.php-cs-fixer.cache
4+
/.phpunit.cache/

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = new PhpCsFixer\Finder()
4+
->in(__DIR__)
5+
;
6+
7+
return new PhpCsFixer\Config()
8+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
9+
->setRules([
10+
'@Symfony' => true,
11+
'@PHP84Migration' => true,
12+
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
13+
'concat_space' => ['spacing' => 'one'],
14+
])
15+
->setFinder($finder)
16+
;

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Contributing to Stochastix
2+
3+
First off, thank you for considering contributing to Stochastix! It's people like you that make open source such a great community.
4+
5+
## How Can I Contribute?
6+
7+
### Reporting Bugs
8+
9+
If you find a bug, please ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/phpquant/stochastix-core/issues).
10+
11+
If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/phpquant/stochastix-core/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample or an executable test case** demonstrating the expected behavior that is not occurring.
12+
13+
### Suggesting Enhancements
14+
15+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/phpquant/stochastix-core/issues). Create an issue on that repository and describe the enhancement you would like to see, why it would be useful, and any implementation ideas you may have.
16+
17+
### Pull Request Process
18+
19+
1. Fork the repository and create your branch from `master`.
20+
2. Ensure the test suite passes with your changes. Run `make test`.
21+
3. If you've added code that should be tested, add new tests.
22+
4. Make sure your code lints. We use `php-cs-fixer` and `phpstan`. Run `make fix` and `make stan`.
23+
5. Issue that pull request!
24+
25+
## Coding Standards
26+
27+
This project follows the **PER-CS2.0** coding standard. To automatically format your code before committing, you can run:
28+
29+
```bash
30+
make fix
31+
```

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM php:8.4-cli
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
libgmp-dev \
6+
git \
7+
unzip \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Install PHP extensions
11+
RUN docker-php-ext-install \
12+
bcmath \
13+
gmp \
14+
&& pecl install \
15+
xdebug \
16+
trader \
17+
ds \
18+
&& docker-php-ext-enable \
19+
xdebug \
20+
bcmath \
21+
gmp \
22+
trader \
23+
ds \
24+
&& docker-php-source delete
25+
26+
RUN git config --global --add safe.directory /app
27+
28+
# Install Composer
29+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
30+
31+
WORKDIR /app
32+
33+
CMD [ "php", "-v" ]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 William Arin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.PHONY: all build up composer bash test check fix stan
2+
3+
build:
4+
@docker compose build
5+
6+
up:
7+
@docker compose up -d
8+
9+
composer:
10+
@docker compose run --rm php composer $(c)
11+
12+
bash:
13+
@docker compose exec php bash
14+
15+
test:
16+
@docker compose run --rm php vendor/bin/phpunit $(c)
17+
18+
check:
19+
@docker compose run --rm -e PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix --diff --dry-run
20+
21+
fix:
22+
@docker compose run --rm -e PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix -vvv
23+
24+
stan:
25+
@docker compose run --rm php composer stan
26+

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Stochastix
2+
3+
[![Stochastix CI](https://github.com/phpquant/stochastix-core/actions/workflows/ci.yaml/badge.svg)](https://github.com/phpquant/stochastix-core/actions/workflows/ci.yaml)
4+
5+
Stochastix is a high-performance, event-driven quantitative trading backtesting engine built with PHP and Symfony. It provides a modular and extensible framework for developing, testing, and analyzing algorithmic trading strategies.
6+
7+
## Key Features
8+
9+
* **Event-Driven Architecture:** Built for performance and realism.
10+
* **Advanced Order Types:** Supports Market, Limit, and Stop orders with a full pending order book.
11+
* **Multi-Timeframe Engine:** Develop strategies that analyze data across multiple timeframes simultaneously.
12+
* **Extensible Metrics:** A full suite of performance metrics (Sharpe, Sortino, Calmar, etc.) with a dependency-aware calculation engine.
13+
* **High-Performance Storage:** Custom binary file formats for efficient market data storage and retrieval.
14+
* **User Interface:** Modern web interface to download market data, launch backtest and analyze results.
15+
* **REST API:** A complete API for building custom interfaces, including real-time progress updates via Mercure.
16+
17+
## Documentation
18+
19+
For the latest official documentation, visit the [Stochastix Documentation](https://phpquant.github.io/stochastix-docs).
20+
21+
## Installation
22+
23+
This project is a Symfony bundle. To install it in your application:
24+
25+
1. **Require the bundle with Composer:**
26+
```bash
27+
composer require stochastix/core
28+
```
29+
30+
2. **Enable the bundle (if not using Symfony Flex):**
31+
In `config/bundles.php`, add:
32+
```php
33+
return [
34+
// ...
35+
Stochastix\StochastixBundle::class => ['all' => true],
36+
];
37+
```
38+
39+
## Contributing
40+
41+
We welcome contributions from the community! Please read our [**Contributing Guide**](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
php:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
environment:
7+
PHP_CS_FIXER_IGNORE_ENV: 1
8+
volumes:
9+
- .:/app
10+
working_dir: /app
11+
command: tail -f /dev/null

0 commit comments

Comments
 (0)