Skip to content

Darenar/DeepLearningAssetPricing_torch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch version of Deep Learning for Asset Pricing

Introduction

This repository contains PyTorch implementation of the asset pricing model from the paper Deep Learning in Asset Pricing by Luyang Chen, Markus Pelger, and Jason Zhu (September 10, 2020).

An official TensorFlow implementation from repo was used as a prototype for this implementation.

Setup

Dependencies for Python 3.7:

  • Numpy 1.21.1
  • PyTorch 1.9.0

Install the required packages

pip install -r requirements.txt

Usage

Download the required dataset from the link. Place unpacked folder datasets in the main folder of the project. One could use command line to download the dataset using gdown package:

pip install gdown
gdown "https://drive.google.com/uc?id=1h9O7YwPLaRBbghtF50Cr-JmIq0aHHi4Y"
unzip datasets.zip

Run the script to train both GAN and Returns prediction models:

python run_torch.py

The list of arguments for the script is available by:

python run_torch.py --help

Results

Script stores model dumps and logging file in the folder with path given by --path_to_output option.

In the end of the logging file one could find calculated statistics (Explained Variation, XS-R2, Weighted XS-R2) for each dataset.

To calculate statistics on the given datasets and pretrained model run the following script:

python calculate_statistics.py

The results from this implementation are the following:

Dataset Explained Variation XS-R2 Weighted XS-R2
Train 0.12 0.024 0.16
Validation 0.05 0.028 0.016
Test 0.04 0.05 0.186

Those are the results from original TensorFlow implementation:

Dataset Explained Variation XS-R2 Weighted XS-R2
Train 0.17 -0.03 0.15
Validation 0.08 0.03 -0.01
Test 0.07 0.04 0.20

NOTE: Different weights initialization in PyTorch model affects the resulting metrics. Take this into account in your own experiments.

GPU support

The script automatically checks if there is a GPU available. One could check if GPU is available and correctly installed using:

import torch
if torch.cuda.is_available():
    print("Cuda is available")

About

Torch version of GAN-SDF network

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages