Skip to main content

Reinforcement Learning OpenAI Gym environment for crypto-currency trading.

Project description

gym-crypto

OpenAI Gym compatible environment for crypto-currency trading. The environment allows to change the currency the bot trades, the granularity of trading and starting capital of the agent. More configurability to come in the future.

Observation Space

The observation space is a tuple structured as follows:

(OCHLV, Current Capital, Weight of the capital invested)

OCHLV represents Open, Close, High, Low prices and Volume respectively.

Action Space

Action space is a single scalar between -1 and 1, which represents the percentage of the capital that the agent has invested into the currency at the last time step.

-1 representing a full short position and 1 representing a full long position.

Rewards

The reward is defined as the total amount of capital that has been gained/lost for that time-step. This number includes the return on the investment as well as the transaction costs.

Usage

In order to train the agent, the enviroment first has to be configured. This can be done as follows:

import gym

env = gym.make("gym-crypto-v0")

start_date = '2018-01-01'
end_date = '2019-01-01'

currency = 'BTC'
granularity = '15min'
transaction_pct = 0.001
capital = 100

kwargs = {'currency':currency, 'granularity':granularity,
          'transaction_pct':transaction_pct, 'capital':capital,
          'start_date': start_date, 'end_date':end_date}

env.configure_env(**kwargs)

To get some results from the agent, a env.render() needs to be called, which will return the capital returns as the first variable and weight allocation as the second variable. More detailed results will be coming in the future.

Data

To futher inspect the data two methods can be called from the data_utils module.

from gym_crypto.data_utils.data_utils import *

currencies = get_avaliable_currencies()
full_data = read_data('BTC')

All data was obtained from the Bitfinex API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gym-crypto-0.0.3.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gym_crypto-0.0.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file gym-crypto-0.0.3.tar.gz.

File metadata

  • Download URL: gym-crypto-0.0.3.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for gym-crypto-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ad9c65873be6cce25c15e20c367dd7571d1d85e29a5663b4569f6f364574b8ef
MD5 ae61a5e0fdd9680a7d77ade88796b013
BLAKE2b-256 5a3fef06cb56787088db02367daca6955ff5882299b5609b674de01845c9fa54

See more details on using hashes here.

File details

Details for the file gym_crypto-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: gym_crypto-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for gym_crypto-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dbbafeb8763d170c5d82e532c9b6dbadde1b469508ffc7ee9646f204509ebaa4
MD5 136c26d24eceb31ef6c28ddac4c074d1
BLAKE2b-256 289f818258c54d585b22a5f3337100e6fb7ac964c045cf6021eb3c52b111bc65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page