### Install SDK via NPM Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Use this command to install the SDK package from NPM. ```terminal npm install @alpacahq/typescript-sdk ``` -------------------------------- ### Get Account Information Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the account information. No specific setup or constraints are mentioned. ```typescript client.getAccount().then(console.log); ``` -------------------------------- ### Get All Activities Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all account activities. No parameters are required. ```typescript client.getActivities().then(console.log); ``` -------------------------------- ### Get Account Configurations Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the current account configurations. No parameters are required. ```typescript client.getConfigurations().then(console.log); ``` -------------------------------- ### Get All Watchlists Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all watchlists associated with the account. No parameters are needed. ```typescript client.getWatchlists().then(console.log); ``` -------------------------------- ### Get Crypto Snapshots Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of crypto snapshots. Requires location and symbols. ```typescript client .getCryptoSnapshots({ loc: "US", symbols: "BTCUSD,ETHUSD", }) .then(console.log); ``` -------------------------------- ### Get All Crypto Wallets Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all crypto wallets associated with the account. No parameters are required. ```typescript client.getCryptoWallets().then(console.log); ``` -------------------------------- ### Get All Positions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all current positions held. This provides an overview of the entire portfolio. ```typescript client.getPositions().then(console.log); ``` -------------------------------- ### Get Latest Crypto Orderbooks Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest crypto orderbooks. Requires location and symbols. ```typescript client .getLatestCryptoOrderbooks({ loc: "US", symbols: "BTCUSD,ETHUSD", }) .then(console.log); ``` -------------------------------- ### Get Stocks Snapshots Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a snapshot of current stock data for the specified symbols. This provides a quick overview of market data. ```typescript client .getStocksSnapshots({ symbols: "AAPL,TSLA", }) .then(console.log); ``` -------------------------------- ### Get All Whitelisted Crypto Addresses Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all whitelisted crypto addresses associated with the account. No parameters are required. ```typescript client.getCryptoWhitelistedAddresses().then(console.log); ``` -------------------------------- ### Get Options Snapshots Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a snapshot of current options data for the specified symbols. This provides a quick overview of options market data. ```typescript client .getOptionsSnapshots({ symbols: "AAPL220617C00270000,TSLA220617C01000000", }) .then(console.log); ``` -------------------------------- ### Get Market Calendar Data Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the market calendar for a specified date range. Ensure the client is initialized before use. ```typescript client .getCalendar({ start: "2023-01-01", end: "2023-12-31", }) .then(console.log); ``` -------------------------------- ### Get Portfolio History Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the historical performance of the portfolio. Requires `period` and `timeframe` parameters. ```typescript client .getPortfolioHistory({ period: "1M", timeframe: "1D", }) .then(console.log); ``` -------------------------------- ### Get Crypto Quotes Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of crypto quotes. Specify symbols and an optional limit. ```typescript client .getCryptoQuotes({ symbols: "BTCUSD,ETHUSD", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stock Logo Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the logo for a given stock symbol. The `symbol` parameter is mandatory. ```typescript client .getLogo({ symbol: "AAPL", }) .then(console.log); ``` -------------------------------- ### Get Latest Crypto Quotes Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest crypto quotes. Requires location and symbols. ```typescript client .getCryptoQuotesLatest({ loc: "US", symbols: "BTCUSD,ETHUSD", }) .then(console.log); ``` -------------------------------- ### Get Specific Crypto Wallet Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a specific crypto wallet by asset. The `asset` parameter is required. ```typescript client .getCryptoWallet({ asset: "BTCUSD", }) .then(console.log); ``` -------------------------------- ### Get Current Market Clock Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the current market clock status. No parameters are required. ```typescript client.getClock().then(console.log); ``` -------------------------------- ### Get Crypto Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of crypto trades. Specify location, symbols, and an optional limit. ```typescript client .getCryptoTrades({ loc: "US", symbols: "BTCUSD,ETHUSD", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stocks Quotes Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of stock quotes for specified symbols. A `limit` can be set for the number of results. ```typescript client .getStocksQuotes({ symbols: "AAPL,TSLA", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stocks Auctions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of stock auctions for specified symbols and limit. This data is relevant for pre-market and after-hours trading. ```typescript client .getStocksAuctions({ symbols: "AAPL,TSLA", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stocks Conditions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of stock conditions based on tick type and tape. Ensure `tickType` and `tape` parameters are correctly specified. ```typescript client .getStocksConditions({ tickType: "trades", tape: "xxx", }) .then(console.log); ``` -------------------------------- ### Get List of Options Contracts Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of options contracts based on underlying symbols and expiration dates. `underlying_symbols` and `expiration_date` are required. ```typescript client .getOptionsContracts({ underlying_symbols: "AAPL", expiration_date: "2023-06-16", }) .then(console.log); ``` -------------------------------- ### Get Specific Asset Information Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves details for a specific asset using its symbol or asset ID. The `symbol_or_asset_id` parameter is required. ```typescript client .getAsset({ symbol_or_asset_id: "AAPL", }) .then(console.log); ``` -------------------------------- ### Get Options Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of options trades for specified symbols and limit. This provides historical options trade data. ```typescript client .getOptionsTrades({ symbols: "AAPL220617C00270000,TSLA220617C01000000", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Forex Rates Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of forex rates for specified currency pairs, timeframe, and limit. Ensure `currency_pairs` and `timeframe` are correctly formatted. ```typescript client .getForexRates({ currency_pairs: "EURUSD,GBPUSD", timeframe: "1Min", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stocks Corporate Actions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of corporate actions for specified symbols and types. Ensure symbols and types are correctly provided. ```typescript client .getStocksCorporateActions({ symbols: "AAPL", types: "cash_dividends", }) .then(console.log); ``` -------------------------------- ### Get Stocks Exchange Codes Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all available stock exchange codes. This is useful for filtering or validating exchange information. ```typescript client.getStocksExchangeCodes().then(console.log); ``` -------------------------------- ### Get List of Crypto Transfers Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of crypto transfers, optionally filtered by asset. The `asset` parameter can be used for filtering. ```typescript client .getCryptoTransfers({ asset: "BTCUSD", }) .then(console.log); ``` -------------------------------- ### Get Stocks Most Actives Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of the most active stocks, ordered by volume or another specified metric. The `top` parameter limits the number of results. ```typescript client .getStocksMostActives({ by: "volume", top: 10, }) .then(console.log); ``` -------------------------------- ### Get Specific Options Contract Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves details for a specific options contract using its symbol or contract ID. The `symbol_or_contract_id` parameter is mandatory. ```typescript client .getOptionsContract({ symbol_or_contract_id: "AAPL230616C00150000", }) .then(console.log); ``` -------------------------------- ### Get Latest Forex Rates Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest forex rates for the specified currency pairs. This is useful for real-time exchange rate data. ```typescript client .getLatestForexRates({ currency_pairs: "EURUSD,GBPUSD", }) .then(console.log); ``` -------------------------------- ### Get Options Bars Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves historical options bar data for specified symbols, timeframe, and limit. Ensure `symbols` and `timeframe` are correctly formatted. ```typescript client .getOptionsBars({ symbols: "AAPL220617C00270000,TSLA220617C01000000", timeframe: "1Day", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get List of Orders Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of orders, filterable by status, and with options for limit and direction. Useful for checking open or historical orders. ```typescript client .getOrders({ status: "open", limit: 10, direction: "desc", }) .then(console.log); ``` -------------------------------- ### getConfigurations Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the current account configurations. ```APIDOC ## getConfigurations ### Description Retrieves the account configurations. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/accounts/{account_id}/configurations (assumed) ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account whose configurations are to be retrieved. ### Request Example ```typescript client.getConfigurations().then(console.log); ``` ### Response #### Success Response (200) - **trade_confirm_email** (string) - The trade confirmation email setting. - **no_market_data_subscription** (boolean) - Indicates if market data subscription is disabled. - **suspend_trade** (boolean) - Indicates if trading is suspended for the account. #### Response Example ```json { "trade_confirm_email": "all", "no_market_data_subscription": false, "suspend_trade": false } ``` ``` -------------------------------- ### Get Stocks Bars Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves historical stock bar data for specified symbols, timeframe, and limit. Ensure `timeframe` is correctly formatted (e.g., '1Day'). ```typescript client .getStocksBars({ symbols: "AAPL,TSLA", timeframe: "1Day", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Stocks Market Movers Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of top market movers, sorted by change or another specified metric. The `top` parameter limits the number of results. ```typescript client .getStocksMarketMovers({ by: "change", top: 10, }) .then(console.log); ``` -------------------------------- ### createWatchlist Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Creates a new watchlist with a specified name and a list of symbols. ```APIDOC ## createWatchlist ### Description Creates a new watchlist. ### Method POST (assumed, based on SDK method name) ### Endpoint /watchlists (assumed) ### Parameters #### Request Body - **name** (string) - Required - The name for the new watchlist. - **symbols** (array) - Required - A list of symbols to include in the watchlist. ### Request Example ```typescript client.createWatchlist({ name: "My Watchlist", symbols: ["AAPL", "GOOGL", "AMZN"], }).then(console.log); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the newly created watchlist. - **account_id** (string) - The ID of the account associated with the watchlist. - **name** (string) - The name of the watchlist. - **symbols** (array) - A list of symbols included in the watchlist. - **created_at** (string) - The timestamp when the watchlist was created. - **updated_at** (string) - The timestamp when the watchlist was last updated. #### Response Example ```json { "id": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", "account_id": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "name": "My Watchlist", "symbols": ["AAPL", "GOOGL", "AMZN"], "created_at": "2023-10-26T11:00:00Z", "updated_at": "2023-10-26T11:00:00Z" } ``` ``` -------------------------------- ### Create New Watchlist Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Creates a new watchlist with a given name and a list of symbols. Both `name` and `symbols` are required. ```typescript client .createWatchlist({ name: "My Watchlist", symbols: ["AAPL", "GOOGL", "AMZN"], }) .then(console.log); ``` -------------------------------- ### Import SDK from CDN Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Import the SDK directly from a CDN like Skypack for use in environments that support ESM. ```typescript import { createClient } from "https://cdn.skypack.dev/@alpacahq/typescript-sdk"; ``` -------------------------------- ### Get Latest Crypto Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest crypto trades. Requires location and symbols. ```typescript client .getCryptoTradesLatest({ loc: "US", symbols: "BTCUSD,ETHUSD", }) .then(console.log); ``` -------------------------------- ### Create Alpaca Client Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Instantiate the Alpaca client using your API key and secret. By default, it targets the paper trading environment. You can optionally provide an access token for OAuth. ```typescript import { createClient } from "@alpacahq/typescript-sdk"; const client = createClient({ key: "YOUR_API_KEY_ID", secret: "YOUR_API_SECRET_KEY", // Or, provide an access token if you're using OAuth. // accessToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', }); ``` -------------------------------- ### createOrder Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Creates a new order to buy or sell assets. Supports market, limit, stop, and stop-limit order types. ```APIDOC ## createOrder ### Description Creates a new order. ### Method ```typescript client.createOrder(orderRequest) ``` ### Parameters #### Request Body - **orderRequest** (object) - Required - Details of the order to be created. - **symbol** (string) - Required - The symbol of the asset to trade. - **qty** (number) - Required - The quantity of the asset to trade. - **side** (string) - Required - The side of the order ('buy' or 'sell'). - **type** (string) - Required - The type of the order ('market', 'limit', 'stop', 'stop_limit'). - **time_in_force** (string) - Required - The time in force for the order ('day', 'gtc', 'opg', 'cls', 'ioc', 'fok'). - **limit_price** (number) - Optional - The limit price for limit orders. - **stop_price** (number) - Optional - The stop price for stop or stop-limit orders. ### Request Example ```json { "symbol": "AAPL", "qty": 1, "side": "buy", "type": "market", "time_in_force": "day" } ``` ### Response Example ```json { "example": "order creation response" } ``` ``` -------------------------------- ### getOptionsExchanges Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all supported options exchange codes. ```APIDOC ## getOptionsExchanges ### Description Retrieves a list of options exchanges. ### Method GET ### Endpoint /v1/options/exchanges ### Parameters (No parameters required) ### Request Example ```typescript client.getOptionsExchanges().then(console.log); ``` ### Response #### Success Response (200) - **list** (array) - A list of exchange code objects, each containing `code`, `name`. #### Response Example ```json { "list": [ { "code": "CBOE", "name": "CBOE Exchange" } ] } ``` ``` -------------------------------- ### Configure Rate Limiting Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Customize the SDK's rate limiting behavior by providing a token bucket configuration with capacity and fill rate. This configuration is shared across all requests made by a single client instance. ```typescript tokenBucket: { // Maximum number of tokens that can be stored capacity: 200, // Number of tokens refilled per second fillRate: 60, } ``` -------------------------------- ### Get Specific Watchlist Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a specific watchlist by its unique ID. The `watchlist_id` parameter is mandatory. ```typescript client .getWatchlist({ watchlist_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", }) .then(console.log); ``` -------------------------------- ### Create New Order Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Creates a new order with specified parameters like symbol, quantity, side, type, and time in force. Ensure all required fields are provided. ```typescript client .createOrder({ symbol: "AAPL", qty: 1, side: "buy", type: "market", time_in_force: "day", }) .then(console.log); ``` -------------------------------- ### getOptionsBars Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves historical bar data for options contracts over a specified timeframe. ```APIDOC ## getOptionsBars ### Description Retrieves a list of options bars. ### Method GET ### Endpoint /v1/options/bars ### Parameters #### Query Parameters - **symbols** (string) - Required - Comma-separated list of option symbols (e.g., 'AAPL220617C00270000,TSLA220617C01000000'). - **timeframe** (string) - Required - The timeframe for the bars (e.g., '1Min', '1Hour', '1Day'). - **limit** (integer) - Optional - The maximum number of bars to return. Defaults to 100. - **start_date** (string) - Optional - Start date for the bars (YYYY-MM-DD). - **end_date** (string) - Optional - End date for the bars (YYYY-MM-DD). - **after** (string) - Optional - Timestamp to retrieve bars after. - **before** (string) - Optional - Timestamp to retrieve bars before. ### Request Example ```typescript client.getOptionsBars({ symbols: "AAPL220617C00270000,TSLA220617C01000000", timeframe: "1Day", limit: 10 }).then(console.log); ``` ### Response #### Success Response (200) - **list** (array) - A list of bar objects, each containing `t` (timestamp), `o` (open), `h` (high), `l` (low), `c` (close), `v` (volume), `vw` (volume weighted average price). #### Response Example ```json { "list": [ { "t": 1678886400000, "o": 5.50, "h": 6.00, "l": 5.25, "c": 5.75, "v": 1000, "vw": 5.60 } ] } ``` ``` -------------------------------- ### Get Specific Activity Type Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves activities of a specific type, such as 'FILL'. The `activity_type` parameter is required. ```typescript client .getActivity({ activity_type: "FILL", }) .then(console.log); ``` -------------------------------- ### getActivity Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a specific type of account activity. ```APIDOC ## getActivity ### Description Retrieves a specific activity type. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/accounts/{account_id}/activities/{activity_type} (assumed) ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **activity_type** (string) - Required - The type of activity to retrieve (e.g., 'FILL', 'ORDER', 'PORTFOLIO'). #### Query Parameters - **date** (string) - Optional - The date for which to retrieve activities (YYYY-MM-DD). - **start** (string) - Optional - The start date for the activity range (YYYY-MM-DD). - **end** (string) - Optional - The end date for the activity range (YYYY-MM-DD). - **limit** (integer) - Optional - The maximum number of activities to return. - **page_token** (string) - Optional - Token for retrieving the next page of results. ### Request Example ```typescript client.getActivity({ activity_type: "FILL", }).then(console.log); ``` ### Response #### Success Response (200) - **activities** (array) - A list of activity objects matching the specified type and parameters. #### Response Example ```json { "activities": [ { "id": "activity_id_1", "account_id": "account_id_123", "type": "FILL", "transaction_time": "2023-10-26T14:30:00Z", "price": 150.75, "qty": 10, "leaves_qty": 0, "side": "buy", "symbol": "AAPL", "order_id": "order_id_abc" } ] } ``` ``` -------------------------------- ### Get Latest Stocks Quotes Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest stock quotes for the specified symbols. This is useful for real-time data. ```typescript client .getStocksQuotesLatest({ symbols: "AAPL,TSLA", }) .then(console.log); ``` -------------------------------- ### getFeeEstimate Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the estimated fee for a crypto withdrawal. ```APIDOC ## getFeeEstimate ### Description Retrieves the fee estimate for a crypto withdrawal. ### Method POST (assumed, based on SDK method name) ### Endpoint /v1/crypto/fees/estimate (assumed) ### Parameters #### Request Body - **asset** (string) - Required - The asset symbol for the withdrawal (e.g., 'BTCUSD'). - **from_address** (string) - Required - The address from which the withdrawal is initiated. - **to_address** (string) - Required - The destination address for the withdrawal. - **amount** (string) - Required - The amount of the asset to be withdrawn. ### Request Example ```typescript client.getFeeEstimate({ asset: "BTCUSD", from_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", to_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", amount: "0.1", }).then(console.log); ``` ### Response #### Success Response (200) - **asset** (string) - The asset symbol. - **fee** (string) - The estimated withdrawal fee. #### Response Example ```json { "asset": "BTCUSD", "fee": "0.0001" } ``` ``` -------------------------------- ### getOptionsSnapshots Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a snapshot of the latest options data for specified symbols. ```APIDOC ## getOptionsSnapshots ### Description Retrieves a list of options snapshots. ### Method GET ### Endpoint /v1/options/snapshots ### Parameters #### Query Parameters - **symbols** (string) - Required - Comma-separated list of option symbols (e.g., 'AAPL220617C00270000,TSLA220617C01000000'). ### Request Example ```typescript client.getOptionsSnapshots({ symbols: "AAPL220617C00270000,TSLA220617C01000000" }).then(console.log); ``` ### Response #### Success Response (200) - **list** (array) - A list of snapshot objects, each containing `symbol`, `latest_trade`, `previous_close`, `todays_open`, `todays_high`, `todays_low`, `todays_volume`, `greeks`. #### Response Example ```json { "list": [ { "symbol": "AAPL220617C00270000", "latest_trade": { "price": 5.75, "size": 10, "exchange": "CBOE", "timestamp": 1678886400000 }, "previous_close": 5.50, "todays_open": 5.50, "todays_high": 6.00, "todays_low": 5.25, "todays_volume": 1000, "greeks": { "delta": 0.5, "gamma": 0.1, "theta": -0.05, "vega": 0.02 } } ] } ``` ``` -------------------------------- ### Get Specific Crypto Transfer Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves details for a specific crypto transfer by its ID. The `transfer_id` parameter is required. ```typescript client .getCryptoTransfer({ transfer_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", }) .then(console.log); ``` -------------------------------- ### Get Specific Corporate Action Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves details for a specific corporate action by its ID. The `id` parameter is required. ```typescript client .getCorporateAction({ id: "xxxxxxxx", }) .then(console.log); ``` -------------------------------- ### updateConfigurations Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Updates the account configurations with new settings. ```APIDOC ## updateConfigurations ### Description Updates the account configurations. ### Method PATCH (assumed, based on SDK method name) ### Endpoint /v1/accounts/{account_id}/configurations (assumed) ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account whose configurations are to be updated. #### Request Body - **trade_confirm_email** (string) - Optional - The trade confirmation email setting (e.g., 'all', 'none', ' உட'). - **suspend_trade** (boolean) - Optional - Set to true to suspend trading, false to resume. ### Request Example ```typescript client.updateConfigurations({ trade_confirm_email: "all", suspend_trade: false, }).then(console.log); ``` ### Response #### Success Response (200) - **trade_confirm_email** (string) - The updated trade confirmation email setting. - **no_market_data_subscription** (boolean) - The updated market data subscription setting. - **suspend_trade** (boolean) - The updated trading suspension status. #### Response Example ```json { "trade_confirm_email": "all", "no_market_data_subscription": false, "suspend_trade": false } ``` ``` -------------------------------- ### Get Stocks Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of stock trades for specified symbols and limit. This provides historical trade data. ```typescript client .getStocksTrades({ symbols: "AAPL,TSLA", limit: 10, }) .then(console.log); ``` -------------------------------- ### exerciseOption Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Exercises an options contract. This action is typically taken when an option is in-the-money. ```APIDOC ## exerciseOption ### Description Exercises an options contract. ### Method ```typescript client.exerciseOption(optionRequest) ``` ### Parameters #### Request Body - **optionRequest** (object) - Required - Details for exercising the option. - **symbol_or_contract_id** (string) - Required - The symbol or contract ID of the option to exercise. ### Request Example ```json { "symbol_or_contract_id": "xxxxxxxx" } ``` ### Response Example ```json { "example": "option exercise response" } ``` ``` -------------------------------- ### getOptionsContracts Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of options contracts based on specified parameters like underlying symbol and expiration date. ```APIDOC ## getOptionsContracts ### Description Retrieves a list of options contracts based on the specified parameters. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/options/contracts (assumed) ### Parameters #### Query Parameters - **underlying_symbols** (string or array) - Required - The symbol(s) of the underlying asset(s). - **expiration_date** (string) - Optional - Filters contracts by expiration date (YYYY-MM-DD). - **strike_price** (number) - Optional - Filters contracts by strike price. - **strike_price_lt** (number) - Optional - Filters contracts with strike price less than. - **strike_price_lte** (number) - Optional - Filters contracts with strike price less than or equal to. - **strike_price_gt** (number) - Optional - Filters contracts with strike price greater than. - **strike_price_gte** (number) - Optional - Filters contracts with strike price greater than or equal to. - **type** (string) - Optional - Filters by option type ('call' or 'put'). - **limit** (integer) - Optional - The maximum number of contracts to return. - **page_token** (string) - Optional - Token for retrieving the next page of results. ### Request Example ```typescript client.getOptionsContracts({ underlying_symbols: "AAPL", expiration_date: "2023-06-16", }).then(console.log); ``` ### Response #### Success Response (200) - **contracts** (array) - A list of options contract objects matching the query parameters. #### Response Example ```json { "contracts": [ { "contract_id": "AAPL230616C00150000", "symbol": "AAPL230616C00150000", "underlying_symbol": "AAPL", "expiration_date": "2023-06-16", "strike_price": 150.00, "type": "call", "last_trade": { "price": 2.50, "size": 10, "time": "2023-06-15T15:45:00Z" }, "open_interest": 500 } ], "next_page_token": "some_token" } ``` ``` -------------------------------- ### Get Options Exchanges Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all available options exchange codes. This is useful for filtering or validating options exchange information. ```typescript client.getOptionsExchanges().then(console.log); ``` -------------------------------- ### getPositions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all current positions. This provides an overview of all assets currently held in the portfolio. ```APIDOC ## getPositions ### Description Retrieves all positions. ### Method ```typescript client.getPositions() ``` ### Response Example ```json { "example": "list of all positions response" } ``` ``` -------------------------------- ### Get Latest Stocks Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest stock trades for the specified symbols. This is useful for real-time trade execution data. ```typescript client .getStocksTradesLatest({ symbols: "AAPL,TSLA", }) .then(console.log); ``` -------------------------------- ### Close All Positions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Closes all currently open positions. Use with caution as this will liquidate the entire portfolio. ```typescript client.closePositions().then(console.log); ``` -------------------------------- ### getCryptoWallet Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves details for a specific crypto wallet by asset. ```APIDOC ## getCryptoWallet ### Description Retrieves a specific crypto wallet by asset. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/crypto/wallets/{asset} (assumed) ### Parameters #### Path Parameters - **asset** (string) - Required - The asset symbol for the wallet (e.g., 'BTCUSD'). ### Request Example ```typescript client.getCryptoWallet({ asset: "BTCUSD", }).then(console.log); ``` ### Response #### Success Response (200) - **asset** (string) - The asset symbol. - **balance** (string) - The current balance of the asset. - **available_balance** (string) - The available balance for trading or withdrawal. #### Response Example ```json { "asset": "BTCUSD", "balance": "0.5", "available_balance": "0.45" } ``` ``` -------------------------------- ### getActivities Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves all types of account activities within a specified date range. ```APIDOC ## getActivities ### Description Retrieves all activities. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/accounts/{account_id}/activities (assumed) ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Query Parameters - **date** (string) - Optional - The date for which to retrieve activities (YYYY-MM-DD). - **start** (string) - Optional - The start date for the activity range (YYYY-MM-DD). - **end** (string) - Optional - The end date for the activity range (YYYY-MM-DD). - **activity_type** (string) - Optional - Filters activities by type (e.g., 'FILL', 'ORDER'). - **limit** (integer) - Optional - The maximum number of activities to return. - **page_token** (string) - Optional - Token for retrieving the next page of results. ### Request Example ```typescript client.getActivities().then(console.log); ``` ### Response #### Success Response (200) - **activities** (array) - A list of all account activity objects. #### Response Example ```json { "activities": [ { "id": "activity_id_1", "account_id": "account_id_123", "type": "FILL", "transaction_time": "2023-10-26T14:30:00Z", "price": 150.75, "qty": 10, "leaves_qty": 0, "side": "buy", "symbol": "AAPL", "order_id": "order_id_abc" }, { "id": "activity_id_2", "account_id": "account_id_123", "type": "ORDER", "order_id": "order_id_def", "symbol": "GOOGL", "side": "sell", "qty": 5, "time_in_force": "gtc" } ] } ``` ``` -------------------------------- ### getForexRates Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves historical bar data for forex currency pairs over a specified timeframe. ```APIDOC ## getForexRates ### Description Retrieves a list of forex rates. ### Method GET ### Endpoint /v1/forex/rates ### Parameters #### Query Parameters - **currency_pairs** (string) - Required - Comma-separated list of currency pairs (e.g., 'EURUSD,GBPUSD'). - **timeframe** (string) - Required - The timeframe for the rates (e.g., '1Min', '1Hour', '1Day'). - **limit** (integer) - Optional - The maximum number of rates to return. Defaults to 100. - **start_date** (string) - Optional - Start date for the rates (YYYY-MM-DD). - **end_date** (string) - Optional - End date for the rates (YYYY-MM-DD). - **after** (string) - Optional - Timestamp to retrieve rates after. - **before** (string) - Optional - Timestamp to retrieve rates before. ### Request Example ```typescript client.getForexRates({ currency_pairs: "EURUSD,GBPUSD", timeframe: "1Min", limit: 10 }).then(console.log); ``` ### Response #### Success Response (200) - **list** (array) - A list of rate objects, each containing `t` (timestamp), `o` (open), `h` (high), `l` (low), `c` (close), `v` (volume), `vw` (volume weighted average price). #### Response Example ```json { "list": [ { "t": 1678886400000, "o": 1.0850, "h": 1.0860, "l": 1.0845, "c": 1.0855, "v": 100000, "vw": 1.0852 } ] } ``` ``` -------------------------------- ### Get Latest News Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest news articles for specified stock symbols. A `limit` can be set to control the number of results. ```typescript client .getNews({ symbols: "AAPL,TSLA", limit: 10, }) .then(console.log); ``` -------------------------------- ### Get Specific Whitelisted Crypto Address Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a specific whitelisted crypto address for a given asset. Requires `address` and `asset`. ```typescript client .getCryptoWhitelistedAddress({ address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", asset: "BTCUSD", }) .then(console.log); ``` -------------------------------- ### getCryptoWallets Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all crypto wallets associated with the account. ```APIDOC ## getCryptoWallets ### Description Retrieves all crypto wallets. ### Method GET (assumed, based on SDK method name) ### Endpoint /v1/crypto/wallets (assumed) ### Parameters None ### Request Example ```typescript client.getCryptoWallets().then(console.log); ``` ### Response #### Success Response (200) - **wallets** (array) - A list of crypto wallet objects. #### Response Example ```json { "wallets": [ { "asset": "BTCUSD", "balance": "0.5", "available_balance": "0.45" }, { "asset": "ETHUSD", "balance": "2.0", "available_balance": "1.9" } ] } ``` ``` -------------------------------- ### getLogo Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the logo for a specific stock symbol. ```APIDOC ## getLogo ### Description Retrieves the logo for a specific symbol. ### Method GET ### Endpoint /v1/reference/logos/{symbol} ### Parameters #### Path Parameters - **symbol** (string) - Required - The stock symbol for which to retrieve the logo. ### Request Example ```typescript client.getLogo({ symbol: "AAPL" }).then(console.log); ``` ### Response #### Success Response (200) - **url** (string) - The URL of the stock logo. #### Response Example ```json { "url": "https://example.com/logos/aapl.png" } ``` ``` -------------------------------- ### Get Crypto Withdrawal Fee Estimate Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the estimated fee for a crypto withdrawal. Requires `asset`, `from_address`, `to_address`, and `amount`. ```typescript client .getFeeEstimate({ asset: "BTCUSD", from_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", to_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", amount: "0.1", }) .then(console.log); ``` -------------------------------- ### getAsset Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves detailed information about a specific asset using its symbol or asset ID. ```APIDOC ## getAsset ### Description Retrieves a specific asset by symbol or asset ID. ### Method GET (assumed, based on SDK method name) ### Endpoint /assets/{symbol_or_asset_id} (assumed) ### Parameters #### Path Parameters - **symbol_or_asset_id** (string) - Required - The symbol or asset ID of the asset to retrieve. ### Request Example ```typescript client.getAsset({ symbol_or_asset_id: "AAPL", }).then(console.log); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the asset. - **symbol** (string) - The trading symbol for the asset. - **name** (string) - The full name of the asset. - **asset_class** (string) - The class of the asset (e.g., 'us_equity'). - **exchange** (string) - The primary exchange where the asset is traded. - **readable_status** (string) - A human-readable status of the asset. - **tradable** (boolean) - Indicates if the asset is currently tradable. - **marginable** (boolean) - Indicates if the asset is marginable. - **shortable** (boolean) - Indicates if the asset is shortable. - **fractionable** (boolean) - Indicates if the asset supports fractional trading. #### Response Example ```json { "id": "a123e456-e89b-12d3-a456-426614174000", "symbol": "AAPL", "name": "Apple Inc.", "asset_class": "us_equity", "exchange": "NASDAQ", "readable_status": "active", "tradable": true, "marginable": true, "shortable": true, "fractionable": true } ``` ``` -------------------------------- ### closePositions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Closes all open positions. This is a comprehensive action to liquidate the entire portfolio. ```APIDOC ## closePositions ### Description Closes all positions. ### Method ```typescript client.closePositions() ``` ### Response Example ```json { "example": "bulk position closing response" } ``` ``` -------------------------------- ### Get List of Corporate Actions Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of corporate actions filtered by type and date range. `ca_types`, `since`, and `until` are required. ```typescript client .getCorporateActions({ ca_types: "MERGER", since: "2023-01-01", until: "2023-12-31", }) .then(console.log); ``` -------------------------------- ### Create New Crypto Withdrawal Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Creates a new crypto withdrawal. Requires `amount`, `address`, and `asset`. ```typescript client .createCryptoTransfer({ amount: "0.1", address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", asset: "BTCUSD", }) .then(console.log); ``` -------------------------------- ### Update Account Configurations Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Updates account configurations, such as trade confirmation emails and trade suspension settings. Parameters `trade_confirm_email` and `suspend_trade` are optional. ```typescript client .updateConfigurations({ trade_confirm_email: "all", suspend_trade: false, }) .then(console.log); ``` -------------------------------- ### Get Specific Order by ID Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a specific order using its unique order ID. The order ID must be valid. ```typescript client .getOrder({ order_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }) .then(console.log); ``` -------------------------------- ### Request Crypto Whitelisted Address Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Use this to request a new whitelisted crypto address. Ensure the address and asset parameters are correctly formatted. ```typescript client .requestCryptoWhitelistedAddress({ address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", asset: "BTCUSD", }) .then(console.log); ``` -------------------------------- ### Get Latest Options Trades Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest options trades for the specified symbols. This is useful for real-time options trade execution data. ```typescript client .getOptionsTradesLatest({ symbols: "AAPL220617C00270000,TSLA220617C01000000", }) .then(console.log); ``` -------------------------------- ### getWatchlists Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves a list of all watchlists associated with the account. ```APIDOC ## getWatchlists ### Description Retrieves all watchlists. ### Method GET (assumed, based on SDK method name) ### Endpoint /watchlists (assumed) ### Parameters None ### Request Example ```typescript client.getWatchlists().then(console.log); ``` ### Response #### Success Response (200) - **watchlists** (array) - A list of watchlist objects. #### Response Example ```json { "watchlists": [ { "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "account_id": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "name": "My Favorite Stocks", "symbols": ["AAPL", "GOOGL"], "created_at": "2023-10-26T10:00:00Z", "updated_at": "2023-10-26T10:00:00Z" } ] } ``` ``` -------------------------------- ### Get Latest Stocks Bars Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest stock bar data for the specified symbols. This is useful for obtaining the most recent OHLC data. ```typescript client .getStocksBarsLatest({ symbols: "AAPL,TSLA", }) .then(console.log); ``` -------------------------------- ### getAccount Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the account information. This is useful for checking account status, buying power, and other relevant details. ```APIDOC ## getAccount ### Description Retrieves the account information. ### Method ```typescript client.getAccount() ``` ### Response Example ```json { "example": "account information response" } ``` ``` -------------------------------- ### getLatestForexRates Source: https://github.com/alpacahq/typescript-sdk/blob/main/README.md Retrieves the latest forex rates for specified currency pairs. ```APIDOC ## getLatestForexRates ### Description Retrieves the latest forex rates. ### Method GET ### Endpoint /v1/forex/rates/latest ### Parameters #### Query Parameters - **currency_pairs** (string) - Required - Comma-separated list of currency pairs (e.g., 'EURUSD,GBPUSD'). ### Request Example ```typescript client.getLatestForexRates({ currency_pairs: "EURUSD,GBPUSD" }).then(console.log); ``` ### Response #### Success Response (200) - **list** (array) - A list of the latest rate objects, each containing `symbol`, `price`, `change`, `change_percent`, `volume`, `timestamp`, etc. #### Response Example ```json { "list": [ { "symbol": "EURUSD", "price": 1.0855, "change": 0.0005, "change_percent": "0.05%", "volume": 100000, "timestamp": 1678886400000 } ] } ``` ```