Giter Club home page Giter Club logo

commodity-trading-agent's Introduction

Cow_AI_rounded

๐Ÿค–๐Ÿ“ˆ RL Commodity Trading Agent

This repo provides a modular environment for training an agent to handle the procurement of agricultural commodities through the use of Reinforcement Learning. Created by Vesper in collaboration with Slimmer AI.

Check out the website for more information about our platform: Vesper - The commodity intelligence platform built to grow your business

GitHub release License issues - Commodity-Trading-Agent

rvdb7345 - Commodity-Trading-Agent stars - Commodity-Trading-Agent forks - Commodity-Trading-Agent

๐Ÿ’ฟ Current data

Current data added to the repo is:

  • US_SMP_food_TA.csv --> example data of the US Skimmed Milk Powder price including a set of Technical Indicators.

๐Ÿ’พ Installation

Before env installation: Make sure that openmpi is installed. If not yet installed, install by:

For Mac:

brew install open-mpi

As outlined in the documentation of mpi4py (for which open-mpi is needed), check if the mpicc compiler wrapper is on your search path by running echo $PATH. If not, add it by running export PATH=$PATH:~/path/to/mpicc for mac users the path is something like: "opt/homebrew/bin/mpicc"

For ubuntu:

sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev

Then install pip environment:

pipenv install

Now all requirements should be installed. Installation can also go through installation of the requirements.txt (if kept up-to-date).

IMPORTANT: this current environment is meant for MacOS-based systems. When using other operating systems, please install the appropriate TensorFlow version.

๐Ÿ‹๏ธ Training and Using the Agent

All code for running our agent SMP buyer can be found in agent_SMP_buyer.py. Running this file will now use the PPO actor-critic model from the stable baselines package and compare results with a simple baseline (baseline strategy: buy what is needed every week).

Flags

--verbose [str], -v [str]

This flag can be used to set the logger level, by default this is set to info level which logs basic information on training and simulating step. The debug level shows multiple measures/rewards per step.

--plot, -p

Enables plotting of rewards, inventory, actions of the simulation after training.

--trainsteps [int], -t [int]

Determines the number of training steps, default is 40000 which takes ยฑ1 minute. Running longer (>10min) is recommended for better results.

A command line example

python agent_SMP_buyer.py -v "debug" -t 20000 -p

๐Ÿค” Evaluating the algorithm

To evaluate the robustness of the RL algorithm, experiment_SMP_buyer.py can be used. It repeats the training and simulation of the model and then evaluates the significance of the difference between train and test scores and their baselines through Wilcoxon sign tests.

command line example

python experiment_SMP_buyer.py -t 40000 -r 30

--reps [int], -r [int]

Determines the number of experiment repetitions to estimate the robustness of the RL algorithm training.

๐ŸŽ› Evaluating the influence of a parameter

To evaluate the influence of a specific parameter, this repo provides functionality to do sensitivity analysis. This is done in sensitivity_analysis.py. Here, a value span can be given and the base parameters can be changed. Subsequently, you can set the reps and training steps using the appropriate flags and run the analysis using:

python sensitivity_analysis.py -t 40000 -r 30

After creating the results for every parameter, it can be visualised using the following command:

python visualise_SA.py

License

Released under MIT by @rvdb7345.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.