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

Migrate project to rust #185

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = False

[bumpversion:file:python/aat/aat/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:python/aat/setup.py]
search = version = "{current_version}"
replace = version = "{new_version}"

# [bumpversion:file:js/package.json]
# search = "version": "{current_version}"
# replace = "version": "{new_version}"
86 changes: 45 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
branches:
- main
- jb/rust
tags:
- v*
paths-ignore:
- LICENSE
- README.md
pull_request:

concurrency:
Expand All @@ -16,72 +22,70 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
python-version: [3.9]
node-version: [14.x]
event-name: [push]

steps:
- uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy
override: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# cache: "pip"
# cache-dependency-path: 'python/aat/pyproject.toml'

- name: Install system dependencies
run: |
sudo apt-get install libboost-dev
wget https://github.com/pybind/pybind11/archive/v2.5.0.tar.gz && tar xfz v2.5.0.tar.gz && cd pybind11-2.5.0 && mkdir build && cd build && cmake .. -DPYBIND11_TEST=OFF && sudo make -j4 install
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Install system dependencies
run: |
brew install boost cmake pybind11
if: ${{ matrix.os == 'macos-latest' }}
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'yarn'
# cache-dependency-path: js/yarn.lock

- name: Install dependencies
run: |
python -m pip install -U cpplint numpy pip pyarrow pyEX setuptools tqdm twine wheel
python -m pip install -e .[dev]
# - name: Install yarn
# run: npm install -g yarn

- name: Lint Python
run: |
make lintpy
# - uses: actions-rs/cargo@v1
# with:
# command: check

- name: Lint C++
run: |
make lintcpp

- name: Type Annotate
- name: Install dependencies
run: |
make annotate
make develop

- name: Test
- name: Build
run: |
make tests
if: ${{ github.event_name == matrix.event-name || matrix.os == 'ubuntu-latest' }}
make build

- name: Test C++
- name: Lint
run: |
make testpycpp
if: ${{ github.event_name == matrix.event-name || matrix.os == 'ubuntu-latest' }}
make lint

- name: Live tests
- name: Checks
run: |
make testruns
make checks
if: ${{ github.event_name == matrix.event-name || matrix.os == 'ubuntu-latest' }}

- name: Twine check
- name: Test
run: |
make dist
make tests-ci-gha
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Upload test results
uses: actions/upload-artifact@v3
uses: EnricoMi/publish-unit-test-result-action@v1
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: python_junit.xml
if: ${{ always() }}

- name: Upload coverage
uses: codecov/codecov-action@v3
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: rust/results.xml
if: ${{ matrix.os == 'ubuntu-latest' }}
42 changes: 19 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
coverage
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
coverage.info
*,cover
cover
results.xml
python_junit.xml
.mypy_cache
venv/

# Translations
*.mo
Expand All @@ -52,47 +58,37 @@ cover

# Sphinx documentation
docs/_build/
docs/api
docs/index.md

# PyBuilder
target/

*_keys
horizon

# Mac files
*.DS_Store

# JS Files
js/node_modules/
js/build/
aat/ui/assets/static/
notes.txt
ref
node_modules

# Keys
coinbase.sh
coinbase_sandbox.sh
keys
old

# Notebooks
.ipynb_checkpoints
*.pkl
notebooks/BTC_*

# IDE
.idea
.vscode

# Other
custom_strategies

node_modules
package-lock.json
yarn.lock
logo.ai
logo.png
coverage
experiments
aat_test
docs/api
docs/index.md
tornado_sqlalchemy_login
aat.db
python_junit.xml
.mypy_cache
.vscode
private_config
_aat_BACKTEST*

venv/
117 changes: 21 additions & 96 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,108 +1,33 @@
PYTHON=python
CONFIG=./config/synthetic.cfg


run: ## Clean and make target, run target
$(PYTHON) -m aat --config $(CONFIG)

runcpp: build ## Clean and make target, run target
AAT_USE_CPP=1 $(PYTHON) -m aat --config $(CONFIG)

rundebug: debug ## Clean and make debug target, run target
$(PYTHON) -m aat --config $(CONFIG)

stratres: ## View strategy results offline
$(PYTHON) -m aat.strategy.calculations

buildextf: ## build the package extensions
$(PYTHON) setup.py build_ext -j8 --inplace -f

buildext: ## build the package extensions
$(PYTHON) setup.py build_ext -j8 --inplace

build: buildext ## build the package
$(PYTHON) setup.py build

debug: ## build debug build of the package
DEBUG=1 $(PYTHON) setup.py build

install: ## install the package
$(PYTHON) -m pip install .

tests: build testpy ## Make unit tests

testpy: ## Make unit tests
$(PYTHON) -m pytest -vvv ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch

testpycpp: ## Make unit tests
# AAT_USE_CPP=1 $(PYTHON) -m pytest -vvv ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch --capture=no
AAT_USE_CPP=1 $(PYTHON) -m pytest -vs ./aat/tests

testruns: testrunscsv testrunsiex ## Run a few examples as a live end-to-end test

testrunscsv:
$(PYTHON) -m aat.strategy.sample.csv.readonly
$(PYTHON) -m aat.strategy.sample.csv.readonly_periodic
$(PYTHON) -m aat.strategy.sample.csv.received

testrunsiex:
$(PYTHON) -m aat.strategy.sample.iex.readonly
TESTING=1 $(PYTHON) -m aat.strategy.sample.iex.buy_and_hold
TESTING=1 $(PYTHON) -m aat.strategy.sample.iex.momentum
TESTING=1 $(PYTHON) -m aat.strategy.sample.iex.golden_death

lint: lintpy lintcpp ## run all linters

lintpy: ## run python linter
$(PYTHON) -m flake8 aat setup.py

lintcpp: ## run cpp linter
cpplint --linelength=120 --recursive aat/cpp/{src,include}

fix: fixpy fixcpp ## run all fixers

fixpy: ## run autopep8 fix
$(PYTHON) -m black aat/ setup.py
.DEFAULT_GOAL := help
.PHONY: develop build lint checks tests tests-ci-gha

fixcpp: ## run clang-format
clang-format -i -style=file `find ./aat/cpp/{src,include} -name "*.*pp"`
develop-rust:
make -C rust develop

annotate: ## MyPy type annotation check
$(PYTHON) -m mypy aat
develop: develop-rust ## Setup project for development

type_ignore: ## Count type ignores
grep -rin "type: ignore" ./aat | wc -l
build-rust:
make -C rust build

type_ignore_list: ## List all type ignores
grep -rin "type: ignore" ./aat
build: build-rust ## Build the project

docs: ## Build the sphinx docs
make -C docs html
open ./docs/_build/html/index.html
lint-rust:
make -C rust lint

dist: ## create dists
rm -rf dist build
python setup.py sdist bdist_wheel
python -m twine check dist/*
lint: lint-rust ## Run project linters

publish: dist ## dist to pypi and npm
python -m twine upload dist/* --skip-existing
checks-rust:
make -C rust checks

clean: ## clean the repository
find . -name "__pycache__" | xargs rm -rf
find . -name "*.pyc" | xargs rm -rf
rm -rf .coverage coverage cover htmlcov logs build dist *.egg-info coverage.xml .mypy_cache
find . -name "*.so" | xargs rm -rf
make -C ./docs clean
rm -rf _aat_BACKTEST_*
checks: checks-rust ## Run any other checks

# Thanks to Francoise at marmelab.com for this
.DEFAULT_GOAL := help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
tests-rust:
make -C rust tests

print-%:
@echo '$*=$($*)'
tests: tests-rust ## Run the tests

.PHONY: run buildext build install tests lint fix docs dist clean help fixcpp
tests-ci-gha-rust:
make -C rust tests-ci-gha

tests-ci-gha: tests-ci-gha-rust

Loading