Remove deprecated Alpaca key-pair auth
This commit is contained in:
parent
5025de78b9
commit
07a9b91df7
8 changed files with 16 additions and 55 deletions
|
|
@ -7,8 +7,6 @@ export type AlpacaEquitiesFeed = "iex" | "sip";
|
|||
|
||||
export type AlpacaEquitiesAdapterConfig = {
|
||||
apiKey: string;
|
||||
keyId: string;
|
||||
secretKey: string;
|
||||
restUrl: string;
|
||||
wsBaseUrl: string;
|
||||
feed: AlpacaEquitiesFeed;
|
||||
|
|
@ -65,15 +63,8 @@ const normalizeSymbols = (symbols: string[]): string[] => {
|
|||
};
|
||||
|
||||
const buildHeaders = (config: AlpacaEquitiesAdapterConfig): Record<string, string> => {
|
||||
if (config.apiKey) {
|
||||
return {
|
||||
Authorization: `Bearer ${config.apiKey}`
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
"APCA-API-KEY-ID": config.keyId,
|
||||
"APCA-API-SECRET-KEY": config.secretKey
|
||||
Authorization: `Bearer ${config.apiKey}`
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -193,10 +184,8 @@ export const createAlpacaEquitiesAdapter = (
|
|||
return {
|
||||
name: "alpaca",
|
||||
start: async (handlers: EquityIngestHandlers) => {
|
||||
if (!config.apiKey && (!config.keyId || !config.secretKey)) {
|
||||
throw new Error(
|
||||
"Alpaca equities adapter requires ALPACA_API_KEY or ALPACA_KEY_ID and ALPACA_SECRET_KEY."
|
||||
);
|
||||
if (!config.apiKey) {
|
||||
throw new Error("Alpaca equities adapter requires ALPACA_API_KEY.");
|
||||
}
|
||||
|
||||
const symbols = normalizeSymbols(config.symbols);
|
||||
|
|
@ -218,8 +207,8 @@ export const createAlpacaEquitiesAdapter = (
|
|||
ws.send(
|
||||
JSON.stringify({
|
||||
action: "auth",
|
||||
key: config.apiKey || config.keyId,
|
||||
secret: config.apiKey ? "" : config.secretKey
|
||||
key: config.apiKey,
|
||||
secret: ""
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ const envSchema = z.object({
|
|||
|
||||
// Alpaca (equities)
|
||||
ALPACA_API_KEY: z.string().default(""),
|
||||
ALPACA_KEY_ID: z.string().default(""),
|
||||
ALPACA_SECRET_KEY: z.string().default(""),
|
||||
ALPACA_REST_URL: z.string().default("https://data.alpaca.markets"),
|
||||
ALPACA_WS_BASE_URL: z.string().default("wss://stream.data.alpaca.markets"),
|
||||
ALPACA_UNDERLYINGS: z.string().default("SPY,NVDA,AAPL"),
|
||||
|
|
@ -168,19 +166,13 @@ const selectAdapter = (name: string): EquityIngestAdapter => {
|
|||
}
|
||||
|
||||
if (name === "alpaca") {
|
||||
const hasApiKey = Boolean(env.ALPACA_API_KEY);
|
||||
const hasKeyPair = Boolean(env.ALPACA_KEY_ID && env.ALPACA_SECRET_KEY);
|
||||
if (!hasApiKey && !hasKeyPair) {
|
||||
logger.warn("alpaca credentials missing; set ALPACA_API_KEY or ALPACA_KEY_ID and ALPACA_SECRET_KEY");
|
||||
throw new Error(
|
||||
"ALPACA_API_KEY or ALPACA_KEY_ID and ALPACA_SECRET_KEY are required for the alpaca adapter."
|
||||
);
|
||||
if (!env.ALPACA_API_KEY) {
|
||||
logger.warn("alpaca credentials missing; set ALPACA_API_KEY");
|
||||
throw new Error("ALPACA_API_KEY is required for the alpaca adapter.");
|
||||
}
|
||||
|
||||
return createAlpacaEquitiesAdapter({
|
||||
apiKey: env.ALPACA_API_KEY,
|
||||
keyId: env.ALPACA_KEY_ID,
|
||||
secretKey: env.ALPACA_SECRET_KEY,
|
||||
restUrl: env.ALPACA_REST_URL,
|
||||
wsBaseUrl: env.ALPACA_WS_BASE_URL,
|
||||
feed: env.ALPACA_EQUITIES_FEED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue