Deep Learning for VWAP Execution
This repository presents Aplo's latest research on VWAP execution and contains the code discussed in the paper Deep Learning for VWAP Execution in Crypto Markets: Beyond the Volume Curve.
Model
The model is proposed as a keras3 package that works with any backend (tensorflow, jax, or torch), although we recommend using jax for optimal performance.
Installation
- Download the repository
- Run
pip install .orpoetry install(recommended) in the root folder of the repository
Usage
from dvwap import StaticVWAP, quadratic_vwap_loss, absolute_vwap_loss, volume_curve_loss
BATCH_SIZE = 128
N_MAX_EPOCHS = 1000
# Specify your model parameters
# lookback and n_ahead are integer values representing the window sizes
model = StaticVWAP(lookback=lookback, n_ahead=n_ahead, input_include_aheads=False)
# The StaticVWAP is a keras model, so it works similarly
# To minimize the VWAP loss effectively, use a loss function that accounts for it
# These losses are available in the dvwap package
model.compile(optimizer='adam', loss=quadratic_vwap_loss)
# Training
history = model.fit(X_train, y_train, batch_size=BATCH_SIZE, epochs=N_MAX_EPOCHS,
validation_split=0.2, callbacks=callbacks(), shuffle=True, verbose=False)
# Prediction
preds = model.predict(X_test, verbose=False)
Model Parameters
lookbackandn_aheadare integer values representing the window sizes.input_include_aheads: You can have two formats of inputs for your model:- If
True, the feature inputs should be formatted to have a size oflookback + n_aheadon the sequence length. - If
False, pass inputs with onlylookbackon sequence length.
- If
Note: Future values are not used by the static model, as it gives its prediction at t0 for the full period. The input_include_aheads option is provided for flexibility when comparing with dynamic models that require future inputs to progressively update their predictions.
Loss Functions
The StaticVWAP is a Keras model. To minimize the VWAP loss effectively, you should use a loss function that accounts for it. These loss functions are available in the dvwap package:
quadratic_vwap_lossabsolute_vwap_lossvolume_curve_loss
Data Formatting
The model expects inputs as a dictionary:
{
"prices": array shape (num_elem, seq_len, 1),
"volumes": array shape (num_elem, seq_len, 1),
"features": array shape (num_elem, seq_len, num_features)
}
Training targets should be an array of shape (num_elem, n_ahead, 2) with volumes in the first element of the last dimension, and price in the second.
To use the default data formatter from the paper:
import pandas as pd
from dvwap.data_formater import full_generate
volumes = pd.read_parquet('path_to_your_volume_data.parquet')
notionals = pd.read_parquet('path_to_your_notionals_data.parquet')
X_train, X_test, y_train, y_test = full_generate(volumes, notionals, target_asset,
lookback=120, n_ahead=12, test_split=0.2,
include_ahead_inputs=False, autoscale_target=True)
Other models
The package also contains the dynamic framework following the paper 'Improving VWAP strategies: A dynamic volume approach', Jedrzej Bialkowski (1) , Serge Darolles (2) , Gaëlle Le Fol (3). It is available importing DynamicVWAPStandardModel. For more details look in the example and results section, or in the code.
Results
Tables and graphs of results from the paper can be found in the example_and_results folder.
License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Metadata
Release files for dvwap 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dvwap-0.1.0.tar.gz | 8.5 kB | Without provenance | Details for dvwap-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dvwap-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dvwap-0.1.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / dvwap-0.1.0.tar.gz
| Download URL | dvwap-0.1.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eda50797847a8cd30b593d2669164fa7273fa64dfe60f09574ff0fd2f4e5159f
|
|
BLAKE2b-256 checksum How to use checksums |
7859ca3acd31c07feef10eb106c846c2b02f6a828ba8bf83e4469bb296dbdea6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.2 Linux/6.8.0-52-generic
|
Release files / dvwap-0.1.0-py3-none-any.whl
| Download URL | dvwap-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b9c8bdde2aee9b5b1f135842c365b33dd50a64c0e16a94e92e4b8ecc8789f07
|
|
BLAKE2b-256 checksum How to use checksums |
74d8e2284e1a1278b48528105eaf3c8fe42628b826a6d6c7eb0f7abdf122b719
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.2 Linux/6.8.0-52-generic
|
Security for dvwap 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.