@vladisld WAS CONFUSED BY FOREX DATA FEED. YOU'RE RIGHT.
Posts made by SPECULARI FUND
-
RE: How to use IB delayed data
-
RE: Starting with Interactive Brokers (IB) - no data feed
@rluc99 said in Starting with Interactive Brokers (IB) - no data feed:
I have discovered the problem. It is not related to Backtrader.
I did some digging around on the IB website. It seems that the IB demo account does not allow historical bars through the API for anything other than FOREX. The same applies to paper trading or live accounts unless there is a subscription to the relevant market data feed. If there is a subscription in place then the historical bars are available at any time, including week-ends.
(As an aside, historical bars are constructed by TWS regardless of whether there is a subscription in place or not.)
Delayed data is available during market hours for accounts without market data subscription, but to obtain this data a flag has to be set in the API. I don't think Backtrader allows the user to set this flag but I have not investigated this in detail.Most of the above information comes from the following two links:
http://interactivebrokers.github.io/tws-api/market_data.html
http://interactivebrokers.github.io/tws-api/historical_data.htmlSo, it's not possible to get even delayed stock data from IB using Backtrader for not funded account right?
-
RE: How to use IB delayed data
Looks like not possible to get delayed stocks data with a paper not funded account from IB. I am right?
-
RE: Crossover + MACD error
@Xavier-Escudero said in Crossover + MACD error:
@SPECULARI-FUND I've the same problem. Have you any solution?
I used raw data from the API to this library.
-
How to use IB delayed data
Is it possible to use delayed data from IB (I mean paper, but not FOREX market) as a "live" strategy?
next()
will be called if data is delayed? Maybe my question is stupid, just try to understand the logic. Thanks! -
Crossover + MACD error
self.macd = btalib.macd(self.get_data_bars(self.symbol, '1Min')[self.symbol], pfast=self.params.macdfast, pslow=self.params.macdslow, psignal=self.params.macdsignal) self.macdX = btalib.crossover(self.macd.macd, self.macd.signal) print(self.macd.df)
time macd signal histogram 2020-10-19 11:37:00-04:00 NaN NaN NaN 2020-10-19 11:38:00-04:00 NaN NaN NaN 2020-10-19 11:39:00-04:00 NaN NaN NaN 2020-10-19 11:40:00-04:00 NaN NaN NaN 2020-10-19 11:41:00-04:00 NaN NaN NaN ... ... ... ... 2020-10-19 14:52:00-04:00 -0.248898 -0.304889 0.055992 2020-10-19 14:53:00-04:00 -0.252423 -0.298331 0.045908 2020-10-19 14:54:00-04:00 -0.225212 -0.289191 0.063979 2020-10-19 14:55:00-04:00 -0.164539 -0.273610 0.109071 2020-10-19 14:56:00-04:00 -0.086874 -0.250268 0.163394
Error:
UserWarning: evaluating in Python space because the '-' operator is not supported by numexpr for the bool dtype, use '^' instead f"evaluating in Python space because the {repr(op_str)} "
What I am doing wrong?
-
Backtesting question about "fromdate" and "todate" with polygon.io
DataFactory = store.getdata data = DataFactory( dataname=ticker, tz=timezone, timeframe=bt.TimeFrame.Minutes, compression=1, fromdate=pd.Timestamp(args.start), sessionstart=datetime.time(9, 30), sessionend=datetime.time(16, 00), historical=True)
I am using such parameters to backtest on history some simple strategy and I see that it runs from right date
fromdate
, but then after 1month of period, it skips all dates range and jump to the current last date. Any idea why this happens? -
RE: Running multiple symbols data feeds in live IB
@orenshkol @vladisld why when I am using with
resample
data insteadadddata
, strategy runs on the first symbol only? -
RE: My stop-loss order is getting executed when it shouldn't
May be you can help how check type of order that accepted? Because I am updating take profit Limit order by moving average price and every updating of price I receiving new Limit order - previous not replaced.
-
Live feed alpaca-backtrader-api - KeyError: ‘bidprice’
I understand that this is not bug by backtrader, but anyway maybe someone had the same.
When stock is hold by exchange or sometimes after overnight I see that type of error. How I can catch this?
File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1130, in run runstrat = self.runstrategies(iterstrat) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1301, in runstrategies self._runnext(runstrats) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1545, in _runnext drets.append(d.next(ticks=False)) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/feed.py", line 407, in next ret = self.load() File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/feed.py", line 479, in load _loadret = self._load() File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/alpaca_backtrader_api/alpacadata.py", line 301, in _load ret = self._load_tick(msg) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/alpaca_backtrader_api/alpacadata.py", line 401, in _load_tick msg['bidprice']) KeyError: 'bidprice'
-
RE: backtrader data same for 5days vs 50 days
@Ronan-Dunham do you have experience with
Alpaca API?
-
RE: Mechanic of next(self) function. Explain me please by experience
@ab_trader all my questions about orders event handling. But I understand that if I had broker terminal I wasn't confused with logs output and
next()
. Anyway, thank you for replies! -
RE: Mechanic of next(self) function. Explain me please by experience
@ab_trader how to check what minimal timeframe data feed can send?
-
RE: Mechanic of next(self) function. Explain me please by experience
@Yaroslav-Horyslavets thx for reply. Looks like I can't understand it because I test it without broker platfrom (only live feed) and my logs show after each "next()".
-
Mechanic of next(self) function. Explain me please by experience
Last 2 days I am testing live data feed. I noticed, that first resample timeframe is major for "next(self):" function. right?
So, if all logic calculates inside of this "loop" it will calculates at the same "speed" as your major timeframe, right?
My major resample timeframe is 1 minute, and when I receive signal my order create and it executes after 1 minute...or I am wrong? On backtesting I didn't understant this moment untill try live data, so looking for asnwer from experienced guys. Thx! -
RE: How convert data feed's (live) timezone?
@vladisld thank you for reply. Yes, I was asking about internal timezone for live data feed. So, you need add "tz" argument to Datafactory(tz=timezone). But if you want show in logs same timezone, need add to cerebro.run():
timezone = pytz.timezone("US/Eastern") cerebro.run(tz=timezone)
With last param I was confused because in logs I saw right timezone, but data feed has different (UTC).
-
How convert data feed's (live) timezone?
My data feed time in UNIX time 1588157340000 in milliseconds.
Using this site - https://www.epochconverter.com/ I see that this is GMT timezone. How convert to US/Eastern? It's possible?timezone = pytz.timezone("US/Eastern") cerebro.run()
This code change timezone for logs, but not for data feed.
-
Live data error ValueError: min() arg is an empty sequence
2020-05-04, 22:03:35, Price 1.37 2020-05-04, 22:03:37, Price 1.38 2020-05-04, 22:03:40, Price 1.38 2020-05-04, 22:03:49, Price 1.38 2020-05-04, 22:03:51, Price 1.38 2020-05-04, 22:04:01, Price 1.37 2020-05-04, 22:04:03, Price 1.37 2020-05-04, 22:04:04, Price 1.37 2020-05-04, 22:04:05, Price 1.37 2020-05-04, 22:04:06, Price 1.37 2020-05-04, 22:04:08, Price 1.37 2020-05-04, 22:04:09, Price 1.37 2020-05-04, 22:04:13, Price 1.37 2020-05-04, 22:04:18, Price 1.37 2020-05-04, 22:04:21, Price 1.37 2020-05-04, 22:04:23, Price 1.37 2020-05-04, 22:04:24, Price 1.38 2020-05-04, 22:04:25, Price 1.38 2020-05-04, 22:04:40, Price 1.38 2020-05-04, 22:04:44, Price 1.38 2020-05-04, 22:04:54, Price 1.38 2020-05-04, 22:04:56, Price 1.38 2020-05-04, 22:04:58, Price 1.38 Traceback (most recent call last): "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1130, in run runstrat = self.runstrategies(iterstrat) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1301, in runstrategies self._runnext(runstrats) File "/home/x777/anaconda3/envs/env_backtrader/lib/python3.6/site-packages/backtrader/cerebro.py", line 1560, in _runnext dt0 = min((d for i, d in enumerate(dts) ValueError: min() arg is an empty sequence
After random time of running script falling. I saw similar error on forum, but not clear understand why it happens. Can anybody explain me? Thanks!
-
RE: Bokeh Integration - Interactive Webbrowser Plotting
It's possible to hide "Meta" tab? Also, how add another datas (timeframes) below main? Thx!
-
RE: Anyone use Alpaca? (Zero commision stock trading)
@Devination Hi, I tried few days ago Alpaca and looks like withou funding account it's impossible to test it even for paper account. Maybe you know similiar services that could work with backtrader?