Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into extend-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Dec 4, 2023
2 parents 599e356 + 6afad7d commit a50a4f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"esbonio.sphinx.confDir": ""
"sonarlint.connectedMode.project": {
"connectionId": "vscode",
"projectKey": "KarelZe_tclf"
}
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Trade classification for python 🐍

![GitHubActions](https://github.com/karelze/tclf//actions/workflows/tests.yaml/badge.svg)
![Codecov](https://codecov.io/gh/karlze/tclf/branch/master/graph/badge.svg)

`tclf` is a [`scikit-learn`](https://scikit-learn.org/stable/)-compatible implementation of trade classification algorithms to classify financial markets transactions into buyer- and seller-initiated trades.

The key features are:
Expand Down Expand Up @@ -48,7 +51,7 @@ Run your script with
```console
python main.py
```
In this example, input data is available as a pd.DataFrame/Series with columns conforming to our [naming conventions](naming_conventions.md).
In this example, input data is available as a pd.DataFrame/Series with columns conforming to our [naming conventions](https://karelze.github.io/tclf/naming_conventions/).

The parameter `layers=[("quote", "ex")]` sets the quote rule at the exchange level and `strategy="random"` specifies the fallback strategy for unclassified trades. The true label `y` is not used in classification and only for API consistency by convention.

Expand Down Expand Up @@ -84,7 +87,7 @@ print(accuracy_score(y_true, y_pred))
```
In this example, input data is available as np.arrays with both exchange (`"ex"`) and nbbo data (`"best"`). We set the layers parameter to `layers=[("quote", "ex"), ("quote", "best")]` to classify trades first on subset `"ex"` and remaining trades on subset `"best"`. Additionally, we have to set `ClassicalClassifier(..., features=features)` to pass column information to the classifier.

Like before, column/feature names must follow our [naming conventions](naming_conventions.md).
Like before, column/feature names must follow our [naming conventions](https://karelze.github.io/tclf/naming_conventions/).

## Supported Algorithms

Expand Down
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.sources=src\
sonar.issue.ignore.multicriteria.e1.ruleKey=python:S117
7 changes: 2 additions & 5 deletions tests/test_classical_classifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""Tests for the classical classifier.
Use of artificial data to test the classifier.
"""
"""Tests for the classical classifier."""

import numpy as np
import pandas as pd
Expand All @@ -25,7 +22,7 @@ def setup(self) -> None:
Prepares inputs and expected outputs for testing.
"""
self.x_train = pd.DataFrame(
[[1, 2], [3, 4], [1, 2], [3, 4]], columns=["ask_best", "bid_best"]
[[1, 1], [1, 1], [1, 1], [1, 1]], columns=["ask_best", "bid_best"]
)
self.y_train = pd.Series([1, 1, -1, -1])
self.x_test = pd.DataFrame(
Expand Down

0 comments on commit a50a4f1

Please sign in to comment.