Skip to content

Latest commit

 

History

History
 
 

autoencoder_statarb

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

AutoEncoderStatArb

Train a TensorFlow-based deep autoencoder on log returns for the Dow Jones 30 securities in the initial minutes of 2018 for use subsequently to make long/short trade entry decisions for the rest of the year. This technique is known as Statistical Arbitrage. Profit from temporary mispricings.

Build and run the Docker container

Note: the Dockerfile expects to see a prices.csv file in the directory to copy into the container to be able to buid and run. See Providing sample data below.

  • BUILD: docker build --network=host --file docker/Dockerfile --tag daesa:nvidia .
  • RUN: docker run --gpus all --rm -it -p 8888:8888 -p 8889:8889 -p 8890:8890 -p 8891:8891 -v $(pwd):$HOME daesa:nvidia

Providing sample data

The rationale is contained in the figures in the .png files, referred to in the Python notebook.

Note: be sure to run the main cuDAESA.ipynb in cell-by-cell run mode because of the length of time to run the main simulation loop cell. Do not use this notebook in run-all mode.

Two options for providing the price quotes to the TensorFlow-based deep autoencoder Python notebook are:

(1) using 1-minute quotes for the NASDAQ and NYSE stock exchanges from EODData.com and using the widedf.ipynb Python notebook to format those or

(2) using another source meeting the format shown below:

Here is a sample of the format of the 1-minute 30 security input read by read_csv():

Date,AAPL,CSCO,INTC,MSFT,JNJ,JPM,KO,MCD,MMM,NKE,PFE,PG,TRV,UNH,UTX,V,VZ,WMT,XOM,AXP,BA,CAT,CVX,DWDP,DIS,GE,GS,HD,IBM,MRK
02-Jan-2018 09:00,170.15,38.51,46.35,85.9,139.61,107.6,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,99.93,296.05,158.3,125.8,71.56,108.6,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:01,170.18,38.51,46.35,85.9,139.61,107.6,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,99.93,296.05,158.3,125.8,71.56,108.6,17.53,256.95,190.2,154.25,56.58
02-Jan-2018 09:02,170.16,38.51,46.35,85.9,139.61,107.6,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,99.93,296.05,158.3,125.8,71.56,108.6,17.53,256.95,190.2,154.25,56.58
02-Jan-2018 09:03,170.15,38.51,46.35,85.9,139.61,107.68,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,99.93,296.05,158.3,125.98,71.56,108.8,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:04,170.15,38.51,46.35,85.9,139.61,107.7,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,99.93,296.05,158.3,125.98,71.56,108.8,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:05,170.15,38.51,46.35,85.9,139.61,107.7,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,100.73,296.05,158.3,125.98,71.56,108.8,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:06,170.18,38.51,46.35,86.0,139.61,107.65,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.56,53.06,99.2,84.05,100.73,296.05,158.3,125.8,71.56,108.8,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:07,170.16,38.51,46.35,86.0,139.61,107.7,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.8,53.06,99.2,84.05,100.73,296.05,158.3,125.8,71.56,108.8,17.54,256.95,190.2,154.25,56.58
02-Jan-2018 09:08,170.18,38.51,46.3,86.0,139.61,107.81,45.95,173.28,236.55,62.7,36.34,92.24,136.41,221.7,128.16,114.66,53.06,99.2,84.05,100.73,296.25,158.3,125.96,71.56,108.8,17.55,256.7,190.2,154.25,56.58

and the tail end of the file is:

31-Dec-2018 16:50,157.7,43.38,46.93,101.57,129.02,97.62,47.35,177.57,190.54,74.13,43.65,91.92,119.75,249.12,106.48,131.94,56.01,93.07,68.19,95.32,322.5,127.07,108.9,53.48,109.65,7.54,166.8,171.82,113.5,76.31
31-Dec-2018 16:51,157.7,43.38,46.93,101.65,129.02,97.62,47.35,177.57,190.54,74.13,43.65,91.92,119.75,249.12,106.48,131.94,56.01,93.07,68.19,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,171.82,113.5,76.31
31-Dec-2018 16:52,157.7,43.38,46.93,101.65,129.02,97.62,47.35,177.57,190.54,74.13,43.65,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.19,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:53,157.7,43.38,46.93,101.65,129.02,97.63,47.35,177.57,190.54,74.13,43.65,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.17,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:54,157.77,43.38,46.93,101.65,129.02,97.63,47.35,177.57,190.54,74.13,43.65,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.17,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:55,157.77,43.38,46.93,101.65,129.02,97.63,47.35,177.57,190.54,74.13,43.55,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.17,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:56,157.77,43.34,46.93,101.65,129.02,97.63,47.35,177.57,190.54,74.13,43.55,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.17,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:57,157.77,43.34,46.94,101.65,129.02,97.63,47.35,177.57,190.54,74.13,43.55,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.19,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.31
31-Dec-2018 16:58,157.77,43.34,46.94,101.7,129.02,97.63,47.35,177.57,190.54,74.13,43.75,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.19,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.5
31-Dec-2018 16:59,157.77,43.34,46.94,101.7,129.02,97.55,47.35,177.57,190.54,74.13,43.75,91.92,119.75,249.12,106.48,131.94,56.11,93.07,68.19,95.32,322.5,127.07,108.89,53.48,109.65,7.54,166.8,172.0,113.5,76.6

If you have your own source of 1-minute, split-adjusted, dividend-adjusted price quotes, and can format it per above then the notebook will run with it.