Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
add support for custom endpoint urls #105
Browse files Browse the repository at this point in the history
  • Loading branch information
117 committed Jun 10, 2022
1 parent 1dfd3c5 commit bee58a5
Show file tree
Hide file tree
Showing 30 changed files with 19,038 additions and 18,950 deletions.
9 changes: 6 additions & 3 deletions @types/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Account, Order, Position, Asset, Watchlist, Calendar, Clock, AccountConfigurations, PortfolioHistory, Activity, DefaultCredentials, OAuthCredentials, OrderCancelation, PageOfTrades, PageOfQuotes, PageOfBars, Bar_v1, LastQuote_v1, LastTrade_v1, Snapshot, NewsPage, LatestTrade } from './entities.js';
import { Account, Order, Position, Asset, Watchlist, Calendar, Clock, AccountConfigurations, PortfolioHistory, Activity, DefaultCredentials, OAuthCredentials, OrderCancelation, PageOfTrades, PageOfQuotes, PageOfBars, Bar_v1, LastQuote_v1, LastTrade_v1, Snapshot, NewsPage, LatestTrade, Endpoints } from './entities.js';
import { GetOrder, GetOrders, PlaceOrder, ReplaceOrder, CancelOrder, GetPosition, ClosePosition, GetAsset, GetAssets, GetWatchList, CreateWatchList, UpdateWatchList, AddToWatchList, RemoveFromWatchList, DeleteWatchList, GetCalendar, UpdateAccountConfigurations, GetAccountActivities, GetPortfolioHistory, GetBars, GetBars_v1, GetTrades, GetQuotes, GetLastTrade_v1, GetLastQuote_v1, GetSnapshot, GetSnapshots, ClosePositions, GetNews, GetLatestTrade } from './params.js';
export declare class AlpacaClient {
params: {
credentials?: DefaultCredentials | OAuthCredentials;
rate_limit?: boolean;
endpoints?: Endpoints | Map<keyof Endpoints, any>;
credentials?: DefaultCredentials | OAuthCredentials;
};
private baseURLs;
private limiter;
constructor(params: {
credentials?: DefaultCredentials | OAuthCredentials;
rate_limit?: boolean;
endpoints?: Endpoints | Map<keyof Endpoints, any>;
credentials?: DefaultCredentials | OAuthCredentials;
});
isAuthenticated(): Promise<boolean>;
getAccount(): Promise<Account>;
Expand Down
3 changes: 3 additions & 0 deletions @types/endpoints.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Endpoints } from './entities';
declare const endpoints: Endpoints;
export default endpoints;
12 changes: 12 additions & 0 deletions @types/entities.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
export interface Endpoints {
rest: {
beta: 'https://data.alpaca.markets/v1beta1';
account: 'https://api.alpaca.markets/v2';
market_data_v2: 'https://data.alpaca.markets/v2';
market_data_v1: 'https://data.alpaca.markets/v1';
};
websocket: {
account: 'wss://api.alpaca.markets/stream';
market_data: (source: DataSource) => string;
};
}
/**
* Your Alpaca key id and secret.
* Can be passed to the AlpacaClient and AlpacaStream.
Expand Down
2 changes: 1 addition & 1 deletion @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare const _default: {
};
export default _default;
export { Account, Order, OrderCancelation, Position, Asset, Watchlist, Calendar, Clock, DefaultCredentials, OAuthCredentials, AccountConfigurations, NonTradeActivity, TradeActivity, Activity, PortfolioHistory, Bar, Bar_v1, Quote, LastQuote_v1, LastTrade_v1, Trade, PageOfBars, PageOfQuotes, PageOfTrades, Snapshot, DataSource, Channel, Message, } from './entities';
export { GetOrder, GetOrders, PlaceOrder, ReplaceOrder, CancelOrder, GetPosition, ClosePosition, GetAsset, GetAssets, GetWatchList, CreateWatchList, UpdateWatchList, AddToWatchList, RemoveFromWatchList, DeleteWatchList, GetCalendar, UpdateAccountConfigurations, GetAccountActivities, GetPortfolioHistory, GetBars, GetBars_v1, GetTrades, GetQuotes, GetSnapshot, GetSnapshots, GetLastTrade_v1, GetLastQuote_v1, BarsV1Timeframe, BarsTimeframe } from './params';
export { GetOrder, GetOrders, PlaceOrder, ReplaceOrder, CancelOrder, GetPosition, ClosePosition, GetAsset, GetAssets, GetWatchList, CreateWatchList, UpdateWatchList, AddToWatchList, RemoveFromWatchList, DeleteWatchList, GetCalendar, UpdateAccountConfigurations, GetAccountActivities, GetPortfolioHistory, GetBars, GetBars_v1, GetTrades, GetQuotes, GetSnapshot, GetSnapshots, GetLastTrade_v1, GetLastQuote_v1, BarsV1Timeframe, BarsTimeframe, } from './params';
5 changes: 4 additions & 1 deletion @types/stream.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="ws" />
import WebSocket from 'isomorphic-ws';
import EventEmitter from 'eventemitter3';
import { Bar, Channel, DataSource, DefaultCredentials, Quote, Trade, TradeUpdate, Message } from './entities.js';
import { Bar, Channel, DataSource, DefaultCredentials, Quote, Trade, TradeUpdate, Message, Endpoints } from './entities.js';
export declare interface Events {
open: (stream: AlpacaStream) => void;
close: (stream: AlpacaStream) => void;
Expand All @@ -25,14 +25,17 @@ export declare class AlpacaStream extends EventEmitter<string | symbol | any> {
credentials: DefaultCredentials;
type: 'account' | 'market_data';
source?: DataSource;
endpoints?: Endpoints | Map<keyof Endpoints, any>;
};
private host;
private connection;
private authenticated;
private baseURLs;
constructor(params: {
credentials: DefaultCredentials;
type: 'account' | 'market_data';
source?: DataSource;
endpoints?: Endpoints | Map<keyof Endpoints, any>;
});
/**
* Retrieve the underlying WebSocket connection AlpacaStream uses.
Expand Down
14 changes: 0 additions & 14 deletions @types/urls.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. See [standa

### [6.3.19](https://github.com/117/alpaca/compare/v6.3.18...v6.3.19) (2022-06-10)

- Add support for custom endpoint urls (#105)

### [6.3.18](https://github.com/117/alpaca/compare/v6.3.17...v6.3.18) (2022-05-09)

### [6.3.17](https://github.com/117/alpaca/compare/v6.3.16...v6.3.17) (2022-04-06)
Expand Down
Loading

0 comments on commit bee58a5

Please # to comment.