Skip to content

akalikadien/torch_trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Torch trader

A simulation of a cryptocurrency trader using deep-Q learning in Pytorch. During my minor a similar trader (CrypTorch) was created by my group. Using this experience and knowledge I tried to build an improved trader from scratch. I did this project to get more experience in machine learning and data science.

This software is intended for learning purposes only

The trader has 3 actions: it can either buy as much BTC as possible, sell as much BTC as possible or hold its current position.

fetch_data.py

Contains functions for fetching and modifying data. CCXT is used to fetch OHLCV data from exchanges. Price data from cryptocurrencypricehistory/ originates from this kaggle dataset. Pre-processing of data is done using 9 indicators. These will be the features that are fed to the neural network.

neuralnet.py

Contains the neural network class and functions. A nn with two linear layers and 1 Relu layer is used.

portfolio.py

Contains buying and selling functions and returns the corresponding action.

agent.py

Contains logic of the trading agent. The training and testing loop are as described in this paper. In summary:

  1. Starting in current state s, feedforward through the network with state variables as input and a Q-value as output.
  2. Use an action selection criterion to select an action a based on computed Q values.
  3. Perform action a on state s resulting in state s' and calculate immediate reward r.
  4. Compute Q' = reward + gamma*max(Q(s', a')) (Bellman)
  5. Backpropagate

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages