Comments (6)
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.
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.
If I don't use Polygon or the Alpaca Data API do I need to connect to the Streamer?
from alpaca-backtrader-api.
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.
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.
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)
- 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.