Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[flake8]
max-line-length = 120
max-line-length = 120
extend-ignore = E203
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run CI make command

on:
push:
branches:
- "*"
- "!main"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Build
working-directory: .
run: make ci
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/PyTrade"]
path = lib/PyTrade
url = https://github.com/kylewidmann/PyTrade.git
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Pytest",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"purpose": ["debug-test"],
"justMyCode": false
}
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"python.defaultInterpreterPath": "./.venv/bin/python",
"python.testing.pytestArgs": [
"--ignore=lib"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"python.analysis.exclude": [
"**/.venv",
"**/docker",
"**/mypy_cache",
"**/pytest_cache"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
MIT License

Copyright (c) 2024, Kyle Widmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SHELL := /bin/bash -e -o pipefail
PROJECT ?= fx-backtest
PROJECT ?= pytradebacktest
BRANCH_NAME ?= local
BUILD_NUMBER ?= 0
IMAGE ?= ${PROJECT}:${BRANCH_NAME}-${BUILD_NUMBER}
COMPOSE_FILE=docker/docker-compose.yaml
COMPOSE_BASE_FILE=docker/docker-compose.base.yaml
DC=docker compose -p ${PROJECT} -f ${COMPOSE_FILE} -f ${COMPOSE_BASE_FILE}
SERVICE := fx_backtest
SERVICE := pytradebacktest
POETRY ?= "poetry"
VERSION := $(shell head VERSION | grep -Eo "\d+.\d+.\d+")

Expand Down
430 changes: 430 additions & 0 deletions clean

Large diffs are not rendered by default.

17 changes: 6 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ RUN curl -sSL https://install.python-poetry.org | python3 - \

WORKDIR /app/${PROJECT_DIR}
COPY ${PROJECT_DIR}/pyproject.toml ${PROJECT_DIR}/poetry.lock ./
COPY fx-strategy ../fx-strategy
COPY vendors/backtesting.py ../vendors/backtesting.py
# RUN poetry install --only main
COPY lib lib/
RUN poetry install --only main

##################################################
## PRODUCTION ##
Expand All @@ -44,7 +43,7 @@ RUN apt-get update \
curl \
build-essential

ENV PATH="/app/${PROJECT_DIR}/.venv/bin:$PATH"
ENV PATH="/app/.venv/bin:$PATH"
ENV APP_USER app
ENV APP_GROUP app
RUN groupadd ${APP_GROUP}
Expand All @@ -53,19 +52,17 @@ RUN useradd -g ${APP_GROUP} ${APP_USER}
WORKDIR /app
COPY --chown=${APP_USER}:${APP_GROUP} ${PROJECT_DIR}/ ./
COPY --from=base /app .

WORKDIR /app/${PROJECT_DIR}
USER ${APP_USER}

ENTRYPOINT ["/app/${PROJECT_DIR}/scripts/entrypoint.sh"]
ENTRYPOINT ["/app/scripts/entrypoint.sh"]

##################################################
## DEVELOPMENT ##
##################################################

FROM base as development

ENV PATH="/app/${PROJECT_DIR}/.venv/bin:$PATH"
ENV PATH="/app/.venv/bin:$PATH"
ENV APP_USER app
ENV APP_GROUP app
RUN groupadd ${APP_GROUP}
Expand All @@ -77,10 +74,8 @@ RUN set -ex \

WORKDIR /app
COPY --chown=${APP_USER}:${APP_GROUP} . ./

WORKDIR /app/${PROJECT_DIR}
RUN poetry install
RUN chown ${APP_USER}:${APP_GROUP} .
USER ${APP_USER}

ENTRYPOINT ["/app/${PROJECT_DIR}/scripts/entrypoint.sh"]
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ services:
extends:
file: docker-compose.base.yaml
service: base
entrypoint: ["/app/fx-backtest/scripts/test.sh"]
entrypoint: ["/app/scripts/test.sh"]
19 changes: 0 additions & 19 deletions fx_backtest/main.py

This file was deleted.

1 change: 1 addition & 0 deletions lib/PyTrade
Submodule PyTrade added at b3b4a2
12 changes: 6 additions & 6 deletions makefiles/development.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ venv:
buid: ##@development Build the docker images
build: prod_image ?= ${PROJECT}:${BRANCH_NAME}-${BUILD_NUMBER}
build: dev_image ?= ${PROJECT}_development:${BRANCH_NAME}-${BUILD_NUMBER}
build: args ?= -f docker/Dockerfile --build-arg PROJECT_DIR=${PROJECT} --network=host --build-arg BUILDKIT_INLINE_CACHE=1
build: args ?= -f docker/Dockerfile --build-arg PROJECT_DIR=. --network=host --build-arg BUILDKIT_INLINE_CACHE=1
build:
DOCKER_BUILDKIT=1 docker build --progress=plain --target production -t ${prod_image} ${args} ..
DOCKER_BUILDKIT=1 docker build --progress=plain --target development -t ${dev_image} --cache-from ${prod_image} ${args} ..
DOCKER_BUILDKIT=1 docker build --progress=plain --target production -t ${prod_image} ${args} .
DOCKER_BUILDKIT=1 docker build --progress=plain --target development -t ${dev_image} --cache-from ${prod_image} ${args} .

.PHONY: infrastructure
infrastructure: ##@development Set up infrastructure for tests
infrastructure:
echo "Skipping..."

.PHONY: client
.PHONY: clean
clean: ##@development Clean up any dependencies
clean:
echo "Skipping..."
find . | grep -E "(/__pycache__$$|\.pyc$$|\.pyo$$)" > $@ || true | xargs rm -rf

.PHONY: config
.PHONY: ci
ci: ##@development Run CI pipeline
ci: clean build infrastructure lint test clean
Loading
Loading