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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tushare_simonnode

v0.3.1

Published

port of tushare for nodejs

Downloads

1

Readme

tushare.js

这是tushare的nodejs版,正在开发当中。如果有感兴趣的同学,非常欢迎一起完善该项目。

tushare的数据大多来自于各大网站股票金融频道的数据。本质上是去抓取这些网站的数据,以此方便二次使用。文档目前并不完善,使用方法(接口) 请参考test/目录内的单元测试

使用方法:

npm install tushare --save
npm run build
npm run test

然后:

import { stock } from 'tushare';

stock.getTodayAll().then(({ data }) => {
  console.log(data);
});

交易数据

1. 获取个股历史数据

const options = {
  code: '600848',
  ktype: 'week'
};
stock.getHistory(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
code: {String} 股票代码,6位数字代码
ktype: {String} 数据类型,day=日k线 week=周 month=月 5=5分钟 15=15分钟 30=30分钟 60=60分钟,默认为day
start: {String} 开始日期,格式YYYY-MM-DD
end: {String} 结束日期,格式YYYY-MM-DD
autype: {String} 复权,默认前复权(fq), 不复权(last)
}

2. 获取历史分笔数据

const options = {
  code: '600848',
  date: '2015-12-31'
};
stock.getTick(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
  date: {String} 历史分笔日期,格式YYYY-MM-DD
  code: {String} 股票代码,6位数字代码
}

获取历史K线数据

const options = {
  code: '000001',
  index: true,
  start : '2015-01-01',
  end: '2016-10-22',
  args: '000001'
};
stock.getKData(options).then(data => {
   console.log('code %s',options.code);
   console.log(data);  
  })
  .catch(err => {
    console.error('get %s error %s', options.code, err);
  });

options 参数说明:

{
  start: {string} 起始时间,格式YYYY-MM-DD
  end: {string} 结束时间,格式YYYY-MM-DD
  code: {string} 股票代码
  ktype: {string} K线类型 ('day','week','month','5','10','15','30','60')
  index: {bool}  表示是否是指数,默认是否
}

3. 实时行情

stock.getTodayAll().then(({ data }) => {
  console.log(data);
});

options(可选) 参数说明:

{
  pageSize: 设置单次返回股票的数量,默认10000,即全部股票
  pageNo: 页码,都懂得
}

4. 实时分笔

var options = {
  codes: [
    '600848',
    '600000'
  ]
};
stock.getLiveData(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
  codes: 股票代码数组
}

5. 当日历史分笔

该方法返回指定时间前五分钟的分笔数据,如需获得所有数据,需要多次调用该方法

var options = {
  code: '600848',
  end: '15:00:00'
};
stock.getTodayTick(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
  code: 股票代码,6位数字
  end: 结束时间
}

6. 大盘指数行情数据

stock.getIndex().then(({ data }) => {
  console.log(data);
});

7. 大单交易数据

var options = {
  code: '600848',
  volume: 700
};
stock.getSinaDD(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
  code: 股票代码,6位数字
  volume: (手)默认400,返回大于xx手的大单数据
}

行业分类数据

1. 获取新浪行业分类信息

比如:房地产、电子信息、钢铁行业等等新浪行业分类信息

stock.getSinaIndustryClassified().then(({ data }) => {
  console.log(data);
});

2. 获取新浪某个行业分类的具体信息:所包含的股票及其交易信息

这里的tag是分类行业分类的tag,可以从上一个接口:tushare.stock.getSinaIndustryClassified获得

var options = {
  tag: 'new_jrhy'
};
stock.getSinaClassifyDetails(options).then(({ data }) => {
  console.log(data);
});

options 参数说明:

{
  tag: 新浪行业代码
}

3. 获取新浪概念分类信息

返回数据中的tag可用于上面(#2)的接口,用于获取某个概念分类的具体信息

stock.getSinaConceptsClassified().then(({ data }) => {
  console.log(data);
});

4. 获取所有上市公司股票基本信息

stock.getAllStocks().then(({ data }) => {
  console.log(data);
});

5. 获取沪深300股票信息

stock.getHS300().then(({ data }) => {
  console.log(data);
});

6. 获取上证50股票信息

stock.getSZ50().then(({ data }) => {
  console.log(data);
});

7. 获取指定年月限售解禁股数据

stock.getXSGData().then(({ data }) => {
  console.log(data);
});

龙虎榜

1. 龙虎榜单(来自网易财经)

  var options = {
    start: '2016-01-15',
    end: '2016-01-15',
    pageNo: 1,
    pageSize: 150
  };
  stock.lhb(options).then(({ data }) => {
    console.log(data);
  });

options 参数说明:

{
start: 开始日期
end: 结束日期
pageNo: (optional, default: 1)
pageSize: optional, default: 150)
}

2. 大宗交易(来自网易财经)

  var options = {
    start: '2016-01-15',
    end: '2016-01-15',
    pageNo: 1,
    pageSize: 150
  };
  stock.blockTeade(options).then(({ data }) => {
    console.log(data);
  });

options 参数说明:

{
start: 开始日期
end: 结束日期
pageNo: (optional, default: 1)
pageSize: optional, default: 150)
}