← Open Source
thedimlebowski

Trading-Gym

Trading Gym is an open source project for the development of reinforcement learning algorithms in the context of trading.

Model DevelopmentEnvironmentsPython
Open on GitHub
Momentum
+0stars in 24 hours0.0%
568
Stars
150
Forks
+0
This week
3
Contributors
Created 2017-06-13 · Updated 2026-09-19 · #16876 today
Top developers
thedimlebowskipm-bebabball

thedimlebowski/Trading-Gym is ranked 16,876 with 568 stars.

Same-category comparison

thedimlebowski/Trading-Gym is ranked 16,876 among these 8 peers; uber-research/PyTorch-NEAT is ranked 16,877.

Same-category comparison
NameRankMetrics
mlverse/torch16,857
Language:
C++
Stars:
569
Forks:
93
Description:
R Interface to Torch.
mmasana/FACIL16,858
Language:
Python
Stars:
569
Forks:
102
Description:
Framework for Analysis of Class-Incremental Learning with 12 state-of-the-art methods and 3 baselines.
ilovepose/DarkPose16,865
Language:
Cuda
Stars:
568
Forks:
82
Description:
Distribution-Aware Coordinate Representation for Human Pose Estimation.
microsoft/foldingdiff16,871
Language:
Jupyter Notebook
Stars:
568
Forks:
75
Description:
Diffusion models of protein structure; trigonometry and attention are all you need.
uber-research/PyTorch-NEAT16,877
Language:
Python
Stars:
568
Forks:
99
HKUDS/SSLRec16,881
Language:
Python
Stars:
567
Forks:
82
Description:
[WSDM'2024 Oral] "SSLRec: A Self-Supervised Learning Framework for Recommendation".
MarvinTeichmann/ConvCRF16,883
Language:
Python
Stars:
567
Forks:
131
Description:
This repository contains the reference implementation for our proposed Convolutional CRFs.
assafshocher/ResizeRight16,886
Language:
Python
Stars:
567
Forks:
52
Description:
The correct way to resize images or tensors. For Numpy or Pytorch (differentiable).
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguagePython
CategoryModel Development
SubcategoryEnvironments
KeywordsFinance, Trading
Stars568
Forks150
Contributors3
Created date2017-06-13
Updated date2026-09-19
Stars in 1 day0
Stars in 7 days0
Rank16,876
Previous rank16,669
Rank change-207
7-day stars rank15,776
Previous 7-day stars rank15,785
7-day stars rank change9
Total stars rank17,546
Previous total stars rank17,515
Total stars rank change-31
CountryUK
README summary

Trading Gym Trading Gym is an open-source project for the development of reinforcement learning algorithms in the context of trading. It is currently composed of a single environment and implements a generic way of feeding this trading environment different type of price data. Installation We strongly recommend using virtual environments. A very good guide can be found at The trading environment: is a trading environment allowing to trade a *spread* (see We feed the environment a time series of

prices (bid and ask) for *n* different products (with a ), as well as a list of *spread coefficients*. The possible actions are then buying, selling or holding the spread. Actions cannot be taken on one or several legs in isolation. The state of the environment is defined as: prices, entry price and position (whether long, short or flat). Create your own To create your own data generator, it must inherit from the base class which can be found in the

file 'tgym/core. Only the private method which defines the times series needs to be overridden. For only one product, the method **must** yield a tuple, one element at a time. For two or more products, you must return a tuple consisting of bid and ask prices for each product, concatenated. For instance for two products, the method should yield . The logic for the time series is encoded there. Compatibility with OpenAI gym Our environments API is strongly inspired by

OpenAI Gym. We aim to entirely base it upon OpenAI Gym architecture and propose Trading Gym as an additional OpenAI environment. Examples Some examples are available in To run the example, you will need to also install keras with . By default, the backend will be set to Theano. You can also run it with Tensorflow by installing it with . You then need to edit and make sure is specified.

Frequently asked questions

How many stars and forks are recorded?

thedimlebowski/Trading-Gym has 568 stars and 150 forks.

What is the repository rank?

thedimlebowski/Trading-Gym is ranked 16,876.

What language and category are recorded?

thedimlebowski/Trading-Gym has 568 stars, uses Python and belongs to Model Development.

Which repository is closest in rank?

thedimlebowski/Trading-Gym is compared with uber-research/PyTorch-NEAT, ranked 16,877 with 568 stars.

README

Trading Gym

Trading Gym is an open-source project for the development of reinforcement learning algorithms in the context of trading. It is currently composed of a single environment and implements a generic way of feeding this trading environment different type of price data.

Installation

pip install tgym

We strongly recommend using virtual environments. A very good guide can be found at http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/.

The trading environment: SpreadTrading

SpreadTrading is a trading environment allowing to trade a spread (see https://en.wikipedia.org/wiki/Spread_trade). We feed the environment a time series of prices (bid and ask) for n different products (with a DataGenerator), as well as a list of spread coefficients. The possible actions are then buying, selling or holding the spread. Actions cannot be taken on one or several legs in isolation. The state of the environment is defined as: prices, entry price and position (whether long, short or flat).

Create your own DataGenerator

To create your own data generator, it must inherit from the DataGenerator base class which can be found in the file 'tgym/core.py'. It consists of four methods. Only the private _generator method which defines the times series needs to be overridden. Example can be found at examples/generator_random.py. For only one product, the _generator method must yield a (bid, ask) tuple, one element at a time. For two or more products, you must return a tuple consisting of bid and ask prices for each product, concatenated. For instance for two products, the method should yield (bid_1, ask_1, bid_2, ask_2). The logic for the time series is encoded there.

Compatibility with OpenAI gym

Our environments API is strongly inspired by OpenAI Gym. We aim to entirely base it upon OpenAI Gym architecture and propose Trading Gym as an additional OpenAI environment.

Examples

Some examples are available in tgym/examples/

To run the dqn_agent.py example, you will need to also install keras with pip install keras. By default, the backend will be set to Theano. You can also run it with Tensorflow by installing it with pip install tensorflow. You then need to edit ~/.keras/keras.json and make sure "backend": "tensorflow" is specified.

Nearby in the ranking
Similar items