Comments (6)
@gaitay ,
can you provide more details on settings your are running? Does it happens with one of the examples or your own code and data?
from btgym.
yes it happens with one of the examples,
when episode finished.
import gym
from gym import spaces
import backtrader as bt
from btgym import BTgymDataset, BTgymBaseStrategy, BTgymEnv
MyCerebro = bt.Cerebro()
MyCerebro.addstrategy(BTgymBaseStrategy,
state_shape={'raw_state': spaces.Box(low=0,high=1,shape=(20,4))},
skip_frame=5,
state_low=None,
state_high=None,
drawdown_call=50,
)
MyCerebro.broker.setcash(100.0)
MyCerebro.broker.setcommission(commission=0.001)
MyCerebro.addsizer(bt.sizers.SizerFix, stake=10)
MyCerebro.addanalyzer(bt.analyzers.DrawDown)
MyDataset = BTgymDataset(filename='../examples/data/DAT_ASCII_EURUSD_M1_2016.csv',
start_weekdays=[0, 1, 2, 4],
start_00=True,
episode_len_days=0,
episode_len_hours=23,
episode_len_minutes=55,
time_gap_days=0,
time_gap_hours=5,
)
MyEnvironment = BTgymEnv(dataset=MyDataset,
engine=MyCerebro,
port=5555,
verbose=1,
)
observation = MyEnvironment.reset()
for t in range(1000):
MyEnvironment.render()
print(observation)
action = MyEnvironment.action_space.sample()
observation, reward, done, info = MyEnvironment.step(action)
if done:
print("Episode finished after {} timesteps".format(t+1))
from btgym.
I just spent some time tracking down solutions to both issues.
ValueError: Axis limits cannot be NaN or Inf
This is an issue caused by taking max() of an array full of NaNs and appears to be caused by a recent update of matplotlib. It is in the process of being fixed. For the time being, I changed line 130 in backtrader/plot/scheme.py from self.volume = True to self.volume = False to disable volume plots.
AttributeError: 'FigureCanvasAgg' object has no attribute 'renderer'
This is an easy fix but took quite a bit of time to track down. Open btgym/rendering/plotter.py and add: fig.canvas.draw() before line 76 where rgb_string is called.
I'm new to Github and not familiar with pull requests so could someone else make this change? Andrew has done an amazing job so far and I'd like to contribute anything I can!
from btgym.
@tmorgan4, @gaitay,
thank you for tracking this down. Indeed BTgym was developed to use Matplotlib 2.0.2 and crashes when 2.1 version is installed.
Solution:
The easiest way until ValueError
is not fixed is to use matplotlib v/2.0.2
How to do:
It is highly recommended to run BTGym in designated virtual environment.
If you reinstalling btgym from scratch - just do nothing as v.2.0.2 is now specified in package dependencies and should install correct version of Matplotlib.
Else:
downgrade your matplotlib installation (that's where virtual env is handy):
`pip install matplotlib==2.0.2`
Remark to @tmorgan4: I'm a bit paranoid about using fig.canvas.draw()
as it potentially can lead to memory leaks. I had very though time fighting that issue when coding it initially. Anyway there is btgym/tests/render_memory_leak_test.ipynb you can try and see if it runs Ok.
from btgym.
@Kismuz @tmorgan4
Thank you for all your hard work!
from btgym.
@Kismuz @tmorgan4
Thank you for all your hard work!
from btgym.
Related Issues (20)
- Is there any real-life cases of successful application of reinforcement learning in trading / asset management? HOT 4
- Overestimated Value Function in Actor Critic Framework HOT 7
- signal.pause() - workers exit, but signal never received -- software issue? (debian linux) HOT 16
- loading multiple features - question ? HOT 3
- Amazing project <3
- PR Request for Docker addition HOT 2
- Train Test routine sampling - IndexError HOT 2
- BTgymMultiData - Sync between different data stream HOT 5
- Discussion: Long Episode Duration HOT 3
- Tutorial: Integration with TF-Agents RL Framework HOT 4
- Erroneous static_RNN policy behavior explanation.
- 2020
- BTGym Slack Join Link Broken HOT 1
- Problem with dependencies in installation on window HOT 1
- Examples that do more that randomly selects an action?
- Support Tensorflow 2 HOT 14
- ValueError: Axis limits cannot be NaN or Inf HOT 1
- INFOS
- Use btgym custom environment
- _pickle.PicklingError: Can't pickle <class 'pandas.core.frame.Pandas'>: attribute lookup Pandas on pandas.core.frame failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btgym.