Comments (18)
Hi Justin
it is not related to your account type
alpaca-backtrader opens a websocket to each data you add.
there's a branch that I work on to bypass this issue.
it is not compelte so I still don't merge it to the master branch but you may try it out (and give me your feedback)
install it like this:
pip install -U git+https://github.com/alpacahq/alpaca-backtrader-api@shared_websocket_streamer
from alpaca-backtrader-api.
Perfect! I'll check it out and let you know!
from alpaca-backtrader-api.
Installing the branch shared_websocket_streamer
worked for me running against the samples, although I'll need to wait for the market to open for a true test.
from alpaca-backtrader-api.
there's a better solution: https://github.com/shlomikushchi/alpaca-proxy-agent
from alpaca-backtrader-api.
Hi, you are running more than one ws connections still. this is the error you get.
I am now making final modifications to this repo to make it compatible with the alpaca-proxy-agent.
you can see the changes here: #109
in this readme there's a section explaining how to use the proxy agent:
https://github.com/alpacahq/alpaca-backtrader-api/blob/make_project_compatible_to_proxy_agent/README.md
also make sure you have the correct branch installed ( not yet released to pypi). you can install it like this:
pip install git+https://github.com/alpacahq/alpaca-backtrader-api@make_project_compatible_to_proxy_agent
from alpaca-backtrader-api.
Sorry, it's my bad, the default IP is not 192.168.99.100. The OS is Ubuntu 16.04.
After connected to the Websocket, it gives the following log:
connected to: ws://172.17.0.2:8765/stream
connected to: ws://172.17.0.2:8765/stream
code = 1000 (OK), no reason
error while consuming ws messages: consume cancelled
It's not in the regular trading hours when I was testing the code, I guess that's probably the reason behind the error. Anyway, thanks for the hint!
from alpaca-backtrader-api.
Hey @shlomikushchi
I fixed it. Wasn't an issue with alpaca-backtrader. Had to add an environment variable to redirect my requests to the proxy agent.
Thanks
from alpaca-backtrader-api.
I'm having the same issue, my strategy uses multiple datas as well. I'm curious on the solution, I assume you can just add another listener to the original connection, this is what I would do using wscat...
from alpaca-backtrader-api.
Hi, I'm wondering why the branch has still not been merged yet? I'm wondering if there are any issues with the branch.
from alpaca-backtrader-api.
Hi @shlomikushchi
I'm trying to solve the problem by using Alpaca-proxy-agent, but I encountered more errors.
error while consuming ws messages: server rejected WebSocket connection: HTTP 503
error while consuming ws messages: Error while connecting to wss://data.alpaca.markets/stream:your connection is rejected while another connection is open under the same account
Could you please take a look when you get a chance? Thanks
To reproduce the aforementioned bugs:
Here're the module versions that I was using
- alpaca-backtrader-api==0.9.5
- Alpaca-proxy-agent is from Docker hub. (docker run -p 8765:8765 -e USE_POLYGON=false shlomik/alpaca-proxy-agent)
The strategies consume multiple tickers datasets.
from alpaca-backtrader-api.
@shlomikushchi Thanks for the quick fix, it seems to be working. A minor issue is that, sometimes, it gives me the following warning:
error while consuming ws messages: [Errno 110] Connect call failed ('192.168.99.100', 8765)
The code doesn't crash though.
from alpaca-backtrader-api.
Hi,
is your docker running in ip 192.168.99.100? what OS are you using?
not being able to connect to your own machine is a bit weird.. it's internal networking
from alpaca-backtrader-api.
I tested it again in the trading hours and still got the error:
connected to: ws://172.17.0.2:8765/stream
code = 1000 (OK), no reason
error while consuming ws messages: consume cancelled
from alpaca-backtrader-api.
Hi
I will be releasing a new version soon.
will let you know so you could test it.
from alpaca-backtrader-api.
I just checked out the latest version of proxy agent 0.50.0. It doesn't work. Got the following error:
error while consuming ws messages: Error while connecting to wss://data.alpaca.markets/stream:your connection is rejected while another connection is open under the same account
error while consuming ws messages: server rejected WebSocket connection: HTTP 503
Edit: sorry, I was using alpaca-backtrader 0.10.1. Never mind, it's a known issue.
from alpaca-backtrader-api.
Hi @shlomikushchi,
I tried connecting to the alpaca proxy agent as in the pictured attached, but for some reason, it does not connect to the agent and is still fetching data. Can you please tell me what is wrong with my implementation?
from alpaca-backtrader-api.
Hi @vanshtuli
What version of alpaca-backtrader-api do you have installed?
from alpaca-backtrader-api.
Hey @shlomikushchi
I'm not sure what I am doing wrong. I have the proxy agent running in docker. I believe I set my environment variable DATA_PROXY_WS=ws://172.17.0.3:8765 but it still connects to:
2021-04-14 14:59:25,972 connected to: wss://paper-api.alpaca.markets/stream
2021-04-14 14:59:26,072 connected to: wss://data.alpaca.markets/stream
I'm on MacOS 10.15.7
alpaca-backtrader-api = 0.13.1
alpaca-trade-api = 0.52.0
-- | -- | --
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.