# @alpacahq/typescript-sdk 中文文档

规范地址：https://npmcn.com/package/%40alpacahq/typescript-sdk/

版本：0\.0\.32-preview
npm 元数据更新时间：2025-08-13T23:02:04.759Z
中文译文更新时间：2026-11-05T23:03:18.984Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40alpacahq/typescript-sdk
原文对照：https://npmcn.com/package/%40alpacahq/typescript-sdk/?lang=original
项目主页：https://github.com/@alpacahq/typescript-sdk#readme
源码仓库：https://github.com/%40alpacahq/typescript-sdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：119 kB，24 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2024-03-30T00:08:24.665Z
- 最新版本发布：2025-08-13T23:02:04.544Z
- 近 30 天下载量：10013（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：21（近 12 个月 0 个）

## 中文简介

类型脚本 SDK [https://alpaca.markets 互联网档案馆的存檔,存档日期2013-12-02](https://alpaca.markets/) REST API和WebSocket流.

## 安装

```sh
npm install @alpacahq/typescript-sdk
```

也可以使用：`pnpm add @alpacahq/typescript-sdk`、`yarn add @alpacahq/typescript-sdk`、`bun add @alpacahq/typescript-sdk`

## README

> 这个SDK不再被开发,也不再由阿尔帕卡维护.
> 
> 请看 [阿尔帕卡- 贸易- api- js](https://github.com/alpacahq/alpaca-trade-api-js/) 我们的官方JavaScript/TypesCript客户端 SDK.

# 类型标记- sdk

![version](https://img.shields.io/badge/dynamic/json?label=version&query=$%5B0%5D.name&url=https://api.github.com/repos/alpacahq/typescript-sdk/tags&style=flat&color=FF33A0) ![code](https://img.shields.io/github/languages/code-size/alpacahq/typescript-sdk?style=flat&color=196DFF&label=code) ![test](https://img.shields.io/github/actions/workflow/status/alpacahq/typescript-sdk/deno_test.yml?style=flat&label=test) ![coverage](https://img.shields.io/github/actions/workflow/status/alpacahq/typescript-sdk/deno_test_coverage.yml?style=flat&label=coverage) ![build](https://img.shields.io/github/actions/workflow/status/alpacahq/typescript-sdk/deno_deploy.yml?style=flat&label=deploy)

类型脚本 SDK [https://alpaca.markets 互联网档案馆的存檔,存档日期2013-12-02](https://alpaca.markets/) REST API和WebSocket流.

-   [特征](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-features)
-   [安装](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-install)
-   [使用量](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getting-started)
    -   [创建客户端](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-create-a-client)
    -   [配置](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-configuration)
        -   [环境变量](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-environment-variables)
        -   [限制费率](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-rate-limiting)
    -   [方法](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-methods)
        -   [贸易 API](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-trading-api)
        -   [市场数据 API](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-market-data-api)
    -   [网络安全套](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-websocket)
        -   [如何运作](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-how-it-works)
        -   [频道](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-channels)
        -   [实例](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-examples)
            -   [订阅](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-subscribe)
            -   [取消订阅](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-unsubscribe)
            -   [处理信件](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-handle-messages)
-   [需要帮忙吗?](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-need-help)

## 特征

-   [x] (原始内容存档于2013-10-12) (英语). REST API
-   [x] WebSocket 流线
-   [x] 内建利率限制( Token Bucket)
-   [x] 类型脚本
-   [x] 德诺
-   [x] 节点 (ESM)
-   [x] \> 35%测试覆盖率(并不断增长)
-   [x] 可动摇的树
-   [x] 无害环境管理和CJS支助
-   [x] 零依赖 QQ( 您读取此右侧)
-   [x] 社区驱动 QQ

自由贡献和公关 对于你的QQ的内容.

## 安装

国家预防机制:

```terminal
npm install @alpacahq/typescript-sdk
```

来自Skypack(或任何支持无害环境管理的CDN):

```ts
import { createClient } from "https://cdn.skypack.dev/@alpacahq/typescript-sdk";
```

## 使用量

### 创建客户端

首先,你需要在阿尔帕卡网站创建API密钥. 你可以这么做 [这里](https://app.alpaca.markets/)。一旦您有 API 密钥,您就可以使用它创建客户端.

```ts
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',
});
```

默认情况下,客户会向纸张交易环境提出请求(`https://paper-api.alpaca.markets`) (中文(简体) ). 这是防止意外交易的安全措施.

### 配置

#### 环境变量

您可以设置以下环境变量来配置客户端 :

-   `APCA_KEY_ID`您的 API 密钥 .
-   `APCA_KEY_SECRET`:你的API秘密.
-   `APCA_ACCESS_TOKEN`: 您的访问符( 如果使用 OAuth ) .
-   `APCA_DEBUG`: 启用调试日志 .

如果这些值被设定,客户端会自动使用. 他们不会推翻明确发给他的任何全权证书 `createClient`。 。 。 .

#### 限制费率

您可以自定义通过通过 `tokenBucket` 对象 `createClient` 函数。 此对象应当包含 `capacity` 财务报告和审定财务报表 `fillRate` 为限速器.

```ts
tokenBucket: {
  // Maximum number of tokens that can be stored
  capacity: 200,
  // Number of tokens refilled per second
  fillRate: 60,
}
```

Bursting是允许的,但如果信使桶是空的,客户端会屏蔽请求. 所有请求都共享标志桶。 如果你有多个客户,他们不会共享同一个桶.

### 方法

#### 贸易 API

-   [`getAccount`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getaccount)
-   [`createOrder`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-createorder)
-   [`getOrder`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getorder)
-   [`getOrders`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getorders)
-   [`replaceOrder`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-replaceorder)
-   [`cancelOrder`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-cancelorder)
-   [`cancelOrders`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-cancelorders)
-   [`getPosition`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getposition)
-   [`getPositions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getpositions)
-   [`closePosition`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-closeposition)
-   [`closePositions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-closepositions)
-   [`exerciseOption`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-exerciseoption)
-   [`getCalendar`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcalendar)
-   [`getClock`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getclock)
-   [`getAsset`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getasset)
-   [`getAssets`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getassets)
-   [`getWatchlist`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getwatchlist)
-   [`getWatchlists`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getwatchlists)
-   [`createWatchlist`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-createwatchlist)
-   [`updateWatchlist`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-updatewatchlist)
-   [`deleteWatchlist`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-deletewatchlist)
-   [`getPortfolioHistory`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getportfoliohistory)
-   [`getConfigurations`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getconfigurations)
-   [`updateConfigurations`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-updateconfigurations)
-   [`getActivity`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getactivity)
-   [`getActivities`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getactivities)
-   [`getOptionsContract`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionscontract)
-   [`getOptionsContracts`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionscontracts)
-   [`getCorporateAction`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcorporateaction)
-   [`getCorporateActions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcorporateactions)
-   [`getCryptoWallet`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptowallet)
-   [`getCryptoWallets`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptowallets)
-   [`getFeeEstimate`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getfeeestimate)
-   [`getCryptoTransfer`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptotransfer)
-   [`getCryptoTransfers`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptotransfers)
-   [`createCryptoTransfer`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-createcryptotransfer)
-   [`getCryptoWhitelistedAddress`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptowhitelistedaddress)
-   [`getCryptoWhitelistedAddresses`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptowhitelistedaddresses)
-   [`requestCryptoWhitelistedAddress`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-requestcryptowhitelistedaddress)
-   [`removeCryptoWhitelistedAddress`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-removecryptowhitelistedaddress)

#### 市场数据 API

-   [`getStocksCorporateActions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstockscorporateactions)
-   [`getLogo`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getlogo)
-   [`getNews`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getnews)
-   [`getStocksMostActives`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksmostactives)
-   [`getStocksMarketMovers`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksmarketmovers)
-   [`getStocksQuotes`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksquotes)
-   [`getStocksQuotesLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksquoteslatest)
-   [`getStocksBars`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksbars)
-   [`getStocksBarsLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksbarslatest)
-   [`getForexRates`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getforexrates)
-   [`getLatestForexRates`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getlatestforexrates)
-   [`getStocksSnapshots`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstockssnapshots)
-   [`getStocksAuctions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksauctions)
-   [`getStocksConditions`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksconditions)
-   [`getStocksExchangeCodes`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstocksexchangecodes)
-   [`getStocksTrades`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstockstrades)
-   [`getStocksTradesLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getstockstradeslatest)
-   [`getOptionsBars`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionsbars)
-   [`getOptionsExchanges`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionsexchanges)
-   [`getOptionsSnapshots`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionssnapshots)
-   [`getOptionsTrades`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionstrades)
-   [`getOptionsTradesLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getoptionstradeslatest)
-   [`getCryptoBars`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptobars)
-   [`getLatestCryptoBars`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getlatestcryptobars)
-   [`getCryptoQuotes`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptoquotes)
-   [`getCryptoQuotesLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptoquoteslatest)
-   [`getCryptoSnapshots`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptosnapshots)
-   [`getCryptoTrades`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptotrades)
-   [`getCryptoTradesLatest`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getcryptotradeslatest)
-   [`getLatestCryptoOrderbooks`](https://npmcn.com/package/%40alpacahq/typescript-sdk/#readme-getlatestcryptoorderbooks)

#### `getAccount`

获取账户信息.

```typescript
client.getAccount().then(console.log);
```

#### `createOrder`

创建新顺序.

```typescript
client
  .createOrder({
    symbol: "AAPL",
    qty: 1,
    side: "buy",
    type: "market",
    time_in_force: "day",
  })
  .then(console.log);
```

#### `getOrder`

使用其身份证获取特定命令.

```typescript
client
  .getOrder({ order_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" })
  .then(console.log);
```

#### `getOrders`

根据指定的参数检索命令列表.

```typescript
client
  .getOrders({
    status: "open",
    limit: 10,
    direction: "desc",
  })
  .then(console.log);
```

#### `replaceOrder`

以更新参数替换已存在的顺序.

```typescript
client
  .replaceOrder({
    qty: 2,
    limit_price: 150.0,
    order_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `cancelOrder`

以其ID取消特定命令.

```typescript
client
  .cancelOrder({ order_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" })
  .then(console.log);
```

#### `cancelOrders`

取消所有开放命令.

```typescript
client.cancelOrders().then(console.log);
```

#### `getPosition`

通过符号或资产ID获取特定位置.

```typescript
client
  .getPosition({
    symbol_or_asset_id: "AAPL",
  })
  .then(console.log);
```

#### `getPositions`

收回所有位置.

```typescript
client.getPositions().then(console.log);
```

#### `closePosition`

通过符号或资产ID关闭特定位置.

```typescript
client
  .closePosition({
    symbol_or_asset_id: "AAPL",
  })
  .then(console.log);
```

#### `closePositions`

关闭所有位置.

```typescript
client.closePositions().then(console.log);
```

#### `exerciseOption`

行使期权合同.

```typescript
client
  .exerciseOption({
    symbol_or_contract_id: "xxxxxxxx",
  })
  .then(console.log);
```

#### `getCalendar`

取出市历.

```typescript
client
  .getCalendar({
    start: "2023-01-01",
    end: "2023-12-31",
  })
  .then(console.log);
```

#### `getClock`

检索当前市场时钟.

```typescript
client.getClock().then(console.log);
```

#### `getAsset`

以符号或资产身份获取特定资产.

```typescript
client
  .getAsset({
    symbol_or_asset_id: "AAPL",
  })
  .then(console.log);
```

#### `getAssets`

根据指定的参数获取资产列表.

```typescript
client
  .getAssets({
    status: "active",
    asset_class: "us_equity",
  })
  .then(console.log);
```

#### `getWatchlist`

使用ID获取特定的监视列表.

```typescript
client
  .getWatchlist({
    watchlist_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `getWatchlists`

取出一切观相.

```typescript
client.getWatchlists().then(console.log);
```

#### `createWatchlist`

创建新的监视列表.

```typescript
client
  .createWatchlist({
    name: "My Watchlist",
    symbols: ["AAPL", "GOOGL", "AMZN"],
  })
  .then(console.log);
```

#### `updateWatchlist`

更新已有的监视列表.

```typescript
client
  .updateWatchlist({
    name: "Updated Watchlist",
    symbols: ["AAPL", "GOOGL", "MSFT"],
    watchlist_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `deleteWatchlist`

用 ID 删除特定的监视列表.

```typescript
client
  .deleteWatchlist({
    watchlist_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `getPortfolioHistory`

检索组合历史.

```typescript
client
  .getPortfolioHistory({
    period: "1M",
    timeframe: "1D",
  })
  .then(console.log);
```

#### `getConfigurations`

获取账户配置.

```typescript
client.getConfigurations().then(console.log);
```

#### `updateConfigurations`

更新账户配置.

```typescript
client
  .updateConfigurations({
    trade_confirm_email: "all",
    suspend_trade: false,
  })
  .then(console.log);
```

#### `getActivity`

获取特定的活动类型.

```typescript
client
  .getActivity({
    activity_type: "FILL",
  })
  .then(console.log);
```

#### `getActivities`

收回一切活动.

```typescript
client.getActivities().then(console.log);
```

#### `getOptionsContract`

以符号或合同ID获取特定期权合同.

```typescript
client
  .getOptionsContract({
    symbol_or_contract_id: "AAPL230616C00150000",
  })
  .then(console.log);
```

#### `getOptionsContracts`

根据指定的参数检索期权合同清单.

```typescript
client
  .getOptionsContracts({
    underlying_symbols: "AAPL",
    expiration_date: "2023-06-16",
  })
  .then(console.log);
```

#### `getCorporateAction`

通过身份证获取公司的具体行动.

```typescript
client
  .getCorporateAction({
    id: "xxxxxxxx",
  })
  .then(console.log);
```

#### `getCorporateActions`

根据指定的参数检索公司行动清单.

```typescript
client
  .getCorporateActions({
    ca_types: "MERGER",
    since: "2023-01-01",
    until: "2023-12-31",
  })
  .then(console.log);
```

#### `getCryptoWallet`

按资产获取特定的加密钱包 .

```typescript
client
  .getCryptoWallet({
    asset: "BTCUSD",
  })
  .then(console.log);
```

#### `getCryptoWallets`

获取所有加密钱包 .

```typescript
client.getCryptoWallets().then(console.log);
```

#### `getFeeEstimate`

获取解密费估计数.

```typescript
client
  .getFeeEstimate({
    asset: "BTCUSD",
    from_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    to_address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    amount: "0.1",
  })
  .then(console.log);
```

#### `getCryptoTransfer`

通过ID获取一个特定的加密传输.

```typescript
client
  .getCryptoTransfer({
    transfer_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `getCryptoTransfers`

根据指定的参数获取加密传输列表.

```typescript
client
  .getCryptoTransfers({
    asset: "BTCUSD",
  })
  .then(console.log);
```

#### `createCryptoTransfer`

创建新的加密退出.

```typescript
client
  .createCryptoTransfer({
    amount: "0.1",
    address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    asset: "BTCUSD",
  })
  .then(console.log);
```

#### `getCryptoWhitelistedAddress`

获取特定的白名单加密地址.

```typescript
client
  .getCryptoWhitelistedAddress({
    address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    asset: "BTCUSD",
  })
  .then(console.log);
```

#### `getCryptoWhitelistedAddresses`

获取所有白名单加密地址 .

```typescript
client.getCryptoWhitelistedAddresses().then(console.log);
```

#### `requestCryptoWhitelistedAddress`

请求一个新的白名单加密地址 .

```typescript
client
  .requestCryptoWhitelistedAddress({
    address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    asset: "BTCUSD",
  })
  .then(console.log);
```

#### `removeCryptoWhitelistedAddress`

删除一个特定的白名单加密地址.

```typescript
client
  .removeCryptoWhitelistedAddress({
    whitelisted_address_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  })
  .then(console.log);
```

#### `getStocksCorporateActions`

根据指定的参数检索公司行动清单.

```typescript
client
  .getStocksCorporateActions({
    symbols: "AAPL",
    types: "cash_dividends",
  })
  .then(console.log);
```

#### `getLogo`

获取特定符号的标志.

```typescript
client
  .getLogo({
    symbol: "AAPL",
  })
  .then(console.log);
```

#### `getNews`

检索最新消息.

```typescript
client
  .getNews({
    symbols: "AAPL,TSLA",
    limit: 10,
  })
  .then(console.log);
```

#### `getStocksMostActives`

检索出最活跃种群列表.

```typescript
client
  .getStocksMostActives({
    by: "volume",
    top: 10,
  })
  .then(console.log);
```

#### `getStocksMarketMovers`

检索上市动车组名单.

```typescript
client
  .getStocksMarketMovers({
    by: "change",
    top: 10,
  })
  .then(console.log);
```

#### `getStocksQuotes`

取取所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出所出.

```typescript
client
  .getStocksQuotes({
    symbols: "AAPL,TSLA",
    limit: 10,
  })
  .then(console.log);
```

#### `getStocksQuotesLatest`

检索最新股票引用.

```typescript
client
  .getStocksQuotesLatest({
    symbols: "AAPL,TSLA",
  })
  .then(console.log);
```

#### `getStocksBars`

检索股道列表.

```typescript
client
  .getStocksBars({
    symbols: "AAPL,TSLA",
    timeframe: "1Day",
    limit: 10,
  })
  .then(console.log);
```

#### `getStocksBarsLatest`

获取最新的股票栏.

```typescript
client
  .getStocksBarsLatest({
    symbols: "AAPL,TSLA",
  })
  .then(console.log);
```

#### `getForexRates`

获取福克斯费率列表 .

```typescript
client
  .getForexRates({
    currency_pairs: "EURUSD,GBPUSD",
    timeframe: "1Min",
    limit: 10,
  })
  .then(console.log);
```

#### `getLatestForexRates`

获取最新的福克斯率.

```typescript
client
  .getLatestForexRates({
    currency_pairs: "EURUSD,GBPUSD",
  })
  .then(console.log);
```

#### `getStocksSnapshots`

检索股票快照列表.

```typescript
client
  .getStocksSnapshots({
    symbols: "AAPL,TSLA",
  })
  .then(console.log);
```

#### `getStocksAuctions`

检索股票拍卖清单.

```typescript
client
  .getStocksAuctions({
    symbols: "AAPL,TSLA",
    limit: 10,
  })
  .then(console.log);
```

#### `getStocksConditions`

检索库存条件清单.

```typescript
client
  .getStocksConditions({
    tickType: "trades",
    tape: "xxx",
  })
  .then(console.log);
```

#### `getStocksExchangeCodes`

检索证券交易所代码列表.

```typescript
client.getStocksExchangeCodes().then(console.log);
```

#### `getStocksTrades`

检索股票交易清单.

```typescript
client
  .getStocksTrades({
    symbols: "AAPL,TSLA",
    limit: 10,
  })
  .then(console.log);
```

#### `getStocksTradesLatest`

收回最新股票交易.

```typescript
client
  .getStocksTradesLatest({
    symbols: "AAPL,TSLA",
  })
  .then(console.log);
```

#### `getOptionsBars`

获取选项栏列表.

```typescript
client
  .getOptionsBars({
    symbols: "AAPL220617C00270000,TSLA220617C01000000",
    timeframe: "1Day",
    limit: 10,
  })
  .then(console.log);
```

#### `getOptionsExchanges`

获取选项交换列表.

```typescript
client.getOptionsExchanges().then(console.log);
```

#### `getOptionsSnapshots`

获取选项快照列表 .

```typescript
client
  .getOptionsSnapshots({
    symbols: "AAPL220617C00270000,TSLA220617C01000000",
  })
  .then(console.log);
```

#### `getOptionsTrades`

获取选项交易列表 .

```typescript
client
  .getOptionsTrades({
    symbols: "AAPL220617C00270000,TSLA220617C01000000",
    limit: 10,
  })
  .then(console.log);
```

#### `getOptionsTradesLatest`

获取最新选项交易.

```typescript
client
  .getOptionsTradesLatest({
    symbols: "AAPL220617C00270000,TSLA220617C01000000",
  })
  .then(console.log);
```

#### `getCryptoBars`

检索密码条列表.

```typescript
client
  .getCryptoBars({
    symbols: "BTCUSD,ETHUSD",
    timeframe: "1Min",
    limit: 10,
  })
  .then(console.log);
```

#### `getLatestCryptoBars`

获取最新的密码条 .

```typescript
client
  .getLatestCryptoBars({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
  })
  .then(console.log);
```

#### `getCryptoQuotes`

检索密码引用列表.

```typescript
client
  .getCryptoQuotes({
    symbols: "BTCUSD,ETHUSD",
    limit: 10,
  })
  .then(console.log);
```

#### `getCryptoQuotesLatest`

获取最新的密码引用 .

```typescript
client
  .getCryptoQuotesLatest({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
  })
  .then(console.log);
```

#### `getCryptoSnapshots`

获取密码快照列表 .

```typescript
client
  .getCryptoSnapshots({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
  })
  .then(console.log);
```

#### `getCryptoTrades`

检索密码交易列表.

```typescript
client
  .getCryptoTrades({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
    limit: 10,
  })
  .then(console.log);
```

#### `getCryptoTradesLatest`

获取最新的密码交易.

```typescript
client
  .getCryptoTradesLatest({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
  })
  .then(console.log);
```

#### `getLatestCryptoOrderbooks`

获取最新的密码命令簿.

```typescript
client
  .getLatestCryptoOrderbooks({
    loc: "US",
    symbols: "BTCUSD,ETHUSD",
  })
  .then(console.log);
```

### 网络安全套

#### 如何运作

待办事宜

#### 频道

待办事宜

#### 实例

待办事宜

## 需要帮忙吗?

该项目的主要维护者是 [@ 117 (韩语)](https://github.com/117)自由接触 [偷懒](https://alpaca-community.slack.com/join/shared_invite/zt-2ebgo7i1f-HbNoBjPWZ_bX72IVQTkcwg) {\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080}或者通过打开这个回放的话题 我很乐意帮你处理任何问题.

## 常见问题

### @alpacahq/typescript-sdk 是什么？

类型脚本 SDK https://alpaca\.markets 互联网档案馆的存檔,存档日期2013-12-02 REST API和WebSocket流\.

### 如何安装 @alpacahq/typescript-sdk？

在项目目录运行 npm install @alpacahq/typescript-sdk，或使用 pnpm add / yarn add / bun add。

### @alpacahq/typescript-sdk 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @alpacahq/typescript-sdk 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @alpacahq/typescript-sdk 可以商用吗？

@alpacahq/typescript-sdk 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @alpacahq/typescript-sdk 的下载量有多少？

根据 npm 官方下载统计，@alpacahq/typescript-sdk 在 2026/10/06 – 2026/11/04 这 30 天内被下载 10,013 次，日均约 334 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @alpacahq/typescript-sdk 还在维护吗？

最新版本 0\.0\.32-preview 发布于 2025/08/14（1\.2 年前）；至今共发布 21 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/03/30。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

