Skip to content

Commit 79b4d77

Browse files
authored
1.105.0
2 parents ea441c3 + f2cc2ce commit 79b4d77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+847
-289
lines changed

.flake8

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exclude =
2424
dist
2525
docs
2626
noxfile.py
27-
ignore = E225, E227, E252, E999
27+
ignore = E225, E227, E252, E999, DAR402
2828
max-complexity = 10
2929
max-line-length = 150
3030
statistics = True
@@ -35,3 +35,4 @@ statistics = True
3535
# E227 missing whitespace around bitwise or shift operator (picks up pointers)
3636
# E252 spaces around default argument assignment (incorrect syntax)
3737
# E999 SyntaxError: invalid syntax (cimport seen as invalid syntax)
38+
# D402 Excess exception(s) in Raises section (picks up legitimate multiple exceptions)

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,19 @@ The `master` branch will always reflect the code of the latest release version.
103103
Also, the documentation is always current for the latest version.
104104

105105
The package is tested against Python 3.7 - 3.9 on both Linux and MacOS.
106+
We recommend running the platform with the latest stable version of Python.
106107

107-
We recommend users setup a virtual environment to isolate the dependencies, and run the platform
108-
with the latest stable version of Python.
108+
Unfortunately Windows installations are not currently supported. Attempts have
109+
been made to get the project more compatible with Windows, however there are some
110+
low level implementation details currently preventing this from being possible.
109111

110-
`pyenv` is the recommended tool for handling Python installations and virtual environments.
112+
It is a goal for the project to keep dependencies focused, however there are
113+
still a large number of dependencies as found in the `pyproject.toml` file.
114+
Therefore we recommend you create a new virtual environment for NautilusTrader
115+
to isolate the dependencies.
116+
117+
`pyenv` is the recommended tool for handling system wide Python installations
118+
and virtual environments.
111119

112120
> https://github.com/pyenv/pyenv
113121
@@ -289,6 +297,10 @@ Refer to the [Developer Guide](https://nautilus-trader.readthedocs.io/en/latest/
289297

290298
## Contributing
291299

300+
Even as some issues are marked with the `help wanted` label - this does not imply
301+
that help is _only_ wanted on those issues. The label indicates where 'extra attention'
302+
is needed.
303+
292304
Involvement from the trading community is a goal for this project. All help is welcome!
293305
Developers can open issues on GitHub to discuss proposed enhancements/changes, or
294306
to make bug reports.

docs/source/developer_guide/coding_standards.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Code Style
99

1010
We philosophically agree with the ``Black`` formatting style, however it does not
1111
currently run over Cython code. So you could say we are "handcrafting towards"
12-
``Black``s stylistic conventions.
12+
``Black`` stylistic conventions.
1313

1414
The current codebase can be used as a guide for formatting guidance.
1515

16-
1- For longer lines of code, and when passing more than a couple of arguments
16+
1- For longer lines of code, and when passing more than a couple of arguments,
1717
it's common to take a new line which aligns at the next logical indent (rather
1818
than attempting a hanging alignment off an opening parenthesis).
1919

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Developing Adapters
22
===================
33

4-
WIP
4+
**work in progress**

docs/source/developer_guide/environment.rst

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ For development we recommend using the PyCharm `Professional` edition IDE, as it
55
interprets Cython syntax. Alternatively, you could use Visual Studio Code with
66
a Cython extension.
77

8+
``pyenv`` is the recommended tool for handling Python installations and virtual environments.
9+
10+
> https://github.com/pyenv/pyenv
11+
812
``poetry`` is the preferred tool for handling all Python package and dev dependencies.
913

1014
> https://python-poetry.org/
@@ -18,22 +22,22 @@ Setup
1822
-----
1923
The following steps are for Unix-like systems, and only need to be completed once.
2024

21-
1. Install ``pre-commit`` by running::
22-
23-
pip install pre-commit
24-
25-
2. Install the Cython package by running:
25+
1. Install the Cython package by running::
2626

2727
pip install -U Cython==3.0a6
2828

29-
3. Install ``poetry`` by running::
29+
2. Install ``poetry`` by running::
3030

3131
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
3232

33-
4. Then install all Python package dependencies, and compile the C extensions by running::
33+
3. Then install all Python package dependencies, and compile the C extensions by running::
3434

3535
poetry install
3636

37+
4. Install the ``pre-commit`` package by running::
38+
39+
pip install pre-commit
40+
3741
5. Setup the ``pre-commit`` hook which will then run automatically at commit by running::
3842

3943
pre-commit run --all-files

docs/source/developer_guide/overview.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ frameworks and libraries, whilst overcoming some of its inherent shortcomings in
1313
performance and lack of built in type safety (with it being an interpreted
1414
dynamic language).
1515

16-
One of the advantages of Cython is that we don't have to concern ourselves with
17-
memory safety, as that is handled by its C code generator during the 'cythonization'
18-
step of the build. So we get the best of both worlds - with Pythons clean straight
19-
forward syntax, and a lot of potential to extract several orders of magnitude
20-
greater runtime performance through compiled C dynamic libraries.
16+
One of the advantages of Cython is that allocation and freeing of memory is
17+
handled by the C code generator during the 'cythonization' step of the build
18+
(unless you're specifically utilizing some of its lower level features).
19+
20+
So we get the best of both worlds - with Pythons clean straight forward syntax,
21+
and a lot of potential to extract several orders of magnitude greater runtime
22+
performance through compiled C dynamic libraries.
2123

2224
The main development and runtime environment we are working in is of course Python.
2325
However with the introduction of Cython syntax throughout the production codebase

docs/source/developer_guide/testing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Testing
22
=======
33

4-
The test suite is divided into broad categories of tests including;
4+
The test suite is divided into broad categories of tests including:
55
- Unit tests
66
- Integration tests
77
- Acceptance/System tests
@@ -55,5 +55,5 @@ of an if-else block which would catch an unrecognized value, these should be
5555
left in place in case there is a change to the production code - which these
5656
checks could then catch.
5757

58-
Other 'design-time' exceptions may also be impossible to test for, and so 100%
58+
Other `design-time` exceptions may also be impossible to test for, and so 100%
5959
test coverage is not the ultimate goal.

docs/source/getting_started/core_concepts.rst

+14-17
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ There are two main reasons for conducting backtests on historical data;
1919
Backtesting with an event-driven engine such as NautilusTrader is not meant to be the primary
2020
research method for alpha discovery, but merely facilitates the above.
2121

22-
One of the primary benefits of this platform is
23-
that the machinery used inside the backtest engine is identical for live trading, apart from the live versions of the data and execution engines
24-
closer to the periphery of the system (they add asyncio queues on top of the common implementations), and integrations with external
25-
endpoints through adapters provided with this package (and/or developed by end users).
22+
One of the primary benefits of this platform is that the machinery used inside
23+
the backtest engine is identical for live trading, apart from the live versions
24+
of the data and execution engines closer to the periphery of the system (they
25+
add asyncio queues on top of the common implementations), and integrations with
26+
external endpoints through adapters provided with this package (and/or developed
27+
by end users).
2628

2729
This helps ensure consistency when seeking to capitalize on alpha through a large
2830
sample size of trades, as expressed in the logic of the trading strategies.
@@ -31,23 +33,18 @@ Only a small amount of example data is available in the ``test`` directory of
3133
the repository - as used in the examples. There are many sources of financial
3234
market data, and it is left to the user to supply this for backtesting purposes.
3335

34-
The platform is extremely flexible and open ended, you could inject dozens of different
35-
datasets into a backtest engine, running them simultaneously with time being
36-
accurately simulated down to the smallest ``timedelta`` definable by Python.
36+
The platform is extremely flexible and open ended, you could inject dozens of
37+
different datasets into a backtest engine, running them simultaneously with time
38+
being accurately simulated down to the smallest ``timedelta`` definable by
39+
Python.
3740

3841
Trading Live
3942
------------
40-
A ``TradingNode`` is able to host a fleet of trading strategies,
41-
with data able to be ingested from multiple data clients, and
42-
order execution and management through multiple execution clients.
43+
A ``TradingNode`` hosts a fleet of trading strategies, with data able to be
44+
ingested from multiple data clients, and order execution through multiple
45+
execution clients.
4346

44-
There are two main modes of for live deployment;
45-
46-
- Demo account
47-
- Real account
48-
49-
The only difference here being whether the accounts are controlling
50-
real assets.
47+
Live deployments can use both demo/paper trading accounts, or real accounts.
5148

5249
Coming soon there will be further discussion of core concepts...
5350

docs/source/getting_started/installation.rst

+14-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@ Installation
44
The ``master`` branch will always reflect the code of the latest release version.
55
Also, the documentation is always current for the latest version.
66

7-
The package is tested against Python versions 3.7 - 3.9 on both Linux and
8-
MacOS. Users are encouraged to use the latest stable version of Python.
7+
The package is tested against Python 3.7 - 3.9 on both Linux and MacOS.
8+
We recommend running the platform with the latest stable version of Python.
9+
10+
Unfortunately Windows installations are not currently supported. Attempts have
11+
been made to get the project more compatible with Windows, however there are some
12+
low level implementation details currently preventing this from being possible.
913

1014
It is a goal for the project to keep dependencies focused, however there are
1115
still a large number of dependencies as found in the ``pyproject.toml`` file.
12-
Therefore we recommend you create a new virtual environment for NautilusTrader.
16+
Therefore we recommend you create a new virtual environment for NautilusTrader
17+
to isolate the dependencies.
1318

14-
There are various ways of achieving this - the easiest being to use the ``poetry``
15-
tool. https://python-poetry.org/docs/
19+
`pyenv` is the recommended tool for handling system wide Python installations
20+
and virtual environments.
1621

17-
If you're not used to working with virtual environments, you will find a great
18-
explanation in the ``poetry`` documentation under the `Managing environments`
19-
sub-menu.
22+
> https://github.com/pyenv/pyenv
2023

21-
Installation for Unix-like systems can be achieved through `one` of the following options;
24+
Installation for Unix-like systems can be achieved through `one` of the
25+
following options;
2226

2327
From PyPI
2428
---------
2529

26-
To install the latest binary wheel (or sdist package) from PyPI, run:
30+
To install the latest binary wheel (or sdist package) from PyPI, run::
2731

2832
pip install -U nautilus_trader
2933

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Backtesting
22
===========
3+
4+
**work in progress**
+1-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
Deploying Live
22
==============
33

4-
Encryption
5-
----------
6-
7-
For effective remote deployment of a live `TradingNode` which needs to access remote services,
8-
encryption keys must be user generated. The currently supported encryption scheme is that which is built
9-
into ZeroMQ being Curve25519 elliptic curve algorithms. This allows perfect forward security with
10-
ephemeral keys being exchanged per connection. The public `server.key` must be shared with the trader
11-
ahead of time and contained in the `keys\` directory (see below).
12-
13-
To generate a new client key pair from a python console or .py run the following;
14-
15-
.. code-block::
16-
17-
from pathlib import Path
18-
19-
import zmq.auth
20-
21-
keys_dir = 'path/to/your/keys'
22-
Path(keys_dir).mkdir(parents=True, exist_ok=True)
23-
24-
zmq.auth.create_certificates(keys_dir, 'client')
25-
26-
Live Deployment
27-
---------------
28-
29-
The user must assemble a directory including the following;
30-
31-
- `config.json` for configuration settings
32-
- `keys/` directory containing the `client.key_secret` and `server.key`
33-
- `launch.py` referring to the strategies to run
34-
- trading strategy python or cython files
4+
**work in progress**

docs/source/user_guide/framework.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ feature rich yet straight forward API. `Domain Driven Design` (DDD) and message
1212
have been central philosophies in the design.
1313

1414
From a high level view - a ``Trader`` can host any number of infinitely customizable
15-
``TradingStrategy``s. A central ``Portfolio`` has access to ``Account``s which can all be queried.
16-
A common ``DataEngine`` and ``ExecutionEngine`` then allow asynchronous ingest of any data
15+
``TradingStrategy`` instances. A central ``Portfolio`` has access to multiple ``Account`` instances,
16+
which can all be queried.
17+
18+
A common ``DataEngine`` and ``ExecutionEngine`` allows asynchronous ingest of any data
1719
and trade events, with the core componentry common to both backtesting and live implementations.
1820

1921
Currently a performant Redis execution database maintains state persistence
2022
(swapped out for an in-memory only implementation for backtesting).
2123
It should be noted that the flexibility of the framework even allows the live trading
2224
Redis database to be plugged into the backtest engine. Interestingly there is
23-
only a 4x performance overhead which speaks to the raw speed of Redis and the
24-
platform itself.
25+
only a 4x performance overhead which speaks to the raw speed of Redis.
26+
27+
**work in progress**
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Writing Indicators
22
==================
3+
4+
**work in progress**
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Writing Strategies
22
==================
3+
4+
**work in progress**

nautilus_trader/common/logging.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ cdef class LoggerAdapter:
107107

108108
cdef readonly str component_name
109109
"""The loggers component name.\n\n:returns: `str`"""
110-
cdef readonly bint bypassed
110+
cdef readonly bint is_bypassed
111111
"""If the logger is in bypass mode.\n\n:returns: `bool`"""
112112

113113
cpdef Logger get_logger(self)

nautilus_trader/common/logging.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ cdef class Logger:
195195
name : str
196196
The name of the logger.
197197
bypass_logging : bool
198-
If the logger should be completely bypassed.
198+
If the logger should be bypassed.
199199
level_console : LogLevel (Enum)
200200
The minimum log level for logging messages to the console.
201201
level_file : LogLevel (Enum)
@@ -359,7 +359,7 @@ cdef class LoggerAdapter:
359359

360360
self._logger = logger
361361
self.component_name = component_name
362-
self.bypassed = logger.bypass_logging
362+
self.is_bypassed = logger.bypass_logging
363363

364364
cpdef Logger get_logger(self):
365365
"""
@@ -491,7 +491,7 @@ cdef class LoggerAdapter:
491491
LogColor color,
492492
str message,
493493
) except *:
494-
if not self.bypassed:
494+
if not self.is_bypassed:
495495
self._logger.log(LogMessage(
496496
self._logger.clock.utc_now_c(),
497497
level,

nautilus_trader/data/base.pxd

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ cdef class Data:
3535

3636

3737
cdef class DataType:
38+
cdef frozenset _metadata_key
39+
3840
cdef readonly type type
3941
"""The type of the data.\n\n:returns: `type`"""
4042
cdef readonly dict metadata
41-
"""The data types metadata.\n\n:returns: `dict[str, object]`"""
43+
"""The data types metadata.\n\n:returns: `set[str, object]`"""
4244

4345

4446
cdef class DataCacheFacade:

0 commit comments

Comments
 (0)