Deep-Learning for Optimal VWAP Execution
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dvwap-0.1.0.tar.gz.
File metadata
- Download URL: dvwap-0.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.8.0-52-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eda50797847a8cd30b593d2669164fa7273fa64dfe60f09574ff0fd2f4e5159f
|
|
| MD5 |
747d4722dbb5a77afed023e4621ccd39
|
|
| BLAKE2b-256 |
7859ca3acd31c07feef10eb106c846c2b02f6a828ba8bf83e4469bb296dbdea6
|
File details
Details for the file dvwap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dvwap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.2 Linux/6.8.0-52-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b9c8bdde2aee9b5b1f135842c365b33dd50a64c0e16a94e92e4b8ecc8789f07
|
|
| MD5 |
917e65b56404d654399149fee807cbc9
|
|
| BLAKE2b-256 |
74d8e2284e1a1278b48528105eaf3c8fe42628b826a6d6c7eb0f7abdf122b719
|