yfe404 / deep-crypto-unicorn-disruptive-fintech

Geospatial deep learning tool for unicorn feeding
1 stars 0 forks source link

** Workflow guidelines

  1. Use Jupyter to draft you strategies, do some plotting and try some indicators. See [[id:915ba80c-0e46-4efa-958a-dadd35f6380b][Run Jupyter]].
  2. Create a dedicated file for your strategy. See [[id:0fc05222-0007-441f-b8e6-de1a1a55b59f][Strategy quickstart]].
  3. Document as much as possible your strategy in the header of the file with at least the name of the strategy, the indicators involved and a URL to learn more about the strategy if it exists. example you can take a look at

** Strategy quickstart :PROPERTIES: :ID: 0fc05222-0007-441f-b8e6-de1a1a55b59f :END:

Create strategy:

+BEGIN_SRC sh

cp strategies/example_strategy.py strategies/my_strategy.py vim strategies/my_strategy.py

...

+END_SRC

Run strategy (ie. on /datasets/rates_2017_may_60min.csv/):

+BEGIN_SRC sh

./strategies/my_strategy.py datasets/rates_2017_may_60min.csv

+END_SRC

Test strategy:

+BEGIN_SRC sh

./strategy_simulator.py datasets/rates_2017_may_60min.csv MY_STRATEGY.csv

+END_SRC

** Docker usage

*** Build image

+BEGIN_SRC sh

docker build -t trading:latest .

+END_SRC

NOTE: To avoid rebuilding when changing source code, run the image with ~-v $(pwd):/home/unicorn/work~.

*** Download stock dataset

| Input | Output | |--------+--------| | API credentials | Stock dataset |

Download rates for the month of January with a granularity of 30s:

+BEGIN_SRC sh

export GDAX_API_KEY=XXX GDAX_API_SECRET=XXX GDAX_API_PASS=XXX

./tools/historic_rates_downloader.py 2017-01-01T06:00:00 2017-01-31T23:59:59 60 BTC-USD > res.csv

Downloading historic rates between 2017-01-01 06:00:00 and 2017-01-31 23:59:59 with granularity of 60 seconds

Downloading rates between 2017-01-01 06:00:00 and 2017-01-01 09:20:00 ...

Downloading rates between 2017-01-01 09:20:00 and 2017-01-01 12:40:00 ...

...

+END_SRC

NOTE: Samples are not guaranteed to be uniformly distributed. Please plot against timestamp.

*** Run strategies

| Input | Output | |--------+--------| | Stock dataset | Actions |

+BEGIN_SRC sh

docker run -it trading python strategies/XXX.py -h

+END_SRC

*** Simulator usage

| Input | Output | |--------+--------| | Stock dataset, strategy actions | Simulation result |

+BEGIN_SRC sh

docker run -it trading python strategy_simulator.py -h usage: strategy_simulator.py [-h] [--investment AMOUNT] [--reinvest-rate RATE] DATASET ACTIONS

positional arguments: DATASET path to the stock rates dataset ACTIONS path to the timestep to action mapping generated by the strategy

optional arguments: -h, --help show this help message and exit --investment AMOUNT initial investment (default: 1000) --reinvest-rate RATE reinvest rate (default: 0.5)

+END_SRC

*** Run Jupyter :PROPERTIES: :ID: 915ba80c-0e46-4efa-958a-dadd35f6380b :END:

To run jupyter-notebook in the container with the web interface accessible from within the browser of the host machine:

+BEGIN_SRC sh

sudo docker run -p 8888:8888 -v $(pwd):/home/unicorn/data trading \ jupyter-notebook --ip=0.0.0.0 --port=8888 --notebook-dir=/home/unicorn/data

+END_SRC

You'll then be able to access the interface at http://localhost:8888/

You'll be asked to enter a token, this token is visible in the terminal a few seconds after having launch the above command.

Note that this command will also mount the local directory (from which the command is launch, typically from this repository) to =/home/unicorn/data=. This allows you to persists you work achieved through the web interface.

See [[https://docs.docker.com][Docker documentation]] for more information about the options used.

** File formats

**** Stock dataset

+BEGIN_SRC csv

time,low,high,open,close,volume 1483228800,970.42,973.4,973.37,970.42,58.11304124 1483229700,969.9,971.37,970.42,970.7,38.38647656 1483230600,970.88,971.99,971.08,971.82,33.3203246

+END_SRC

**** Strategy output

+BEGIN_SRC csv

time,action 1495328400.0,NOTHING 1495329300.0,BUY 1495330200.0,SELL

+END_SRC