UNPKG

@master-chief/alpaca-ts

Version:

A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.

176 lines 4.8 kB
/** * Watchlists * Returns the list of watchlists registered under the account. * @returns Watchlist Successful response * @throws ApiError */ export const getWatchlists = (httpRequest) => { return httpRequest.request({ method: "GET", url: "/v2/watchlists", }); }; /** * Watchlist * Create a new watchlist with initial set of assets. * @returns Watchlist Successful response * @throws ApiError */ export const postWatchlist = (httpRequest, { requestBody, }) => { return httpRequest.request({ method: "POST", url: "/v2/watchlists", body: requestBody, mediaType: "application/json", }); }; /** * Get Watchlist by ID * Returns a watchlist identified by the ID. * @returns Watchlist Successful response * @throws ApiError */ export const getWatchlistById = (httpRequest, { watchlistId, }) => { return httpRequest.request({ method: "GET", url: "/v2/watchlists/{watchlist_id}", path: { watchlist_id: watchlistId, }, }); }; /** * Update Watchlist By Id * Update the name and/or content of watchlist * @returns Watchlist Successful response * @throws ApiError */ export const updateWatchlistByI = (httpRequest, { watchlistId, requestBody, }) => { return httpRequest.request({ method: "PUT", url: "/v2/watchlists/{watchlist_id}", path: { watchlist_id: watchlistId, }, body: requestBody, mediaType: "application/json", }); }; /** * Add Asset to Watchlist * Append an asset for the symbol to the end of watchlist asset list * @returns Watchlist Successful response * @throws ApiError */ export const addAssetToWatchlist = (httpRequest, { watchlistId, requestBody, }) => { return httpRequest.request({ method: "POST", url: "/v2/watchlists/{watchlist_id}", path: { watchlist_id: watchlistId, }, body: requestBody, mediaType: "application/json", }); }; /** * Delete Watchlist By Id * Delete a watchlist. This is a permanent deletion. * @returns void * @throws ApiError */ export const deleteWatchlistById = (httpRequest, { watchlistId, }) => { return httpRequest.request({ method: "DELETE", url: "/v2/watchlists/{watchlist_id}", path: { watchlist_id: watchlistId, }, errors: { 404: `Watchlist not found`, }, }); }; /** * Get Watchlist by Name * You can also call GET, PUT, POST and DELETE with watchlist name with another endpoint /v2/watchlists:by_name and query parameter name=<watchlist_name>, instead of /v2/watchlists/{watchlist_id} endpoints * * Returns a watchlist by name * @returns Watchlist Successful response * @throws ApiError */ export const getWatchlistByName = (httpRequest, { name, }) => { return httpRequest.request({ method: "GET", url: "/v2/watchlists:by_name", query: { name: name, }, }); }; /** * Update Watchlist By Name * Update the name and/or content of watchlist * @returns Watchlist Successful response * @throws ApiError */ export const updateWatchlistByName = (httpRequest, { name, requestBody, }) => { return httpRequest.request({ method: "PUT", url: "/v2/watchlists:by_name", query: { name: name, }, body: requestBody, mediaType: "application/json", }); }; /** * Add Asset to Watchlist By Name * Append an asset for the symbol to the end of watchlist asset list * @returns Watchlist Successful response * @throws ApiError */ export const addAssetToWatchlistByName = (httpRequest, { name, requestBody, }) => { return httpRequest.request({ method: "POST", url: "/v2/watchlists:by_name", query: { name: name, }, body: requestBody, mediaType: "application/json", }); }; /** * Delete Watchlist By Name * Delete a watchlist. This is a permanent deletion. * @returns void * @throws ApiError */ export const deleteWatchlistByName = (httpRequest, { name, }) => { return httpRequest.request({ method: "DELETE", url: "/v2/watchlists:by_name", query: { name: name, }, }); }; /** * Symbol from Watchlist * Delete one entry for an asset by symbol name * @returns Watchlist Returns the updated watchlist * @throws ApiError */ export const removeAssetFromWatchlist = (httpRequest, { watchlistId, symbol, }) => { return httpRequest.request({ method: "DELETE", url: "/v2/watchlists/{watchlist_id}/{symbol}", path: { watchlist_id: watchlistId, symbol: symbol, }, }); }; //# sourceMappingURL=watchlists.js.map