Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
基于FutuQuant v3.1.2底层协议封装的nodejs版本接口,数据格式使用protobuf,使用前请先在本地或者服务端启动FutuOpenD服务。
相关说明:
使用了ES6 modules,对应nodejs版本v8.5.0以上,启动时添加参数:--experimental-modules
,参考:v8.5.0 proposal #15308。
最新版本使用了babel编译,可以直接使用require('futuquant')
或者import FtQuant from 'futuquant'
语法。
使用了async/await语法,要求nodejs版本v7.10.1以上,v7.5.1可以使用--harmony
或者--harmony-async-await
参数开启async/await的支持。
底层协议基于FutuQuant v3.1.2,参考:FutunnOpen/futuquant。
数据传输格式只支持protobuf。
为了方便使用,请注意部分接口参数及返回结果和富途官方版本不完全一致,详细请参考API文档。
2017.07.27
更多请点击查看更新日志
npm install futuquant --save
或者
yarn add futuquant
const FtQuant = require('./src/futuquant');
const fs = require('fs');
const bunyan = require('bunyan');
const bunyanDebugStream = require('bunyan-debug-stream');
const path = require('path');
const FILENAME = typeof __filename !== 'undefined' ? __filename : (/^ +at (?:file:\/*(?=\/)|)(.*?):\d+:\d+$/m.exec(Error().stack) || '')[1];
const DIRARR = FILENAME.split('/');
DIRARR.pop();
const DIRNAME = typeof __dirname !== 'undefined' ? __dirname : DIRARR.join('/');
const FutuOpenDXMLPath = path.join(DIRNAME, '../FutuOpenD_1.01_Mac/FutuOpenD.xml');
const ftOpenDConfig = fs.readFileSync(FutuOpenDXMLPath, {
encoding: 'utf8'
});
const userID = ftOpenDConfig.match(/login_account>(\d*?)<\/login_account/)[1];
const pwdMd5 = ftOpenDConfig.match(/trade_pwd_md5>(.*?)<\/trade_pwd_md5/)[1];
// 自定义日志对象
const bunyanLogger = bunyan.createLogger({
name: 'sys',
streams: [{
level: 'debug',
type: 'raw',
serializers: bunyanDebugStream.serializers,
stream: bunyanDebugStream({ forceColor: true }),
}],
});
const ft = new FtQuant({
ip: '127.0.0.1', // FutuOpenD服务IP
port: 11111, // FutuOpenD服务端口
userID, // 牛牛号
}, bunyanLogger);
const init = async () => {
let res = null;
res = await ft.initConnect(); // 初始化连接
console.log('initConnect', res);
res = await ft.getGlobalState(); // 获取全局状态
console.log('getGlobalState', res);
await ft.trdUnlockTrade(true, pwdMd5); // 解锁交易密码
const accID = (await ft.trdGetAccList())[0].accID;
await ft.setCommonTradeHeader(1, accID, 1); // 设置为港股的真实环境
};
init();
请先修改test/futuquant.test.js
中FutuOpenDXMLPath
的路径,然后执行npm install
或yarn
安装相关依赖。
运行测试:
npm test
如有需要,请填写推荐人牛牛号:5894668,谢谢!
FAQs
FutuQuant-Nodejs
The npm package futuquant receives a total of 15 weekly downloads. As such, futuquant popularity was classified as not popular.
We found that futuquant demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.