tensortrade-org / tensortrade

An open source reinforcement learning framework for training, evaluating, and deploying robust trading agents.
https://discord.gg/ZZ7BGWh
Apache License 2.0
4.56k stars 1.03k forks source link

Trading on live data #359

Open wnz99 opened 3 years ago

wnz99 commented 3 years ago

Apologies if this is not the best place for such sort of questions, but I think it's a fundamental part that is missing in the documentation.

Having trained an agent with agent with Ray, how can I then use it to make predictions on a live data feed?

It would be great if this page could be expanded to include this last step: https://github.com/tensortrade-org/tensortrade/blob/master/docs/source/examples/train_and_evaluate_using_ray.md

My understanding it that I should create an Exchange to intercept the orders. I managed to do that, however I was unable to understand how to properly feed live data.

tachon36 commented 2 years ago

I have come across the same problem too. According to this, I have been looking for the example like this:

import ccxt
from tensortrade.environments import TradingEnvironment
from tensortrade.strategies import StableBaselinesTradingStrategy
from tensortrade.exchanges.live import CCXTExchange
coinbase = ccxt.coinbasepro(...)
exchange = CCXTExchange(exchange=coinbase,
                        timeframe='1h',
                        base_instrument='USD', 
                        feature_pipeline=feature_pipeline)
environment = TradingEnvironment(exchange=exchange,
                                 action_scheme=action_scheme,
                                 reward_scheme=reward_scheme)
strategy.environment = environment
strategy.restore_agent(path="../agents/ppo_btc/1h")
live_performance = strategy.run(steps=0, trade_callback=episode_cb)

Could anyone please elaborate on how to run Live Trading on the latest tensortrade version?

Thank You in Advance