Giter VIP home page Giter VIP logo

Comments (12)

William-Ebertz avatar William-Ebertz commented on July 28, 2024 1

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.

shlomiku avatar shlomiku commented on July 28, 2024

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.

shlomiku avatar shlomiku commented on July 28, 2024

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.

William-Ebertz avatar William-Ebertz commented on July 28, 2024

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.

shlomiku avatar shlomiku commented on July 28, 2024

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.

William-Ebertz avatar William-Ebertz commented on July 28, 2024

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.

William-Ebertz avatar William-Ebertz commented on July 28, 2024

Hey, I confirmed that I'm getting the same error on the unmodified multiple_data_strategy script as well.

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024

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.

shlomiku avatar shlomiku commented on July 28, 2024

Hi, any update?

from alpaca-backtrader-api.

William-Ebertz avatar William-Ebertz commented on July 28, 2024

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.

shlomiku avatar shlomiku commented on July 28, 2024

could you pull the branch and try again?

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024

closing this issue. let me know if anything else is required

from alpaca-backtrader-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.