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

node-ctp

v0.1.1

Published

Futures CTP API wraped by node.js

Downloads

4

Readme

node-ctp

高性能期货程序化交易框架

##Why?

Shif发布的CTP接口是基于C++语言开发的,我们使用CTP开发交易策略软件时,一般也使用C++语言。 我本人觉得这样不是很方便,封装成Node.js模块,我考虑基于以下两点:

1. 使用Javascript极大的方便了交易策略的编写。
2. 提供了一个高性能的并发框架,并支持多账户交易。

##Demo

我们可以这样调用CTP接口 行情订阅调用示例


var ctp = require('node-ctp');
ctp.settings({log:true});
var mduser = ctp.createMduser({
    connect() {
        console.log("on connected");
        this.reqUserLogin('', '', '', function(result) {});
    },
    rspUserLogin(requestId, isLast, field, info) {
        console.log("on rspUserLogin", arguments)
        this.subscribeMarketData(['rb1801'], function(result) {
            console.log('subscribeMarketData result:' + result);
        });
    },
    rspSubMarketData(requestId, isLast, field, info) {
        console.log("on rspSubMarketData", arguments)
    },
    rspUnSubMarketData(requestId, isLast, field, info) {
        console.log("on rspUnSubMarketData", arguments)
    },
    rtnDepthMarketData(field) {
        console.log("on rtnDepthMarketData", field);
    },
    rspError(requestId, isLast, info) {
        console.log(requestId, isLast, info)
    }
});

mduser.connect('ctp url', 'conn/tmp', function (result){
    console.log(result);

});

交易接口示例

//confirm

ctp = require('node-ctp');
ctp.settings({ log: true});
var trader = ctp.createTrader({
    connect() {
        console.log("on connected");
        this.reqUserLogin('', '', '', function(result, iRequestID) {
            console.log('login return val is ' + result);
        });
    },
    rspUserLogin(requestId, isLast, field, info) {

        console.log(JSON.stringify(field));
        console.log(info);
        this.reqQrySettlementInfo('', '', '', function(result, iRequestID) {
            console.log('settlementinfo return val is ' + result);

        });
        var tradingDay = this.getTradingDay();
        console.log(tradingDay);
    },
    rspInfoconfirm(requestId, isLast, field, info) {

        console.log()

    },
    rqSettlementInfo(requestId, isLast, field, info) {
        console.log('rqsettlementinfo callback');
        console.log(field);
        console.log(info);

    },
    rtnOrder(field) {
        console.log(field);
    },
    rspError(requestId, isLast, field) {
        console.log(JSON.stringify(field));

    }
});

trader.connect('',undefined,0,1,function(result){
    console.log('connect return val is '+result);
});