Code Monkey home page Code Monkey logo

Comments (6)

EricBell271 avatar EricBell271 commented on August 23, 2024 2

Thank you for all your help! The solution was very simple. I realized the curl function did not have to be used with python. Then all I had to do was add the url to the paper trading account.

api = tradeapi.REST('PK53RZXVSO70ZWANC27Q', 'TOCuoIpJdxPCDi1txOStLsxW4DpdBMm4N3kkdAv7' , 'https://paper-api.alpaca.markets')

from alpaca-trade-api-python.

umitanuki avatar umitanuki commented on August 23, 2024 1

Your curl example is pointing to paper-api while your python example is to live trading. You can give https://paper-apip.alpaca.markets/ to the third argument of REST()

from alpaca-trade-api-python.

umitanuki avatar umitanuki commented on August 23, 2024

The code looks fine so it's likely the key you are specifying might be wrong.

You can check the actual HTTP header by adding this before the code.

import logging
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

from alpaca-trade-api-python.

SaviourSelf avatar SaviourSelf commented on August 23, 2024

I'm experiencing a similar issue. Yesterday I was able to generate a key and get this working after trading hours. This morning, I tried using the same key from yesterday and I'm getting:

alpaca_trade_api.rest.APIError: access key verification failed : request is unauthorized (generate APCA-API-KEY-ID and APCA-API-ACCESS-SECRET-KEY from dashboard and include in HTTP header) (Code = 40110000) (Code = 40110000)

I generated a new key, and I was able to get passed this error.

from alpaca-trade-api-python.

EricBell271 avatar EricBell271 commented on August 23, 2024

Still will not work.
I ran this curl function:

curl -X GET -H "APCA-API-KEY-ID: AKYDIJYFTXUS153CS26T" -H "APCA-API-SECRET-KEY: ZGjtbpBRJV8FfayZNXKkACOYR9/ZAmmszD6nBFch" https://paper-api.alpaca.markets/v1/account

This was the response:

image

I then run this in Spyder Python.
import sys
sys.version

import alpaca_trade_api as tradeapi

api = tradeapi.REST('AKYDIJYFTXUS153CS26T', 'ZGjtbpBRJV8FfayZNXKkACOYR9/ZAmmszD6nBFch')
account = api.get_account()
account.status

I tried the debug function.

image

I am not sure what I am missing, but I am missing something.

Do you have any recommendations or anything else I can try?

from alpaca-trade-api-python.

cgi1 avatar cgi1 commented on August 23, 2024

Your curl example is pointing to paper-api while your python example is to live trading. You can give https://paper-apip.alpaca.markets/ to the third argument of REST()

https://paper-api.alpaca.markets/ without typo

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.