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

tdx

v0.1.3

Published

JS version of pytdx

Downloads

3

Readme

tdx js 接口

此接口在node v8.5.0 环境下开发测试

安装

npm install tdx

交易相关 trade 模块

trade 模块需要配合 TdxTradeServer (连接) 使用


const { TradeApi } = require('tdx')
const process = require("process")
const TEST_ENDPOINT = "http://10.11.5.215:10092/api"
const TEST_ENC_KEY  = "4f1cf3fec4c84c84"
const TEST_ENC_IV   = "0c78abc083b011e7"

const api = new TradeApi(TEST_ENDPOINT, "utf-8", null, null)

async function testApis() {

    console.log(await api.ping())

    acc = process.env.TDX_ACCOUNT
    password = process.env.TDX_PASS
    let response
    response = await api.logon("202.108.253.186", 7708,
              "8.23", 32,
              acc, acc, password, "")
    console.log(response)
    // 登入
    const clientId = response["data"]["client_id"]
    console.log(`client id is ${clientId}`)

    // 查询
    for (let i of [0,1,2,3,4,5,6,7,8,12,13,14,15]) {
        console.log(`---查询信息 cate=${i}--`)
        response = await api.queryData(clientId, i)
        console.log(response)
    }

    console.log("---查询报价---")
    console.log(await api.getQuote(clientId, '600315'))

    console.log("---列出所有连接客户端---")
    console.log(await api.getActiveClients())

    // 登出
    response = await(api.logoff(clientId))
    console.log(response)
}

testApis()

接口列表

  • 构造函数 constructor(endpoint, encoding='utf-8', encKey = null, encIv = null)
  • ping ping()
  • 登录 logon(ip, port, version, yybId, accountId, tradeAccount, jyPasswrod, txPassword)
  • 登出 logoff(clientId)
  • 查询信息 queryData(clientId, category)
  • 查询历史信息 queryHistoryData(clientId, category)
  • 下单 sendOrder(clientId, category, priceType, gddm, zqdm, price, quantity)
  • 撤单 cancelOrder(clientId, exchangeId, hth)
  • 行情查询 getQuote(clientId, code)
  • 融资融券账户直接还款 repay(clientId, amount)
  • 批量下单 sendOrders(clientId, orders)
  • 批量撤单 cancelOrders(clientId, orders)
  • 批量查询信息 queryDatas(clientId, categoires)
  • 批量行情查询 getQuotes(clientId, codes)

TODO

  • [ ] 完善行情部分的接口
    • [ ] 标注行情
    • [ ] 扩展行情
  • [ ] Trade部分支持从浏览器直接访问 需要TdxTradeServer增加CORS 支持
  • [ ] 测试集编写