Skip to main content

akademy: A Reinforcement Learning Framework

Project description

Akademy

Akademy is a module containing composable object classes for developing reinforcement learning algorithms focused on quantitative trading and time-series forecasting. This module is a work-in-progress and should, at no time, be assumed to be designed well or be free of bugs.

Overview

Akademy is designed using an Agent-Environment model such that Agent-class objects ingest information from Environment-class objects (Env), produce an Action, which is then applied to the Environment which results in a change in State and possible reward to offer feedback to the agent.

Note: this module does not provide any training routines -- only the object class that can be used to support the implementation of custom training routines.

Getting Started

To install akademy use the following command in the desired Python 3.7+ environment:

pip install akademy

Once installed, developers will have access to Agent, TradeEnv, and Network class objects in which to design Reinforcement Learning algorithms to train models.

Sample training routine:

from akademy.models.envs import TradeEnv
from akademy.models.agents import DQNAgent
from akademy.common.utils import load_spy_daily

# loads the dataset used during training
data = load_spy_daily(count=2500)

# load the Trading Environment
env = TradeEnv(
    data=data,
    window=50,
    asset="spy",
)

# load the agent to train
agent = DQNAgent(
    action_count=env.action_space.n,
    state_shape=env.observation_space.shape
)

# load user-defined training routine
training_routine(
    agent=agent,
    env=env
)

Tests

Unit testing can be run via the following command:

python -m unittest

For detailed information the --verbose flag can be used. For more detailed usage consult the unittest module documentation.

Available Data

This module comes with minimal data for Agents and Environments to train on. The current data available is listed below, along with sources for the most up-to-date versions as well:

1. S&P500

Location: /data/SPY.CSV
Start: 1993-01-29
End: 2023-01-23
Total Rows: 7,454 (excludes header)
Header: Date,Open,High,Low,Close,Adj Close,Volume
Source: https://finance.yahoo.com/quote/SPY/history?p=SPY

note: Any data can be used easily enough via conversion into a Pandas DataFrame object, but must contain information for date and pricing data for open, high, low, and close as well as volume such that each row has at least those 6 features or the latter 5 and an index representative of date.

Notes

Gym vs. Gymnasium

The Gym project by OpenAI has been sunset and now maintained as Gymnasium by the Farama-Foundation. The Env classes present here make use of the newer Gymnasium package which, among other differences, produces an extra item in the step method indicating whether an environment has been truncated. See here

PyTorch

PyTorch requires some additional consideration for setup depending on use-case. Akademy uses an approach whereby CPU-based training and inferences are possible via parameterized function calls. However, GPU use (e.g. CUDA) requires local considerations. [See here] (https://pytorch.org/get-started/locally/) for a more in-depth discussion and guide.

This module currently uses the 1.* version, though a 2.* version release is imminent and an upgrade to that version is planned.

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

akademy-0.1.44.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

akademy-0.1.44-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file akademy-0.1.44.tar.gz.

File metadata

  • Download URL: akademy-0.1.44.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for akademy-0.1.44.tar.gz
Algorithm Hash digest
SHA256 5cbd386645ba0341d3b3f86f01e6cbd84631be9a61a7e96ea7c881cac4f72b91
MD5 e74086c0de14e6c80e4727218a613728
BLAKE2b-256 174f921f1beff3ec6b370ee8c495f0d2ad3614cc1275bd6b197f9ff089858417

See more details on using hashes here.

File details

Details for the file akademy-0.1.44-py3-none-any.whl.

File metadata

  • Download URL: akademy-0.1.44-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for akademy-0.1.44-py3-none-any.whl
Algorithm Hash digest
SHA256 002b8bdc47622ef347f4ad33c55f7913f9644f7f2ae063be61957c5c79cb31c4
MD5 54d233df06024e5f507837d7ab5df37d
BLAKE2b-256 82f10487c569f066ebf578525d4910206631daae4b316e77aeae257a2d8329b0

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