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.52k stars 1.02k forks source link

Instrument - Exception: No stream satisfies selector condition. #470

Open autronix opened 5 months ago

autronix commented 5 months ago

Hello,

I'm attempting to run the following code:

from tensortrade.oms.instruments import USD, Instrument
from tensortrade.oms.wallets import Wallet, Portfolio
from tensortrade.oms.exchanges import Exchange
from tensortrade.feed.core import DataFeed, Stream
from tensortrade.oms.services.execution.simulated import execute_order
from tensortrade.env.default import create
import tensortrade.env.default as default

# Instrument and Symbol
symbol = 'AAPL'
AAPL = Instrument(symbol, 2, symbol)

# Data Stream
data = [150, 152, 153, 151, 150]  # Example price data
price_stream = Stream.source(data, dtype="float").rename("USD-AAPL")

# Data Feed
feed = DataFeed([price_stream])

# Exchange
exchange = Exchange("simulated", service=execute_order)(feed)

# Wallets
portfolio = Portfolio(USD, [
    Wallet(exchange, 10000 * USD),
    Wallet(exchange, 10 * AAPL)
])

# Environment
env = create(
    feed=feed,
    portfolio=portfolio,
    action_scheme=default.actions.SimpleOrders(),
    reward_scheme=default.rewards.SimpleProfit(),
    window_size=10
)

# Testing the environment
observation = env.reset()
print("Initial observation:", observation)
action = env.action_space.sample()
next_state, reward, done, info = env.step(action)
print("Next state:", next_state)
print("Reward:", reward)

Every time I run the code I get the following error: Exception: No stream satisfies selector condition.

I can't seem to figure out what I am missing and the documentation doesn't seem to cover any examples that do this kind of use case.

Thanks