Giter VIP home page Giter VIP logo

Comments (6)

shlomiku avatar shlomiku commented on July 28, 2024 1

Hi,
it should work. inside AlpacaStore (line 234) we do this

self.oapi = API(self.p.key_id,
                self.p.secret_key,
                self.p.base_url,
                self.p.api_version)

check if your Oauth works by adding that

from alpaca-backtrader-api.

ronnyli avatar ronnyli commented on July 28, 2024
Exception in thread Thread-7:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\hocke\leverhead\alpaca_backtrader_api\alpacastore.py", line 336, in _t_streaming_events
    streamer = Streamer(q,
  File "C:\Users\hocke\leverhead\alpaca_backtrader_api\alpacastore.py", line 107, in __init__
    self.conn = tradeapi.StreamConn(api_key,
  File "c:\users\hocke\venv\leverheads\lib\site-packages\alpaca_trade_api\stream2.py", line 184, in __init__
    _key_id, _secret_key, _ = get_credentials(key_id, secret_key)
  File "c:\users\hocke\venv\leverheads\lib\site-packages\alpaca_trade_api\common.py", line 24, in get_credentials
    raise ValueError('Secret key must be given to access Alpaca trade API'
ValueError: Secret key must be given to access Alpaca trade API (env: APCA_API_SECRET_KEY

Looks like the issue is with Streamer but unfortunately the StreamConn in alpaca-trade-api doesn't accept oauth parameter

from alpaca-backtrader-api.

ronnyli avatar ronnyli commented on July 28, 2024

If I don't use Polygon or the Alpaca Data API do I need to connect to the Streamer?

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024

not sure I understand. you want to use a different source but connect it to the alpaca broker?
alpacabroker (the module) is dependent on the alpacastore module. so you cannot create one without the other
about support in streamconn, you should open a feature request in the https://github.com/alpacahq/alpaca-trade-api-python repo

from alpaca-backtrader-api.

ronnyli avatar ronnyli commented on July 28, 2024

Sorry about not being clear. Basically, I'm not sure what the purpose of the Streamer is and I'm wondering if I can safely ignore it when authenticating with Oauth. I plan to use AlpacaBroker and AlpacaStore for executing trades but I don't need AlpacaData since I have my own data feed.

Given that I don't intend to use AlpacaData, can I add an if statement here to prevent instantiating Streamer if I don't provide an api_key and api_secret?

EDIT: Also, what happens if I provide my actual API key and secret key but use someone else's OAuth access token?

from alpaca-backtrader-api.

shlomiku avatar shlomiku commented on July 28, 2024

adding that if statement is not possible in the main repo. you could have a fork and do it there though
the reason is that it is a patch for something it was not designed for, doing something like that could cause bugs in the future (just an example - someone forgets to add credentials and the streamer doesn't start and no exception happens.. he will not know why nothing works)

adding your credentials is never a good practice... so don't do that (you may get unexpected results.. if not now, maybe in a future commit)
currently what happens is that the AlpacaBroker gets the REST interface from the AlpacaStore so if you initialize it there correctly it should probably work (but again, it's not a good practice so operate with caution)

now... we have 2 streamers. one for prices, one for events. prices stream is not relevant for you since you use a different feed. the events are broker events.. so I'm guessing you probably need that

in any case - do these actions only with paper trading and see if you get your desired results.
also, please update it here so others may get that information

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.