onesecondtrader 0.5.3__py3-none-any.whl → 0.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onesecondtrader/__init__.py +1 -10
- onesecondtrader/monitoring/__init__.py +0 -0
- onesecondtrader/{monitoring.py → monitoring/console.py} +2 -4
- onesecondtrader-0.7.0.dist-info/METADATA +248 -0
- onesecondtrader-0.7.0.dist-info/RECORD +7 -0
- onesecondtrader/domain/__init__.py +0 -13
- onesecondtrader/domain/models.py +0 -526
- onesecondtrader-0.5.3.dist-info/METADATA +0 -24
- onesecondtrader-0.5.3.dist-info/RECORD +0 -8
- {onesecondtrader-0.5.3.dist-info → onesecondtrader-0.7.0.dist-info}/LICENSE +0 -0
- {onesecondtrader-0.5.3.dist-info → onesecondtrader-0.7.0.dist-info}/WHEEL +0 -0
onesecondtrader/__init__.py
CHANGED
|
@@ -4,18 +4,9 @@ The Trading Infrastructure Toolkit for Python.
|
|
|
4
4
|
Research, simulate, and deploy algorithmic trading strategies — all in one place.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
from .monitoring import logger
|
|
7
|
+
from .monitoring.console import logger
|
|
9
8
|
|
|
10
|
-
# Domain models
|
|
11
|
-
from .domain.models import DomainModel, MarketData, PositionManagement, SystemManagement
|
|
12
9
|
|
|
13
10
|
__all__ = [
|
|
14
|
-
# Core infrastructure
|
|
15
11
|
"logger",
|
|
16
|
-
# Domain models
|
|
17
|
-
"DomainModel",
|
|
18
|
-
"MarketData",
|
|
19
|
-
"PositionManagement",
|
|
20
|
-
"SystemManagement",
|
|
21
12
|
]
|
|
File without changes
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Console logging utilities for OneSecondTrader.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
a logger instance for use throughout the package.
|
|
3
|
+
Simple console logging configuration for terminal output.
|
|
5
4
|
"""
|
|
6
5
|
|
|
7
6
|
import logging
|
|
8
7
|
|
|
9
|
-
|
|
10
8
|
logging.basicConfig(
|
|
11
9
|
level=logging.DEBUG,
|
|
12
10
|
format="%(asctime)s - %(levelname)s - %(threadName)s - %(message)s",
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: onesecondtrader
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place.
|
|
5
|
+
Author: Nils P. Kujath
|
|
6
|
+
Author-email: 63961429+NilsKujath@users.noreply.github.com
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: pandas (>=2.3.1,<3.0.0)
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# OneSecondTrader
|
|
16
|
+
|
|
17
|
+
[](https://github.com/nilskujath/onesecondtrader/actions/workflows/release.yml)
|
|
18
|
+
[](https://www.onesecondtrader.com)
|
|
19
|
+
[](https://pypi.org/project/onesecondtrader/)
|
|
20
|
+
[](https://github.com/nilskujath/onesecondtrader/blob/master/LICENSE)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
For documentation, please visit [onesecondtrader.com](https://www.onesecondtrader.com).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## For Developers: Continuous Integration & Delivery (CI/CD) Pipeline
|
|
29
|
+
|
|
30
|
+
This project's continuous integration & continuous delivery (CI/CD) pipeline consists of two distinct workflows:
|
|
31
|
+
**local pre-commit hooks** that run on `git commit` to ensure code quality,
|
|
32
|
+
and **GitHub Actions** that run on `git push origin master` to automate releases.
|
|
33
|
+
|
|
34
|
+
In order for the pipeline to work, the following configuration is required:
|
|
35
|
+
|
|
36
|
+
* version field in `pyproject.toml` must be set to appropriate version
|
|
37
|
+
```toml
|
|
38
|
+
[tool.poetry]
|
|
39
|
+
name = "onesecondtrader"
|
|
40
|
+
version = "0.1.0" # Updated automatically by bump_version.py
|
|
41
|
+
```
|
|
42
|
+
* `mkdocs.yml` must have `mkdocstrings-python` plugin configured
|
|
43
|
+
```yaml
|
|
44
|
+
plugins:
|
|
45
|
+
- mkdocstrings:
|
|
46
|
+
handlers:
|
|
47
|
+
python:
|
|
48
|
+
options:
|
|
49
|
+
docstring_style: google
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Local Pre-Commit Workflow
|
|
53
|
+
|
|
54
|
+
To ensure that only good quality code is commited to the repository, a series of pre-commit hooks are executed before each commit.
|
|
55
|
+
These hooks include code quality checks, testing, security scans, and automated API reference generation.
|
|
56
|
+
This workflow is orchestrated by the `pre-commit` package, which is configured in the `.pre-commit-config.yaml` file.
|
|
57
|
+
If any of these checks fail, the commit is blocked and the developer must fix the issues before retrying.
|
|
58
|
+
|
|
59
|
+
Prior to usage, the pre-commit hooks must be installed by running:
|
|
60
|
+
```bash
|
|
61
|
+
poetry run pre-commit install
|
|
62
|
+
poetry run pre-commit install --hook-type commit-msg
|
|
63
|
+
poetry run pre-commit run --all-files # Optional: Test installation
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This project follows [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages.
|
|
67
|
+
This standardized format enables automated semantic versioning and changelog generation.
|
|
68
|
+
The commit messages must have the following format:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
<type>: <description>
|
|
72
|
+
|
|
73
|
+
[optional body]
|
|
74
|
+
|
|
75
|
+
[optional footer(s)]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The commit message must start with a type, followed by a colon and a space, and then a description. The type must be one of the following:
|
|
79
|
+
|
|
80
|
+
- **feat**: New features that add functionality
|
|
81
|
+
- **fix**: Bug fixes and patches
|
|
82
|
+
- **docs**: Documentation changes only
|
|
83
|
+
- **chore**: Maintenance tasks, dependency updates, build changes
|
|
84
|
+
- **test**: Adding or modifying tests
|
|
85
|
+
- **refactor**: Code changes that neither fix bugs nor add features
|
|
86
|
+
- **perf**: Performance improvements
|
|
87
|
+
- **ci**: Changes to CI/CD configuration
|
|
88
|
+
|
|
89
|
+
Examples:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
feat: added trade-by-trade chart generation
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The following diagram illustrates this pre-commit workflow:
|
|
96
|
+
|
|
97
|
+
```mermaid
|
|
98
|
+
---
|
|
99
|
+
config:
|
|
100
|
+
themeVariables:
|
|
101
|
+
fontSize: "11px"
|
|
102
|
+
---
|
|
103
|
+
graph TD
|
|
104
|
+
A([<kbd>git commit</kbd>]) -->|Trigger Pre-commit Workflow on <kbd>commit</kbd>| PrecommitHooks
|
|
105
|
+
|
|
106
|
+
subgraph PrecommitHooks ["Local Pre-commit Hooks"]
|
|
107
|
+
B["<b>Code Quality Checks</b><br/>• Ruff Check & Format<br/>• MyPy Type Checking<br/>• Tests & Doctests"]
|
|
108
|
+
C["<b>Security Checks</b><br/>• Gitleaks Secret Detection"]
|
|
109
|
+
D["<b>File Validation</b><br/>• YAML/TOML/JSON Check<br/>• End-of-file Fixer<br/>• Large Files Check<br/>• Merge Conflict Check<br/>• Debug Statements Check"]
|
|
110
|
+
E["<b>Generate API Documentation</b> via <kbd>scripts/generate_api_docs.py</kbd><br/>• Auto-generate docs<br/>• Stage changes"]
|
|
111
|
+
end
|
|
112
|
+
B --> C --> D --> E
|
|
113
|
+
|
|
114
|
+
F([Write Commit Message])
|
|
115
|
+
PrecommitHooks -->|Pass| F
|
|
116
|
+
PrecommitHooks -.->|Fail| H
|
|
117
|
+
|
|
118
|
+
subgraph CommitMessageHook ["Commit Message Hook"]
|
|
119
|
+
G{Commit Message Valid?}
|
|
120
|
+
end
|
|
121
|
+
G -.->|No| H[Commit Blocked]
|
|
122
|
+
G -->|Yes| I[Commit Successful]
|
|
123
|
+
|
|
124
|
+
F --> CommitMessageHook
|
|
125
|
+
|
|
126
|
+
H -.->|Rework & Restage<br/>| K
|
|
127
|
+
|
|
128
|
+
K(["<kbd>git commit --amend</kbd>"])
|
|
129
|
+
|
|
130
|
+
K -.-> PrecommitHooks
|
|
131
|
+
|
|
132
|
+
L(["<kbd>git pull --rebase origin master</kbd>"])
|
|
133
|
+
|
|
134
|
+
L -.->|Rebase & Resolve Conflicts| M
|
|
135
|
+
|
|
136
|
+
M([<kbd>git add <...></kbd>])
|
|
137
|
+
|
|
138
|
+
M -.-> A
|
|
139
|
+
|
|
140
|
+
I -.~.-> J([<kbd>git push</kbd>])
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### GitHub Actions Workflow
|
|
145
|
+
|
|
146
|
+
Once a commit is pushed to the remote `master` branch, the GitHub Actions workflow `.github/workflows/release.yml` is triggered.
|
|
147
|
+
Note that the GitHub Actions workflow might push commits to the remote repository.
|
|
148
|
+
This means your local branch will be behind the remote branch.
|
|
149
|
+
|
|
150
|
+
In order for this workflow to run properly, two secrets need to be configured (`Settings > Secrets and variables > Actions`):
|
|
151
|
+
|
|
152
|
+
- `GH_PAT`: Personal Access Token with enhanced permissions (see PAT Setup below)
|
|
153
|
+
- `PYPI_API_TOKEN`: Generate from PyPI account settings
|
|
154
|
+
|
|
155
|
+
The default `GITHUB_TOKEN` has limited permissions and cannot trigger subsequent workflow runs or push to protected branches.
|
|
156
|
+
The PAT provides the necessary permissions for the automated release process.
|
|
157
|
+
The PAT is created as follows:
|
|
158
|
+
|
|
159
|
+
1. Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
|
|
160
|
+
2. Click "Generate new token (classic)"
|
|
161
|
+
3. Set expiration and select these scopes:
|
|
162
|
+
- `repo` (Full control of private repositories)
|
|
163
|
+
- `workflow` (Update GitHub Action workflows)
|
|
164
|
+
4. Copy the token and add it as `GH_PAT` secret in repository settings
|
|
165
|
+
|
|
166
|
+
Note that GitHub Actions bot must have write permissions to the repository.
|
|
167
|
+
|
|
168
|
+
The following diagram illustrates this GitHub Actions workflow:
|
|
169
|
+
|
|
170
|
+
```mermaid
|
|
171
|
+
---
|
|
172
|
+
config:
|
|
173
|
+
themeVariables:
|
|
174
|
+
fontSize: "11px"
|
|
175
|
+
---
|
|
176
|
+
graph TD
|
|
177
|
+
|
|
178
|
+
A0(<kdb>git commit</kbd>)
|
|
179
|
+
|
|
180
|
+
A1(<kdb>git commit --amend</kdb>)
|
|
181
|
+
|
|
182
|
+
A(<kbd>git push origin master</kbd>) -->|Trigger GitHub Actions Workflow on <kbd>push</kbd>| GitHubActions
|
|
183
|
+
|
|
184
|
+
A2(<kbd>git push origin master --force</kbd>) -->|Trigger GitHub Actions Workflow on <kbd>push</kbd>| GitHubActions
|
|
185
|
+
|
|
186
|
+
A0 -.->|Trigger Pre-commit Workflow & Commit| A
|
|
187
|
+
A1 -.->|Trigger Pre-commit Workflow & Commit| A2
|
|
188
|
+
|
|
189
|
+
subgraph GitHubActions ["GitHub Actions Environment Setup"]
|
|
190
|
+
B["<b>Checkout Repository</b><br/>Retrieve the full repository history on the latest Ubuntu runner"]
|
|
191
|
+
C["<b>Setup Python Environment</b><br/>Configure the required Python version and install Poetry"]
|
|
192
|
+
D["<b>Install Dependencies</b><br/>Install all project dependencies, including development ones"]
|
|
193
|
+
B --> C --> D
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
GitHubActions -.->|Failure<br/>Rework & Restage| A3
|
|
197
|
+
A3(<kdb>git commit --amend</kdb>)
|
|
198
|
+
|
|
199
|
+
GitHubActions -->|Environment Setup Complete| QualityChecks
|
|
200
|
+
|
|
201
|
+
subgraph QualityChecks ["CI Quality Validation"]
|
|
202
|
+
F["<b>Ruff Linting</b><br/>Validate code style and enforce formatting rules"]
|
|
203
|
+
G["<b>MyPy Type Checking</b><br/>Static type analysis"]
|
|
204
|
+
H["<b>Test Suite</b><br/>Run all automated tests"]
|
|
205
|
+
F --> G --> H
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
QualityChecks -.->|Failure<br/>Rework & Restage| A3
|
|
209
|
+
|
|
210
|
+
QualityChecks -->|CI Quality Checks Passed| GitConfig
|
|
211
|
+
|
|
212
|
+
subgraph GitConfig ["Git Configuration"]
|
|
213
|
+
J["<b>Configure Git Identity</b><br/>Set the automated commit author for CI operations"]
|
|
214
|
+
K["<b>Setup Authentication</b><br/>Enable secure access to the repository with release permissions (requires <kbd>GH_PAT</kbd>)"]
|
|
215
|
+
J --> K
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
GitConfig -->|Git Configured| VersionAnalysis
|
|
219
|
+
|
|
220
|
+
subgraph VersionAnalysis ["Semantic Version Analysis"]
|
|
221
|
+
N["<b>Execute bump_version.py</b><br/>Analyze commits since last tag to decide on version bump and bump level"]
|
|
222
|
+
P{Version Bump Required?}
|
|
223
|
+
N --> P
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
VersionAnalysis -->|No Version Change<br/>Skip Release Process| DocDeployment
|
|
227
|
+
VersionAnalysis -->|Version Bump Required| ReleaseProcess
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
subgraph ReleaseProcess ["Release & Publishing"]
|
|
231
|
+
R["<b>Update Version & Changelog</b><br/>Write new version and regenerate release notes."]
|
|
232
|
+
S["<b>Commit & Push</b><br/>Commit updated files and push to the default branch."]
|
|
233
|
+
T["<b>Publish to PyPI</b><br/>Build and upload distributions in one step."]
|
|
234
|
+
U["<b>Create GitHub Release</b><br/>Publish tag and attach changelog."]
|
|
235
|
+
R --> S --> T --> U
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
ReleaseProcess -->|Release Complete| DocDeployment
|
|
240
|
+
|
|
241
|
+
subgraph DocDeployment ["Documentation Deployment"]
|
|
242
|
+
X["<b>Generate API Documentation</b><br/>Automatically build API docs and update navigation"]
|
|
243
|
+
Y["<b>Install Package for Docs</b><br/>Prepare project for import-based documentation"]
|
|
244
|
+
Z["<b>Deploy to GitHub Pages</b><br/>Publish updated documentation site"]
|
|
245
|
+
X --> Y --> Z
|
|
246
|
+
end
|
|
247
|
+
```
|
|
248
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
onesecondtrader/__init__.py,sha256=TNqlT20sH46-J7F6giBxwWYG1-wFZZt7toDbZeQK6KQ,210
|
|
2
|
+
onesecondtrader/monitoring/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
onesecondtrader/monitoring/console.py,sha256=9_WrLnfG_IanqBX3FJQOy7ZYdceoTAXb5BXFYJTUq0o,298
|
|
4
|
+
onesecondtrader-0.7.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
onesecondtrader-0.7.0.dist-info/METADATA,sha256=WXbgynzRnwqWMZerSQidFXiEtw5rZCWEiEw4XCjQn7E,9518
|
|
6
|
+
onesecondtrader-0.7.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
7
|
+
onesecondtrader-0.7.0.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from .models import DomainModel
|
|
2
|
-
|
|
3
|
-
# Convenience aliases for domain models
|
|
4
|
-
MarketData = DomainModel.MarketData
|
|
5
|
-
PositionManagement = DomainModel.PositionManagement
|
|
6
|
-
SystemManagement = DomainModel.SystemManagement
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
"DomainModel",
|
|
10
|
-
"MarketData",
|
|
11
|
-
"PositionManagement",
|
|
12
|
-
"SystemManagement",
|
|
13
|
-
]
|
onesecondtrader/domain/models.py
DELETED
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Container module for non-component-specific domain models.
|
|
3
|
-
|
|
4
|
-
This module provides the non-component-specific domain models used across the
|
|
5
|
-
trading infrastructure.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import collections
|
|
9
|
-
import enum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class DomainModel:
|
|
13
|
-
"""
|
|
14
|
-
Container class for non-component-specific domain models.
|
|
15
|
-
Domain models are organised into namespaces to provide clear semantic groupings
|
|
16
|
-
(e.g.: `PositionManagement.OrderType.MARKET`).
|
|
17
|
-
Note that the namespace prefix `DomainModel` can be omitted when accessing
|
|
18
|
-
the domain models, i.e.: `DomainModel.MarketData.OHLCV` can be aliased as
|
|
19
|
-
`MarketData.OHLCV`.
|
|
20
|
-
|
|
21
|
-
???+ note "Domain Model Hierarchy"
|
|
22
|
-
|
|
23
|
-
```mermaid
|
|
24
|
-
---
|
|
25
|
-
config:
|
|
26
|
-
themeVariables:
|
|
27
|
-
fontSize: "11px"
|
|
28
|
-
---
|
|
29
|
-
graph LR
|
|
30
|
-
|
|
31
|
-
A0[DomainModels]
|
|
32
|
-
|
|
33
|
-
A01[MarketData]
|
|
34
|
-
A02[PositionManagement]
|
|
35
|
-
A03[SystemManagement]
|
|
36
|
-
|
|
37
|
-
A0 --> A01
|
|
38
|
-
A0 --> A02
|
|
39
|
-
A0 --> A03
|
|
40
|
-
|
|
41
|
-
A1["**MarketData.OHLCV**"]
|
|
42
|
-
A2["**MarketData.RecordType**"]
|
|
43
|
-
A01 --> A1
|
|
44
|
-
A01 --> A2
|
|
45
|
-
|
|
46
|
-
B1["**PositionManagement.OrderType**"]
|
|
47
|
-
B2["**PositionManagement.OrderState**"]
|
|
48
|
-
B3["**PositionManagement.Side**"]
|
|
49
|
-
B4["**PositionManagement.TimeInForce**"]
|
|
50
|
-
B5["**PositionManagement.CancelReason**"]
|
|
51
|
-
A02 --> B1
|
|
52
|
-
A02 --> B2
|
|
53
|
-
A02 --> B3
|
|
54
|
-
A02 --> B4
|
|
55
|
-
A02 --> B5
|
|
56
|
-
|
|
57
|
-
C1["**SystemManagement.StopReason**"]
|
|
58
|
-
A03 --> C1
|
|
59
|
-
|
|
60
|
-
subgraph MarketData ["Market Data Domain Models"]
|
|
61
|
-
A1
|
|
62
|
-
A2
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
subgraph PositionManagement ["Position Management Domain Models"]
|
|
66
|
-
B1
|
|
67
|
-
B2
|
|
68
|
-
B3
|
|
69
|
-
B4
|
|
70
|
-
B5
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
subgraph SystemManagement ["System Management Domain Models"]
|
|
74
|
-
C1
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
subgraph DomainModelNamespaces ["Domain Model Namespaces"]
|
|
78
|
-
A0
|
|
79
|
-
A01
|
|
80
|
-
A02
|
|
81
|
-
A03
|
|
82
|
-
end
|
|
83
|
-
```
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
# ----------------------------------------------------------------------------------
|
|
87
|
-
# SYSTEM MANAGEMENT DOMAIN MODEL NAMESPACE
|
|
88
|
-
# ----------------------------------------------------------------------------------
|
|
89
|
-
|
|
90
|
-
class SystemManagement:
|
|
91
|
-
"""
|
|
92
|
-
Domain model namespace for system management related concepts.
|
|
93
|
-
|
|
94
|
-
???+ note "Domain Model Hierarchy"
|
|
95
|
-
|
|
96
|
-
```mermaid
|
|
97
|
-
---
|
|
98
|
-
config:
|
|
99
|
-
themeVariables:
|
|
100
|
-
fontSize: "11px"
|
|
101
|
-
---
|
|
102
|
-
graph LR
|
|
103
|
-
|
|
104
|
-
A0[DomainModels]
|
|
105
|
-
|
|
106
|
-
A01[MarketData]
|
|
107
|
-
A02[PositionManagement]
|
|
108
|
-
A03[SystemManagement]
|
|
109
|
-
|
|
110
|
-
A0 --> A01
|
|
111
|
-
A0 --> A02
|
|
112
|
-
A0 --> A03
|
|
113
|
-
|
|
114
|
-
A1["**MarketData.OHLCV**"]
|
|
115
|
-
A2["**MarketData.RecordType**"]
|
|
116
|
-
A01 --> A1
|
|
117
|
-
A01 --> A2
|
|
118
|
-
|
|
119
|
-
B1["**PositionManagement.OrderType**"]
|
|
120
|
-
B2["**PositionManagement.OrderState**"]
|
|
121
|
-
B3["**PositionManagement.Side**"]
|
|
122
|
-
B4["**PositionManagement.TimeInForce**"]
|
|
123
|
-
B5["**PositionManagement.CancelReason**"]
|
|
124
|
-
A02 --> B1
|
|
125
|
-
A02 --> B2
|
|
126
|
-
A02 --> B3
|
|
127
|
-
A02 --> B4
|
|
128
|
-
A02 --> B5
|
|
129
|
-
|
|
130
|
-
C1["**SystemManagement.StopReason**"]
|
|
131
|
-
A03 --> C1
|
|
132
|
-
|
|
133
|
-
subgraph MarketData ["Market Data Domain Models"]
|
|
134
|
-
A1
|
|
135
|
-
A2
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
subgraph PositionManagement ["Position Management Domain Models"]
|
|
139
|
-
B1
|
|
140
|
-
B2
|
|
141
|
-
B3
|
|
142
|
-
B4
|
|
143
|
-
B5
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
subgraph SystemManagement ["System Management Domain Models"]
|
|
147
|
-
C1
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
subgraph DomainModelNamespaces ["Domain Model Namespaces"]
|
|
151
|
-
A0
|
|
152
|
-
A01
|
|
153
|
-
A02
|
|
154
|
-
A03
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
style SystemManagement fill:#6F42C1,fill-opacity:0.3
|
|
158
|
-
```
|
|
159
|
-
"""
|
|
160
|
-
|
|
161
|
-
class StopReason(enum.Enum):
|
|
162
|
-
"""
|
|
163
|
-
Reasons for system or component shutdown.
|
|
164
|
-
|
|
165
|
-
**Attributes:**
|
|
166
|
-
|
|
167
|
-
| Enum | Value | Description |
|
|
168
|
-
|------|-------|-------------|
|
|
169
|
-
| `SYSTEM_SHUTDOWN` | `enum.auto()` | Coordinated shutdown of entire system |
|
|
170
|
-
| `COMPONENT_DISCONNECT` | `enum.auto()` | Single component disconnect |
|
|
171
|
-
"""
|
|
172
|
-
|
|
173
|
-
SYSTEM_SHUTDOWN = enum.auto()
|
|
174
|
-
COMPONENT_DISCONNECT = enum.auto()
|
|
175
|
-
|
|
176
|
-
# ----------------------------------------------------------------------------------
|
|
177
|
-
# POSITION MANAGEMENT DOMAIN MODEL NAMESPACE
|
|
178
|
-
# ----------------------------------------------------------------------------------
|
|
179
|
-
|
|
180
|
-
class PositionManagement:
|
|
181
|
-
"""
|
|
182
|
-
???+ note "Domain Model Hierarchy"
|
|
183
|
-
|
|
184
|
-
```mermaid
|
|
185
|
-
---
|
|
186
|
-
config:
|
|
187
|
-
themeVariables:
|
|
188
|
-
fontSize: "11px"
|
|
189
|
-
---
|
|
190
|
-
graph LR
|
|
191
|
-
|
|
192
|
-
A0[DomainModels]
|
|
193
|
-
|
|
194
|
-
A01[MarketData]
|
|
195
|
-
A02[PositionManagement]
|
|
196
|
-
A03[SystemManagement]
|
|
197
|
-
|
|
198
|
-
A0 --> A01
|
|
199
|
-
A0 --> A02
|
|
200
|
-
A0 --> A03
|
|
201
|
-
|
|
202
|
-
A1["**MarketData.OHLCV**"]
|
|
203
|
-
A2["**MarketData.RecordType**"]
|
|
204
|
-
A01 --> A1
|
|
205
|
-
A01 --> A2
|
|
206
|
-
|
|
207
|
-
B1["**PositionManagement.OrderType**"]
|
|
208
|
-
B2["**PositionManagement.OrderState**"]
|
|
209
|
-
B3["**PositionManagement.Side**"]
|
|
210
|
-
B4["**PositionManagement.TimeInForce**"]
|
|
211
|
-
B5["**PositionManagement.CancelReason**"]
|
|
212
|
-
A02 --> B1
|
|
213
|
-
A02 --> B2
|
|
214
|
-
A02 --> B3
|
|
215
|
-
A02 --> B4
|
|
216
|
-
A02 --> B5
|
|
217
|
-
|
|
218
|
-
C1["**SystemManagement.StopReason**"]
|
|
219
|
-
A03 --> C1
|
|
220
|
-
|
|
221
|
-
subgraph MarketData ["Market Data Domain Models"]
|
|
222
|
-
A1
|
|
223
|
-
A2
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
subgraph PositionManagement ["Position Management Domain Models"]
|
|
227
|
-
B1
|
|
228
|
-
B2
|
|
229
|
-
B3
|
|
230
|
-
B4
|
|
231
|
-
B5
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
subgraph SystemManagement ["System Management Domain Models"]
|
|
235
|
-
C1
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
subgraph DomainModelNamespaces ["Domain Model Namespaces"]
|
|
239
|
-
A0
|
|
240
|
-
A01
|
|
241
|
-
A02
|
|
242
|
-
A03
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
style PositionManagement fill:#6F42C1,fill-opacity:0.3
|
|
246
|
-
```
|
|
247
|
-
"""
|
|
248
|
-
|
|
249
|
-
# ------------------------------------------------------------------------------
|
|
250
|
-
# ORDER TYPE
|
|
251
|
-
|
|
252
|
-
class OrderType(enum.Enum):
|
|
253
|
-
"""
|
|
254
|
-
Order execution types.
|
|
255
|
-
|
|
256
|
-
**Attributes:**
|
|
257
|
-
|
|
258
|
-
| Enum | Value | Description |
|
|
259
|
-
|------|-------|-------------|
|
|
260
|
-
| `MARKET` | `enum.auto()` | Execute immediately at best available price |
|
|
261
|
-
| `LIMIT` | `enum.auto()` | Execute only at specified price or better |
|
|
262
|
-
| `STOP` | `enum.auto()` | Becomes market order when trigger price is reached |
|
|
263
|
-
| `STOP_LIMIT` | `enum.auto()` | Becomes limit order when trigger price is reached |
|
|
264
|
-
"""
|
|
265
|
-
|
|
266
|
-
MARKET = enum.auto()
|
|
267
|
-
LIMIT = enum.auto()
|
|
268
|
-
STOP = enum.auto()
|
|
269
|
-
STOP_LIMIT = enum.auto()
|
|
270
|
-
|
|
271
|
-
# ------------------------------------------------------------------------------
|
|
272
|
-
# ORDER STATE
|
|
273
|
-
|
|
274
|
-
class OrderState(enum.Enum):
|
|
275
|
-
"""
|
|
276
|
-
Order lifecycle states.
|
|
277
|
-
|
|
278
|
-
**Attributes:**
|
|
279
|
-
|
|
280
|
-
| Enum | Value | Description |
|
|
281
|
-
|------|-------|-------------|
|
|
282
|
-
| `NEW` | `enum.auto()` | Created but not submitted |
|
|
283
|
-
| `SUBMITTED` | `enum.auto()` | Sent to broker/exchange |
|
|
284
|
-
| `ACTIVE` | `enum.auto()` | Live in market |
|
|
285
|
-
| `PARTIALLY_FILLED` | `enum.auto()` | Partially executed |
|
|
286
|
-
| `FILLED` | `enum.auto()` | Completely executed |
|
|
287
|
-
| `CANCELLED` | `enum.auto()` | Cancelled before first fill |
|
|
288
|
-
| `CANCELLED_AT_PARTIAL_FILL` | `enum.auto()` | Cancelled after partial fill |
|
|
289
|
-
| `REJECTED` | `enum.auto()` | Rejected by broker/exchange |
|
|
290
|
-
| `EXPIRED` | `enum.auto()` | Expired due to time-in-force constraints |
|
|
291
|
-
|
|
292
|
-
"""
|
|
293
|
-
|
|
294
|
-
NEW = enum.auto()
|
|
295
|
-
SUBMITTED = enum.auto()
|
|
296
|
-
ACTIVE = enum.auto()
|
|
297
|
-
PARTIALLY_FILLED = enum.auto()
|
|
298
|
-
FILLED = enum.auto()
|
|
299
|
-
CANCELLED = enum.auto()
|
|
300
|
-
CANCELLED_AT_PARTIAL_FILL = enum.auto()
|
|
301
|
-
REJECTED = enum.auto()
|
|
302
|
-
EXPIRED = enum.auto()
|
|
303
|
-
|
|
304
|
-
# ------------------------------------------------------------------------------
|
|
305
|
-
# SIDE
|
|
306
|
-
class Side(enum.Enum):
|
|
307
|
-
"""
|
|
308
|
-
Order direction - buy or sell.
|
|
309
|
-
|
|
310
|
-
**Attributes:**
|
|
311
|
-
|
|
312
|
-
| Enum | Value | Description |
|
|
313
|
-
|------|-------|-------------|
|
|
314
|
-
| `BUY` | `enum.auto()` | Buy the financial instrument |
|
|
315
|
-
| `SELL` | `enum.auto()` | Sell the financial instrument |
|
|
316
|
-
|
|
317
|
-
"""
|
|
318
|
-
|
|
319
|
-
BUY = enum.auto()
|
|
320
|
-
SELL = enum.auto()
|
|
321
|
-
|
|
322
|
-
# ------------------------------------------------------------------------------
|
|
323
|
-
# TIME IN FORCE
|
|
324
|
-
class TimeInForce(enum.Enum):
|
|
325
|
-
"""
|
|
326
|
-
Order time-in-force specifications.
|
|
327
|
-
|
|
328
|
-
**Attributes:**
|
|
329
|
-
|
|
330
|
-
| Enum | Value | Description |
|
|
331
|
-
|------|-------|-------------|
|
|
332
|
-
| `DAY` | `enum.auto()` | Valid until end of trading day |
|
|
333
|
-
| `FOK` | `enum.auto()` | Fill entire order immediately or cancel (Fill-or-Kill) |
|
|
334
|
-
| `GTC` | `enum.auto()` | Active until explicitly cancelled (Good-Till-Cancelled) |
|
|
335
|
-
| `GTD` | `enum.auto()` | Active until specified date (Good-Till-Date) |
|
|
336
|
-
| `IOC` | `enum.auto()` | Execute available quantity immediately, cancel rest (Immediate-or-Cancel) |
|
|
337
|
-
"""
|
|
338
|
-
|
|
339
|
-
DAY = enum.auto()
|
|
340
|
-
FOK = enum.auto()
|
|
341
|
-
GTC = enum.auto()
|
|
342
|
-
GTD = enum.auto()
|
|
343
|
-
IOC = enum.auto()
|
|
344
|
-
|
|
345
|
-
# ------------------------------------------------------------------------------
|
|
346
|
-
# CANCEL REASON
|
|
347
|
-
class CancelReason(enum.Enum):
|
|
348
|
-
"""
|
|
349
|
-
Reasons for order cancellation.
|
|
350
|
-
|
|
351
|
-
**Attributes:**
|
|
352
|
-
|
|
353
|
-
| Enum | Value | Description |
|
|
354
|
-
|------|-------|-------------|
|
|
355
|
-
| `CLIENT_REQUEST` | `enum.auto()` | Order cancelled by client/trader request |
|
|
356
|
-
| `EXPIRED_TIME_IN_FORCE` | `enum.auto()` | Order expired due to time-in-force constraints |
|
|
357
|
-
| `BROKER_REJECTED_AT_SUBMISSION` | `enum.auto()` | Broker rejected order during submission |
|
|
358
|
-
| `BROKER_FORCED_CANCEL` | `enum.auto()` | Broker cancelled order due to risk or other constraints |
|
|
359
|
-
| `UNKNOWN` | `enum.auto()` | Cancellation reason not specified or unknown |
|
|
360
|
-
"""
|
|
361
|
-
|
|
362
|
-
CLIENT_REQUEST = enum.auto()
|
|
363
|
-
EXPIRED_TIME_IN_FORCE = enum.auto()
|
|
364
|
-
BROKER_REJECTED_AT_SUBMISSION = enum.auto()
|
|
365
|
-
BROKER_FORCED_CANCEL = enum.auto()
|
|
366
|
-
UNKNOWN = enum.auto()
|
|
367
|
-
|
|
368
|
-
# ----------------------------------------------------------------------------------
|
|
369
|
-
# MARKET DATA DOMAIN MODEL NAMESPACE
|
|
370
|
-
# ----------------------------------------------------------------------------------
|
|
371
|
-
|
|
372
|
-
class MarketData:
|
|
373
|
-
"""
|
|
374
|
-
Domain model namespace for market data related concepts.
|
|
375
|
-
(Can be aliased as `MarketData` for convenience.)
|
|
376
|
-
|
|
377
|
-
???+ note "Domain Model Hierarchy"
|
|
378
|
-
|
|
379
|
-
```mermaid
|
|
380
|
-
---
|
|
381
|
-
config:
|
|
382
|
-
themeVariables:
|
|
383
|
-
fontSize: "11px"
|
|
384
|
-
---
|
|
385
|
-
graph LR
|
|
386
|
-
|
|
387
|
-
A0[DomainModels]
|
|
388
|
-
|
|
389
|
-
A01[MarketData]
|
|
390
|
-
A02[PositionManagement]
|
|
391
|
-
A03[SystemManagement]
|
|
392
|
-
|
|
393
|
-
A0 --> A01
|
|
394
|
-
A0 --> A02
|
|
395
|
-
A0 --> A03
|
|
396
|
-
|
|
397
|
-
A1["**MarketData.OHLCV**"]
|
|
398
|
-
A2["**MarketData.RecordType**"]
|
|
399
|
-
A01 --> A1
|
|
400
|
-
A01 --> A2
|
|
401
|
-
|
|
402
|
-
B1["**PositionManagement.OrderType**"]
|
|
403
|
-
B2["**PositionManagement.OrderState**"]
|
|
404
|
-
B3["**PositionManagement.Side**"]
|
|
405
|
-
B4["**PositionManagement.TimeInForce**"]
|
|
406
|
-
B5["**PositionManagement.CancelReason**"]
|
|
407
|
-
A02 --> B1
|
|
408
|
-
A02 --> B2
|
|
409
|
-
A02 --> B3
|
|
410
|
-
A02 --> B4
|
|
411
|
-
A02 --> B5
|
|
412
|
-
|
|
413
|
-
C1["**SystemManagement.StopReason**"]
|
|
414
|
-
A03 --> C1
|
|
415
|
-
|
|
416
|
-
subgraph MarketData ["Market Data Domain Models"]
|
|
417
|
-
A1
|
|
418
|
-
A2
|
|
419
|
-
end
|
|
420
|
-
|
|
421
|
-
subgraph PositionManagement ["Position Management Domain Models"]
|
|
422
|
-
B1
|
|
423
|
-
B2
|
|
424
|
-
B3
|
|
425
|
-
B4
|
|
426
|
-
B5
|
|
427
|
-
end
|
|
428
|
-
|
|
429
|
-
subgraph SystemManagement ["System Management Domain Models"]
|
|
430
|
-
C1
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
subgraph DomainModelNamespaces ["Domain Model Namespaces"]
|
|
434
|
-
A0
|
|
435
|
-
A01
|
|
436
|
-
A02
|
|
437
|
-
A03
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
style MarketData fill:#6F42C1,fill-opacity:0.3
|
|
441
|
-
```
|
|
442
|
-
"""
|
|
443
|
-
|
|
444
|
-
# ------------------------------------------------------------------------------
|
|
445
|
-
# OHLCV
|
|
446
|
-
|
|
447
|
-
OHLCV = collections.namedtuple(
|
|
448
|
-
"OHLCV", ["open", "high", "low", "close", "volume"]
|
|
449
|
-
)
|
|
450
|
-
"""
|
|
451
|
-
Simple data class for Open-High-Low-Close-Volume (OHLCV) bar data.
|
|
452
|
-
|
|
453
|
-
Attributes:
|
|
454
|
-
open (float): Open price
|
|
455
|
-
high (float): High price
|
|
456
|
-
low (float): Low price
|
|
457
|
-
close (float): Close price
|
|
458
|
-
volume (int | float): Volume
|
|
459
|
-
|
|
460
|
-
Examples:
|
|
461
|
-
>>> from onesecondtrader.domain.models import MarketData
|
|
462
|
-
>>> bar = MarketData.OHLCV(12.34, 13.74, 11.26, 12.32, 56789)
|
|
463
|
-
>>> bar.open
|
|
464
|
-
12.34
|
|
465
|
-
>>> bar.high
|
|
466
|
-
13.74
|
|
467
|
-
"""
|
|
468
|
-
|
|
469
|
-
# ------------------------------------------------------------------------------
|
|
470
|
-
# RECORD TYPE
|
|
471
|
-
|
|
472
|
-
class RecordType(enum.Enum):
|
|
473
|
-
"""
|
|
474
|
-
Market data record type identifiers that preserve compatibility with
|
|
475
|
-
Databento's rtype integer identifiers.
|
|
476
|
-
|
|
477
|
-
**Attributes:**
|
|
478
|
-
|
|
479
|
-
| Enum | Value | Description |
|
|
480
|
-
|------|-------|-------------|
|
|
481
|
-
| `OHLCV_1S` | `32` | 1-second bars |
|
|
482
|
-
| `OHLCV_1M` | `33` | 1-minute bars |
|
|
483
|
-
| `OHLCV_1H` | `34` | 1-hour bars |
|
|
484
|
-
| `OHLCV_1D` | `35` | Daily bars |
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
Examples:
|
|
488
|
-
>>> from onesecondtrader.domain.models import MarketData
|
|
489
|
-
>>> MarketData.RecordType.OHLCV_1S
|
|
490
|
-
<MarketData.RecordType.OHLCV_1S: 32>
|
|
491
|
-
>>> MarketData.RecordType.OHLCV_1S.value
|
|
492
|
-
32
|
|
493
|
-
>>> MarketData.RecordType.to_string(32)
|
|
494
|
-
'1-second bars'
|
|
495
|
-
>>> MarketData.RecordType.to_string(99)
|
|
496
|
-
'unknown (99)'
|
|
497
|
-
"""
|
|
498
|
-
|
|
499
|
-
OHLCV_1S = 32
|
|
500
|
-
OHLCV_1M = 33
|
|
501
|
-
OHLCV_1H = 34
|
|
502
|
-
OHLCV_1D = 35
|
|
503
|
-
|
|
504
|
-
@classmethod
|
|
505
|
-
def to_string(cls, record_type: int) -> str:
|
|
506
|
-
match record_type:
|
|
507
|
-
case cls.OHLCV_1S.value:
|
|
508
|
-
return "1-second bars"
|
|
509
|
-
case cls.OHLCV_1M.value:
|
|
510
|
-
return "1-minute bars"
|
|
511
|
-
case cls.OHLCV_1H.value:
|
|
512
|
-
return "1-hour bars"
|
|
513
|
-
case cls.OHLCV_1D.value:
|
|
514
|
-
return "daily bars"
|
|
515
|
-
case _:
|
|
516
|
-
return f"unknown ({record_type})"
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
# --------------------------------------------------------------------------------------
|
|
520
|
-
# ALIASES
|
|
521
|
-
# --------------------------------------------------------------------------------------
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
MarketData = DomainModel.MarketData
|
|
525
|
-
PositionManagement = DomainModel.PositionManagement
|
|
526
|
-
SystemManagement = DomainModel.SystemManagement
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: onesecondtrader
|
|
3
|
-
Version: 0.5.3
|
|
4
|
-
Summary: The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place.
|
|
5
|
-
Author: Nils P. Kujath
|
|
6
|
-
Author-email: 63961429+NilsKujath@users.noreply.github.com
|
|
7
|
-
Requires-Python: >=3.11
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
-
Requires-Dist: pandas (>=2.3.1,<3.0.0)
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
|
|
15
|
-
# OneSecondTrader
|
|
16
|
-
|
|
17
|
-
[](https://github.com/nilskujath/onesecondtrader/actions/workflows/release.yml)
|
|
18
|
-
[](https://www.onesecondtrader.com)
|
|
19
|
-
[](https://pypi.org/project/onesecondtrader/)
|
|
20
|
-
[](https://github.com/nilskujath/onesecondtrader/blob/master/LICENSE)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
For documentation, please visit [onesecondtrader.com](https://www.onesecondtrader.com).
|
|
24
|
-
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
onesecondtrader/__init__.py,sha256=58MDAIjNTzzg0fqH3b6Tgf2Cifzq9w5MdWUWVnzQa9I,462
|
|
2
|
-
onesecondtrader/domain/__init__.py,sha256=1KLObrd6j_QuA7_yws0ajZYyVEb1QC3toakvmcd_nsE,311
|
|
3
|
-
onesecondtrader/domain/models.py,sha256=qU3S27TgQJ1uIbM1TPF6poDFOFbrImHw8EADDMw_zi0,16523
|
|
4
|
-
onesecondtrader/monitoring.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
5
|
-
onesecondtrader-0.5.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
6
|
-
onesecondtrader-0.5.3.dist-info/METADATA,sha256=Hkyti4cDKugO46y9x_4h3gTAyCpsP91pzYYPKX0Xmhs,1220
|
|
7
|
-
onesecondtrader-0.5.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
8
|
-
onesecondtrader-0.5.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|