npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trading-simulator

v1.0.0

Published

A simulator for A-share and HK stock trading

Readme

trading-simulator

一个用于模拟 A 股和港股交易环境的 npm 包。

安装

npm install trading-simulator

功能特性

  • 支持 A 股和港股的交易规则模拟
  • 虚拟账户管理系统
  • 限价单和市价单支持
  • 实时行情数据模拟
  • 涨跌幅限制和交易时间检查
  • 持仓管理和盈亏计算

快速开始

const { Account, MarketData, LimitOrder } = require('trading-simulator');

// 初始化账户
const account = new Account({ initialFunds: 100000 });
account.login();

// 获取行情数据
const stockData = MarketData.getAShareData('000001');

// 提交订单
const order = new LimitOrder({
  stockCode: '000001',
  price: stockData.currentPrice,
  quantity: 100,
  type: 'buy'
});
account.submitOrder(order);

// 查看持仓
console.log(account.getPortfolio());

API 文档

账户管理

创建账户

const account = new Account({ initialFunds: 100000 });

登录账户

account.login();

查看账户信息

const info = account.getInfo();
console.log(info);
// {
//   balance: 100000,        // 当前余额
//   initialFunds: 100000,   // 初始资金
//   portfolioValue: 0,      // 持仓价值
//   totalValue: 100000      // 总资产
// }

市场行情

获取 A 股行情

const aShareData = MarketData.getAShareData('000001');

获取港股行情

const hkShareData = MarketData.getHKShareData('00700');

订单操作

提交限价单

const order = new LimitOrder({
  stockCode: '000001',
  price: 10.5,
  quantity: 100,
  type: 'buy'
});
account.submitOrder(order);

提交市价单

const marketOrder = new MarketOrder({
  stockCode: '000001',
  quantity: 100,
  type: 'buy'
});
account.submitOrder(marketOrder);

测试

npm test

许可证

MIT