项目作者: kkuette

项目描述 :
Trading environnement for RL agents, backtesting and training.
高级语言: Python
项目地址: git://github.com/kkuette/TradzQAI.git
创建时间: 2017-05-27T13:55:54Z
项目社区:https://github.com/kkuette/TradzQAI

开源协议:Apache License 2.0

下载


TradzQAI

Trading environnement for RL agents, backtesting and training.

Live session with coinbasepro-python is finaly arrived !

  • Available sessions:

    • Local
      • 1M bar datasets any size.
        • header should be [‘Time’, ‘Open’, ‘High’, ‘Low’, ‘Close’, ‘Volume’] with ‘;’ as separator
      • Tick datasets any size.
        • header should be [‘Time’, ‘BID’, ‘ASK’, ‘VOL’] or [‘Time’, ‘Price’, ‘Volume’] with ‘,’ as separator
    • Live
      • Gdax API
  • Available agents:

    • DDPG
    • DQFD
    • DQN
    • DQNN
    • NAF
    • PPO
    • TRPO
    • VPG
  • Available contract type:

    • CFD
    • Classic

TradzQAI has been inspired by q-trader.

Indicators lib come from pyti

More datasets available here

Status

  1. Alpha in development
  2. GUI rework on track

Getting Started

  • Dependencies :

    Installation :

    pip install -r requirements.txt

  • Running the project

    1. Usage:
    2. python run.py -h (Show usage)
    3. python run.py -b agent_name (to manually build config file, it build config files from agent, default PPO)
    4. python run.py -s live (for live session)
    5. python run.py -m eval (for eval mode)
    6. python run.py -c config_dir/ # load config from directory, make sure you have agent, env and network json files in it
    7. python run.py (Run as default)

    When you run it for the first time, a config directory is created, you can change it to changes environnement settings and some agents settings.
    It save settings (env, agent, network) in a save directory, and create a new directory if make any changes.

    • Do you own decision function for maker side.
      For more info look at this function

      1. from core import Local_session as Session
      2. from mymodule import myfunc
      3. session = Session(mode=args.mode, config=args.config)
      4. session.initApi(key=key, b64=b64, passphrase=passphrase, url=url,
      5. product_id=product_id)
      6. session.getApi().setBestPriceFunc(myfunc)
    • Do your own runner.

      1. from core import Local_session as Session
      2. session = Session() # Run with default values
      3. session.loadSession() # loading environnement, worker and agent
      4. session.start() # Start the session thread
    • Do your own worker.
      1. from core import Local_env
      2. env = Local_env() # run with default values
      3. for e in episode:
      4. state = env.reset()
      5. for s in step:
      6. action = agent.act(state)
      7. next_state, terminal, reward = env.execute(action)
      8. agent.observe(reward, terminal)
      9. if terminal or env.stop:
      10. break
      11. if env.stop or e == episode - 1:
      12. env.logger._running = False #Close the logger thread
      13. break
    • How to use networks.

      • You have to define your input to fit with columns name of your datasets, it will automaticaly it grab input from network and compare it with your dataset columns in getState function, it allow you to do complex network like this :

        1. [
        2. [
        3. {"names": ["Price"], "type": "input"},
        4. {"activation": "relu", "size": 8, "type": "dense"},
        5. {"activation": "relu", "size": 8, "type": "dense"},
        6. {"name": "pricenet", "type": "output"}
        7. ],
        8. [
        9. {"names": ["Volume"], "type": "input"},
        10. {"activation": "relu", "size": 8, "type": "dense"},
        11. {"activation": "relu", "size": 8, "type": "dense"},
        12. {"name": "volnet", "type": "output"}
        13. ],
        14. [
        15. {"names": ["pricenet", "volnet"], "type": "input"},
        16. {"activation": "relu", "size": 64, "type": "dense"},
        17. {"activation": "relu", "size": 32, "type": "dense"},
        18. {"activation": "relu", "size": 8, "type": "dense"},
        19. {"name": "prediction", "type": "output"}
        20. ]
        21. ]
        • Simple network are handled as well without defining any input:
          1. [
          2. {"activation": "relu", "size": 64, "type": "dense"},
          3. {"activation": "relu", "size": 64, "type": "dense"}
          4. ]
    • Also TradzQAI support pre trained keras model:
      • You can build settings for your model by using py run.py -b DEEP.
        Your model have to be placed in the same directory as the one you use to launch it and have to be called deep_model.h5.

Relevant project

This project isn’t perfect so keep this in mind.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.