Code Monkey home page Code Monkey logo

Comments (6)

ttt733 avatar ttt733 commented on July 21, 2024

The API URL for a direct connection is the same, just with https:// replaced with wss://. I.e., wss://paper-api.alpaca.markets or wss://api.alpaca.markets. So a connection might look like:

conn = tradeapi.StreamConn(
        'X',
        'X',
        'wss://paper-api.alpaca.markets'
    )

@conn.on(r'trade_updates')
async def on_trade_update(conn, channel, data):
    pass

conn.run(['trade_updates'])

Replace the Xs with your API keys and pass with whatever code you want to handle them. If you have trouble connecting in this way, please reopen the issue and let us know more - copy the full error output if possible.

from alpaca-trade-api-python.

GitHubEmploy avatar GitHubEmploy commented on July 21, 2024

Hello, I tried running this and it started spamming 'ERROR:root:error while consuming ws messages: server rejected WebSocket connection: HTTP 429', and every 3 it said, 'ERROR:root: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'. So now I am trying to figure out how to terminate that connection. This happened when I clicked disconnect instead of terminate.

from alpaca-trade-api-python.

shlomiku avatar shlomiku commented on July 21, 2024

Hi, what do you mean "clicked disconnect" where did you click?
the errors you see caused by the websocket client trying to reconnect to the server

from alpaca-trade-api-python.

GitHubEmploy avatar GitHubEmploy commented on July 21, 2024

Ok, let me explain in more detail. I use a IDE called PyCharm, and when you stop a program in PyCharm you have 2 options. You can either disconnect from the program, or terminate the program. The main difference is disconnection is where it is still running on your computer, but PyCharm is no longer hosting the program, and terminate is where you stop the program.

from alpaca-trade-api-python.

shlomiku avatar shlomiku commented on July 21, 2024

so you need to kill the python process running this code. you can't have more than one connection to the websocket, this is why you get this error.

from alpaca-trade-api-python.

nickvertucci avatar nickvertucci commented on July 21, 2024

@ttt733 Are you able to assist with the momentum template? I just ran into this same error.

from alpaca-trade-api-python.

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.