@flexemarkets/fm-sdk

中文文档
0.22.0发布于 2026/11/15MITTypeScriptES Module构建来源已验证近 30 天下载 3131

弹性市场类型SDK

中文使用文档
文档目录8 节
  1. QQ Alpha 软件——API不稳定
  2. 所需资源
  3. 安装
  4. 配置
  5. 证书文件
  6. 端点文件
  7. SDK 使用情况
  8. 示例:计数器

fm- sdk 类型标记

类型脚本 / JavaScript SDK 弹性市场 API (英语).

QQ Alpha 软件——API不稳定

fm-sdk为前1.0并处于积极开发阶段. 任何公众可能 在任何版本中添加、更名或删除,包括以打破方式 编译和运行到今天的代码,并且首先没有折旧期. 下 语义版本 (单位:千美元) 0.x 释放 没有兼容承诺,这些版本就是这样使用的: 处理每个 0.x 撞到可能断裂.

定出一个准确的版本而不是一个范围( N)"@flexemarkets/fm-sdk": "0.2.0", (中文(简体) ), 没有 ^0.2.0,阅读 升级注释 联 合 国 释放您正在移动,并期望您移动时更改代码 .

未建议用于生产.

所需资源

  • 节点.js 22+(ES模块)

安装

npm install @flexemarkets/fm-sdk

配置

SDK从这些来源装入证书和终点(最优先的第一):

  1. 传递到 Flexemarkets.connect()
  2. 文件 ~/.fm/credential 财务报告和审定财务报表 ~/.fm/endpoint (贾瓦语) .properties 格式)
  3. 环境变量 FM_API_URL (违约) https://api.flexemarkets.com(中文(简体) )

证书文件

创建 ~/.fm/credential数字 :

account=myaccount
[email protected]
password=secret

或用无记名符:

token=eyJhbGciOiJIUzI1NiJ9...

端点文件

创建 ~/.fm/endpoint数字 :

endpoint=https://api.flexemarkets.com/api/marketplaces/123

SDK 使用情况

import { Flexemarkets } from "@flexemarkets/fm-sdk";

// connect(null, null, ...) falls back to ~/.fm/credential and ~/.fm/endpoint
const fm = await Flexemarkets.connect(null, null, "my-bot");

// REST API
const marketplaceId = fm.endpointMarketplaceId;
const markets = await fm.markets(marketplaceId);
const session = await fm.session(marketplaceId);
const holding = await fm.holding(marketplaceId);

// Submit orders
const order = await fm.submitLimit(marketplaceId, markets[0].id, "BUY", 1, 950);
await fm.submitCancel(marketplaceId, markets[0].id, order.id);

// Live market data. A desk keeps the books and tapes for you: it seeds them
// over REST, applies deltas, and re-seeds after a sequence gap.
const desk = await fm.desk(marketplaceId);
const marketId = markets[0].id;

desk.onBookChange(marketId, (book) => console.log(book.bestPrice("BUY")));
desk.onSessionChange((s) => console.log(s.state));
desk.onHoldingChange((h) => console.log(h.cash));

const one = desk.book(marketId);          // one market
for (const book of desk.books()) {        // every market in the marketplace
  console.log(book.symbol, book.bestPrice("BUY"));
}

desk.close();

示例:计数器

SDK 包含一个勾选例——最能显示订单的活终端 投标/任务、传播和最近的贸易价格.

npx tsx src/ticker.ts -C ~/.fm/credential -E 123

选项 :

旗帜说明
-C, (中文(简体) ), --credential证书文件路径或无记名符号
-E, (中文(简体) ), --endpoint地址、端点文件路径或 URL

输出 :

fm-ticker                                              OPEN

  Symbol     Bid     Ask  Spread   Last trades
  ------  ------  ------  ------   -----------
    AAPL    9.50   10.50    1.00   9.50  10.00
     IBM    4.00    5.00    1.00   4.50

显示会在每个订单簿更新中刷新. 新闻 Ctrl-C 停下来.

版本与发布记录

@flexemarkets/fm-sdk 共发布 42 个版本,首次发布于 2026/02/21;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.22.0latest2026/11/15今天
0.21.02026/11/105 天前
0.20.02026/11/087 天前
0.19.02026/11/078 天前
0.18.02026/11/0510 天前
0.17.02026/10/3017 天前

关于 @flexemarkets/fm-sdk 的常见问题

@flexemarkets/fm-sdk 是什么?

弹性市场类型SDK

如何安装 @flexemarkets/fm-sdk?

在项目目录运行 npm install @flexemarkets/fm-sdk,或使用 pnpm add / yarn add / bun add。

@flexemarkets/fm-sdk 支持 TypeScript 吗?

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

@flexemarkets/fm-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flexemarkets/fm-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@flexemarkets/fm-sdk 可以商用吗?

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

@flexemarkets/fm-sdk 的下载量有多少?

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

@flexemarkets/fm-sdk 还在维护吗?

最新版本 0.22.0 发布于 2026/11/15(今天);至今共发布 42 个版本,其中过去 12 个月发布了 42 个;首次发布于 2026/02/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。