-
-
Notifications
You must be signed in to change notification settings - Fork 93
Hello, please tell me, can I get data on currency pairs using my Broker Api or do I necessarily need to create a Trader Api for this?
I'm trying to get data for the next pair, but I get an exception when checking response.isSuccessful(). Could the reason for the exception be the use of the Broker Api?
final BrokerAPIEndpointType endpointType = BrokerAPIEndpointType.SANDBOX; // or 'PRODUCTION'
final AlpacaAPI alpacaAPI = new AlpacaAPI(brokerAPIKey, brokerAPISecret, endpointType);
final ApiClient api = new ApiClient(alpacaAPI.getOkHttpClient());
ForexApi forexApi = new ForexApi(api);
forexApi.latestRates("USDJPY,USDMXN");
All reactions
-
👀 1
Answered by
Petersoj
Aug 3, 2024
A few things:
- Don't construct your own instance of
ApiClientotherwise the Alpaca authorization headers won't be present in requests. All API requests should be made through method calls in theAlpacaAPIinstance and its endpoint methods (e.g.api.trader().accountActivities()...). - The Broker API doesn't have access to the market data endpoints that regular Alpaca users have. You can't use market data endpoints with Broker API keys or with the Connect API unless you have some sort of special agreement set in place with Alpaca.
- The Broker API should be used if you're trying to use Alpaca as a white-label brokerage. If that's the case, you should reach out to their sales staff to discuss pr...
Replies: 1 comment 1 reply
A few things:
- Don't construct your own instance of
ApiClientotherwise the Alpaca authorization headers won't be present in requests. All API requests should be made through method calls in theAlpacaAPIinstance and its endpoint methods (e.g.api.trader().accountActivities()...). - The Broker API doesn't have access to the market data endpoints that regular Alpaca users have. You can't use market data endpoints with Broker API keys or with the Connect API unless you have some sort of special agreement set in place with Alpaca.
- The Broker API should be used if you're trying to use Alpaca as a white-label brokerage. If that's the case, you should reach out to their sales staff to discuss pricing and such before integrating the Broker API into your business/application. You may want to look into the Connect API (OAuth) instead.
- If you want to use Forex data on behalf of your own Alpaca account, your code should look something like this:
final AlpacaAPI alpacaAPI = new AlpacaAPI("<id>", "<secret>", TraderAPIEndpointType.LIVE, MarketDataWebsocketSourceType.IEX); alpacaAPI.marketData().forex().latestRates("EURUSD");
All reactions
-
👍 1
1 reply
Thank you very much, you helped me a lot
All reactions
Answer selected by
Petersoj
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment