Agent for an OpenAI Gym environment, implementing a Keras model as feature extractor.
This agent loads an standardized observation dataset on a gym environment, reads observations from it and executes actions based on the output of a Keras model used as feature extractor, and a neat-python pre-optimized neural network used as action controller.
Exports a csv containing the agent state (balance, equity, orders status) and the trading history.
The agent is implemented in the AgentDeep class, it has methods for loading a dataset on a simulation environment, performing steps of the simulation and d it and producing an output dataset and a configuration file that can be loaded and applied to another dataset, please see test_agent_deep. It can also be used via command line.
The module is installed with the preprocessor package, the instructions are described in the following section.
- Clone the GithHub repo:
git clone https://github.com/harveybc/preprocessor
- Change to the repo folder:
cd preprocessor
- Install requirements.
pip install -r requirements.txt
- Install python package (also installs the console command data-trimmer)
python setup.py install
- (Optional) Perform tests
python setup.py install
- (Optional) Generate Sphinx Documentation
python setup.py docs
The standardizer also is implemented as a console command:
standardizer -- input_file <input_dataset> <optional_parameters>
- --input_file : The only mandatory parameter, is the filename for the input dataset to be trimmed.
- --output_file : (Optional) Filename for the output dataset. Defaults to the input dataset with the .output extension.
- --output_config_file : (Optional) Filename for the output configuration containing rows trimmed in columns 0 and columns trimmed in column 1. Defaults to the input dataset with the .config extension.
- --input_config_file : (Optional) Imports an existing configuration and trims a dataset with it.
The following examples show both the class method and command line uses.
from preprocessor.standardizer.standardizer import Standardizer
# configure parameters (same vaiable names as command-line parameters)
class Conf:
def __init__(self):
self.input_file = "tests/data/test_input.csv"
conf = Conf()
# instance trimmer class and loads dataset
st = Standardizer(conf)
# do the trimming
st.standardize()
# save output to output file
st.store()
standardizer --input_file "tests/data/test_input.csv"