Skip to content

Commit

Permalink
push autoencoder statarb and backtesting directories to main branch p…
Browse files Browse the repository at this point in the history
…er mbennett
  • Loading branch information
esnvidia committed Nov 23, 2021
1 parent 5947f08 commit 450e253
Show file tree
Hide file tree
Showing 39 changed files with 6,098 additions and 0 deletions.
52 changes: 52 additions & 0 deletions autoencoder_statarb/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Autoencoder Statistical Arbitrage Repository OSS Contribution Rules

## Signing Your Work

1. We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. <em>Any contribution which contains commits that are not Signed-Off will not be accepted.</em>

2. To sign off on a commit you simply use the `--signoff` (or `-s`) option when committing your changes:
```
$ git commit -s -m "Add cool feature."
```
This will append the following to your commit message:
```
Signed-off-by: Your Name <[email protected]>
```
3. Full text of the DCO:
```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
File renamed without changes.
52 changes: 52 additions & 0 deletions autoencoder_statarb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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](https://en.wikipedia.org/wiki/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():

<pre>
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
</pre>
and the tail end of the file is:
<pre>
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
</pre>

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.
Loading

0 comments on commit 450e253

Please sign in to comment.