Comments (12)
The new branch is working, several buy and sell orders completed without exceptions. Should be able to run my own script now as well, thanks.
from alpaca-backtrader-api.
Hi
every time you see this AttributeError: 'Entity' object has no attribute 'symbol'
it means that the data returned from the server is not the expected data (usually it means you get an error message and when trying to wrap it with an Entity this is what you get)
let's first start by making sure that you have the latest version of the python-sdk
do this:
pip install -U git+https://github.com/alpacahq/alpaca-trade-api-python
from alpaca-backtrader-api.
and I just pulled the latest code from the master branch into this branch.
so make sure you pull this branch too
from alpaca-backtrader-api.
Thanks, I ran the updates on the trade api and this one. It looks like it recovered from two instances of this exception, though it still crashed:
Starting Portfolio Value: 99418.14
***** DATA NOTIF: LIVE
***** DATA NOTIF: LIVE
***** DATA NOTIF: LIVE
2020-06-15T16:42:30, <alpaca_backtrader_api.alpacadata.AlpacaData object at 0x729d9030>
2020-06-15T16:42:30, Crossover below: -0.02233333333333576
2020-06-15T16:42:30, 2020-06-15 16:42:36
ERROR:root:error while consuming ws messages: 'Entity' object has no attribute 'symbol'
2020-06-15T16:42:30, Order submitted/accepted, do nothing
ERROR:root:error while consuming ws messages: 'Entity' object has no attribute 'symbol'
Traceback (most recent call last):
File "multiple_data_strategy_days.py", line 173, in
strategy = cerebro.run(maxcpus=2)
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1298, in runstrategies
self._runnext(runstrats)
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1630, in _runnext
strat._next()
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/strategy.py", line 347, in _next
super(Strategy, self)._next()
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/lineiterator.py", line 265, in _next
self._notify()
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/strategy.py", line 606, in _notify
fundvalue = self.broker.fundvalue
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/broker.py", line 125, in get_fundvalue
return self.getvalue()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacabroker.py", line 160, in getvalue
self.value = float(self.o.oapi.get_account().portfolio_value)
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_trade_api/entity.py", line 29, in getattr
return super().getattribute(key)
AttributeError: 'Account' object has no attribute 'portfolio_value'
from alpaca-backtrader-api.
does it happen also with the sample code? I would like to execute it locally and try and see if it happens locally too
from alpaca-backtrader-api.
I'll try running the sample code tomorrow. In the meantime, here's the script I'm running.
multiple_data_strategy_mod.zip
from alpaca-backtrader-api.
Hey, I confirmed that I'm getting the same error on the unmodified multiple_data_strategy script as well.
from alpaca-backtrader-api.
Hi, I believe I fixed the issue.
pull from the branch again, and let me know if it works (or not)
from alpaca-backtrader-api.
Hi, any update?
from alpaca-backtrader-api.
Hey thanks for the patch, it seems to have fixed this error. However, I'm getting a new error when the multiple_data_strategy script places orders. As soon as the order is successfully placed, it quits with this message:
Starting Portfolio Value: 99419.47
2020-06-23T19:34:46, placing trade for AAPL. target size: 5
Traceback (most recent call last):
File "multiple_data_strategy.py", line 101, in
cerebro.run()
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1298, in runstrategies
self._runnext(runstrats)
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/cerebro.py", line 1542, in _runnext
drets.append(d.next(ticks=False))
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/feed.py", line 407, in next
ret = self.load()
File "/home/pi/.local/lib/python3.7/site-packages/backtrader/feed.py", line 479, in load
_loadret = self._load()
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacadata.py", line 302, in _load
ret = self._load_tick(msg)
File "/home/pi/.local/lib/python3.7/site-packages/alpaca_backtrader_api/alpacadata.py", line 389, in _load_tick
dtobj = datetime.utcfromtimestamp(int(msg['time']))
KeyError: 'time'
from alpaca-backtrader-api.
could you pull the branch and try again?
from alpaca-backtrader-api.
closing this issue. let me know if anything else is required
from alpaca-backtrader-api.
Related Issues (20)
- Not a reliable API
- backtrader-api uses deprecated alpaca-trade-api - will it be migrated to alpaca-py?
- Documentation for creating new Alpaca is broken. HOT 1
- Trading Calender - Package Issue HOT 3
- Cannot import alpaca-backtrader-api (Python 3.9.9 MacOS) HOT 5
- backtest not going back far enough HOT 2
- Multiple datas has connection limited error?
- alpaca-trade-api uses UTC while `_clear_out_of_market_hours` assumes NY Time. HOT 1
- Alpaca AttributeError: 'Asset' has not attribute 'status'
- Data websocket error with paper trading. Error code = 1002 (protocol error)
- Multiple WebSocket Open or Proxy - for multiple strategies
- Cannot purchase Long and create a trailing stop
- The Default Value for 'stocklike'
- only getting minute data until 12pm EST everyday in historical mode HOT 1
- Multiple datas sample no longer works HOT 1
- alpaca-trade-api-python is being deprecated by alpaca-py HOT 1
- Replay with historical data only retrieve daily bars instead replaying every minute
- module 'finplot' has no attribute 'add_order' HOT 1
- error installing on Windows 11, Python 3.9 HOT 3
- Wrong timezone for DataFactory
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 alpaca-backtrader-api.