All Projects → samre12 → Deep Trading Agent

samre12 / Deep Trading Agent

Licence: mit
Deep Reinforcement Learning based Trading Agent for Bitcoin

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Deep Trading Agent

Gdax Orderbook Ml
Application of machine learning to the Coinbase (GDAX) orderbook
Stars: ✭ 60 (-89.53%)
Mutual labels:  bitcoin, trading, recurrent-neural-networks
Crypto Rl
Deep Reinforcement Learning toolkit: record and replay cryptocurrency limit order book data & train a DDQN agent
Stars: ✭ 328 (-42.76%)
Mutual labels:  bitcoin, trading, deep-reinforcement-learning
king-pong
Deep Reinforcement Learning Pong Agent, King Pong, he's the best
Stars: ✭ 23 (-95.99%)
Mutual labels:  agent, deep-reinforcement-learning, deep-q-network
Trending Deep Learning
Top 100 trending deep learning repositories sorted by the number of stars gained on a specific day.
Stars: ✭ 543 (-5.24%)
Mutual labels:  artificial-intelligence, deep-reinforcement-learning, recurrent-neural-networks
Pygame Learning Environment
PyGame Learning Environment (PLE) -- Reinforcement Learning Environment in Python.
Stars: ✭ 828 (+44.5%)
Mutual labels:  artificial-intelligence, deep-reinforcement-learning, agent
Top Deep Learning
Top 200 deep learning Github repositories sorted by the number of stars.
Stars: ✭ 1,365 (+138.22%)
Mutual labels:  artificial-intelligence, deep-reinforcement-learning, recurrent-neural-networks
Machine Learning And Ai In Trading
Applying Machine Learning and AI Algorithms applied to Trading for better performance and low Std.
Stars: ✭ 258 (-54.97%)
Mutual labels:  artificial-intelligence, bitcoin, trading
Wolfbot
Crypto currency trading bot written in TypeScript for NodeJS
Stars: ✭ 335 (-41.54%)
Mutual labels:  bitcoin, trading
Tribeca
A high frequency, market making cryptocurrency trading platform in node.js
Stars: ✭ 3,646 (+536.3%)
Mutual labels:  bitcoin, trading
Curl
CURL: Contrastive Unsupervised Representation Learning for Sample-Efficient Reinforcement Learning
Stars: ✭ 346 (-39.62%)
Mutual labels:  deep-reinforcement-learning, deep-q-network
First Steps Towards Deep Learning
This is an open sourced book on deep learning.
Stars: ✭ 376 (-34.38%)
Mutual labels:  artificial-intelligence, recurrent-neural-networks
Machine Learning For Trading
Code for Machine Learning for Algorithmic Trading, 2nd edition.
Stars: ✭ 4,979 (+768.94%)
Mutual labels:  artificial-intelligence, trading
Ta4j Origins
A Java library for technical analysis ***Not maintained anymore, kept for archival purposes, see #192***
Stars: ✭ 354 (-38.22%)
Mutual labels:  bitcoin, trading
Crypto Trader
💰 Cryptocurrency trading bot library with a simple example strategy (trading via Gemini).
Stars: ✭ 554 (-3.32%)
Mutual labels:  bitcoin, trading
Ccxt
A JavaScript / Python / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
Stars: ✭ 22,501 (+3826.88%)
Mutual labels:  bitcoin, trading
Erc20 Ico Onchain Technical Analysis
An tool to analyze any company's ICO
Stars: ✭ 326 (-43.11%)
Mutual labels:  bitcoin, trading
Lagom
lagom: A PyTorch infrastructure for rapid prototyping of reinforcement learning algorithms.
Stars: ✭ 364 (-36.47%)
Mutual labels:  artificial-intelligence, deep-reinforcement-learning
Phillip
The SSBM "Phillip" AI.
Stars: ✭ 508 (-11.34%)
Mutual labels:  artificial-intelligence, deep-reinforcement-learning
Deep Learning Bitcoin
Exploiting Bitcoin prices patterns with Deep Learning.
Stars: ✭ 481 (-16.06%)
Mutual labels:  artificial-intelligence, bitcoin
Bxbot
A simple Bitcoin trading bot written in Java.
Stars: ✭ 515 (-10.12%)
Mutual labels:  bitcoin, trading

Deep Trading Agent

license dep1 dep2 dep3 dep4 dep4
Deep Reinforcement Learning based Trading Agent for Bitcoin using DeepSense Network for Q function approximation.

model
For complete details of the dataset, preprocessing, network architecture and implementation, refer to the Wiki of this repository.

Requirements

  • Python 2.7
  • Tensorflow
  • Pandas (for pre-processing Bitcoin Price Series)
  • tqdm (for displaying progress of training)

To setup a ubuntu virtual machine with all the dependencies to run the code, refer to assets/vm.

Run with Docker

Pull the prebuilt docker image directly from docker hub and run it as

docker pull samre12/deep-trading-agent:latest
docker run -p 6006:6006 -it samre12/deep-trading-agent:latest

OR

Build the docker image locally by executing the command and the run the image as

docker build -t deep-trading-agent .
docker run -p 6006:6006 -it deep-trading-agent

This will setup the repository for training the agent and

  • mount the current directory into /deep-trading-agent in the container

  • during image build, the latest transactions history from the exchange is pulled and sampled to create per-minute scale dataset of Bitcoin prices. This dataset is placed at /deep-trading-agent/data/btc.csv

  • to initiate training of the agent, specify suitable parameters in a config file (an example config file is provided at /deep-trading-agent/code/config/config.cfg) and run the code using /deep-trading-agent/code/main.py

  • training supports logging and monitoring through Tensorboard

  • vim and screen are installed in the container to edit the configuration files and run tensorboard

  • bind port 6006 of container to 6006 of host machine to monitor training using Tensorboard

Support

Please give a ⭐️ to this repository to support the project 😄.

ToDo

Docker Support

  • [X] Add Docker support for a fast and easy start with the project

Improve Model performance

  • [X] Extract highest and lowest prices and the volume of Bitcoin traded within a given time interval in the Preprocessor
  • [X] Use closing, highest, lowest prices and the volume traded as input channels to the model (remove features calculated just using closing prices)
  • [X] Normalize the price tensors using the price of the previous time step
  • [X] For the complete state representation, input the remaining number of trades to the model
  • [X] Use separate diff price blocks to calculate the unrealized PnL
  • [ ] Use exponentially decayed weighted unrealized PnL as a reward function to incorporate current state of investment and stabilize the learning of the agent

Trading Model

is inspired by Deep Q-Trading where they solve a simplified trading problem for a single asset.
For each trading unit, only one of the three actions: neutral(1), long(2) and short(3) are allowed and a reward is obtained depending upon the current position of agent. Deep Q-Learning agent is trained to maximize the total accumulated rewards.
Current Deep Q-Trading model is modified by using the Deep Sense architecture for Q function approximation.

Dataset

Per minute Bitcoin series is obtained by modifying the procedure mentioned in this repository. Transactions in the Coinbase exchange are sampled to generate the Bitcoin price series.
Refer to assets/dataset to download the dataset.

Preprocessing

Basic Preprocessing
Completely ignore missing values and remove them from the dataset and accumulate blocks of continuous values using the timestamps of the prices.
All the accumulated blocks with number of timestamps lesser than the combined history length of the state and horizon of the agent are then filtered out since they cannot be used for training of the agent.
In the current implementation, past 3 hours (180 minutes) of per minute Bitcoin prices are used to generate the representation of the current state of the agent.
With the existing dataset (at the time of writing), following are the logs generated while preprocessing the dataset:

INFO:root:Number of blocks of continuous prices found are 58863
INFO:root:Number of usable blocks obtained from the dataset are 887
INFO:root:Number of distinct episodes for the current configuration are 558471

Advanced Preprocessing
Process missing values and concatenate smaller blocks to increase the sizes of continuous price blocks.
Standard technique in literature to fill the missing values in a way that does not much affect the performance of the model is using exponential filling with no decay.
(To be implemented)

Implementation

Tensorflow "1.1.0" version is used for the implementation of the Deep Sense network.

Deep Sense

Implementation is adapted from this Github repository with a few simplifications in the network architecture to incorporate learning over a single time series of the Bitcoin data.

Deep Q Trading

Implementation and preprocessing is inspired from this Medium post. The actual implementation of the Deep Q Network is adapted from DQN-tensorflow.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].