Skip to content

Commit

Permalink
Fix and update
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Mar 2, 2024
1 parent 095a208 commit 52513a7
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 396 deletions.
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
# General checks
##############################################################################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: fix-encoding-pragma
args: [--remove]
Expand All @@ -24,7 +24,7 @@ repos:
- id: check-yaml

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.6
hooks:
- id: codespell
description: Checks for common misspellings.
Expand All @@ -34,35 +34,35 @@ repos:
# Python formatting and linting
##############################################################################
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
rev: v3.1.0
hooks:
- id: add-trailing-comma
name: add-trailing-comma
types: [python]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.2.0
hooks:
- id: black
types_or: [python, pyi]
entry: "black"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.269
rev: v0.3.0
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.8.0
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports, --warn-no-return, --explicit-package-bases]
additional_dependencies: [types-pytz, types-redis, types-toml, types-requests, msgspec]
exclude: "nautilus_server/backend/api_v1/endpoints/models*"

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout

Expand All @@ -75,7 +75,7 @@ repos:
- id: jshint

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
args: ["--print-width", "160"]
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.7.1 \
POETRY_VERSION=1.8.1 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_NO_INTERACTION=1 \
Expand Down Expand Up @@ -39,6 +39,3 @@ COPY ./nautilus_data $PYSETUP_PATH/nautilus_data

# Generate data catalog
RUN python -m nautilus_data.hist_data_to_catalog

# Run backtest to generate data
RUN python -m nautilus_data.example_backtest
14 changes: 14 additions & 0 deletions nautilus_data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -------------------------------------------------------------------------------------------------
# Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved.
# https://nautechsystems.io
#
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------------------------------
81 changes: 0 additions & 81 deletions nautilus_data/example_backtest.py

This file was deleted.

20 changes: 17 additions & 3 deletions nautilus_data/hist_data_to_catalog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -------------------------------------------------------------------------------------------------
# Copyright (C) 2015-2023 Nautech Systems Pty Ltd. All rights reserved.
# Copyright (C) 2015-2024 Nautech Systems Pty Ltd. All rights reserved.
# https://nautechsystems.io
#
# Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
Expand All @@ -13,29 +13,43 @@
# limitations under the License.
# -------------------------------------------------------------------------------------------------

from os import PathLike
from pathlib import Path
import requests

from nautilus_trader.persistence.catalog import ParquetDataCatalog
from nautilus_trader.persistence.wranglers import QuoteTickDataWrangler
from nautilus_trader.test_kit.providers import CSVTickDataLoader
from nautilus_trader.test_kit.providers import TestInstrumentProvider

from nautilus_data.util import CATALOG_DIR

ROOT = Path(__file__).parent.parent
CATALOG_DIR = ROOT / "catalog"
CATALOG_DIR.mkdir(exist_ok=True)


def load_fx_hist_data(filename: str, currency: str, catalog_path: str) -> None:
def load_fx_hist_data(
filename: str,
currency: str,
catalog_path: PathLike[str] | str,
) -> None:
instrument = TestInstrumentProvider.default_fx_ccy(currency)
wrangler = QuoteTickDataWrangler(instrument)

df = CSVTickDataLoader.load(filename, index_col=0, format="%Y%m%d %H%M%S%f")
df.columns = ["bid_price", "ask_price", "size"]
print(df)

print("Preparing ticks...")
ticks = wrangler.process(df)

print("Writing data to catalog...")
catalog = ParquetDataCatalog(catalog_path)
catalog.write_data([instrument])
catalog.write_data(ticks)

print("Done")


def download(url: str) -> None:
filename = url.rsplit("/", maxsplit=1)[1]
Expand Down
21 changes: 0 additions & 21 deletions nautilus_data/util.py

This file was deleted.

Loading

0 comments on commit 52513a7

Please sign in to comment.