Giter VIP home page Giter VIP logo

Comments (18)

shlomiku avatar shlomiku commented on July 28, 2024 2

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.

JustinGuese avatar JustinGuese commented on July 28, 2024 1

Perfect! I'll check it out and let you know!

from alpaca-backtrader-api.

dileshan avatar dileshan commented on July 28, 2024 1

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.

shlomiku avatar shlomiku commented on July 28, 2024 1

there's a better solution: https://github.com/shlomikushchi/alpaca-proxy-agent

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024 1

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.

dsqx71 avatar dsqx71 commented on July 28, 2024 1

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.

vanshtuli avatar vanshtuli commented on July 28, 2024 1

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.

dileshan avatar dileshan commented on July 28, 2024

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.

dsqx71 avatar dsqx71 commented on July 28, 2024

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.

dsqx71 avatar dsqx71 commented on July 28, 2024

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.

dsqx71 avatar dsqx71 commented on July 28, 2024

@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.

shlomiku avatar shlomiku commented on July 28, 2024

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.

dsqx71 avatar dsqx71 commented on July 28, 2024

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.

shlomiku avatar shlomiku commented on July 28, 2024

Hi
I will be releasing a new version soon.
will let you know so you could test it.

from alpaca-backtrader-api.

dsqx71 avatar dsqx71 commented on July 28, 2024

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.

vanshtuli avatar vanshtuli commented on July 28, 2024

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?

image

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024

Hi @vanshtuli
What version of alpaca-backtrader-api do you have installed?

from alpaca-backtrader-api.

StefanMarchand avatar StefanMarchand commented on July 28, 2024

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)

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.