Socket
Socket
Sign inDemoInstall

datafeed-server

Package Overview
Dependencies
94
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    datafeed-server

tradingview datafeed server


Version published
Weekly downloads
13
Maintainers
1
Created
Weekly downloads
 

Readme

Source

datafeed-server

tradingview data server

安装

npm install datafeed-server

启动

import { DatafeedApp, IDatafeeder } from 'datafeed-server';

(async function bootstrap() {
  const datafeeder: IDatafeeder = {
    getServerTime: () => {
      return 'get test time';
    },
    resolveSymbol: () => {
      return Promise.resolve(undefined);
    },
    getHistory: () => {
      return Promise.resolve(undefined);
    },
    searchSymbols: () => {
      return Promise.resolve(undefined);
    },
  };
  const app = new DatafeedApp({
    port: 3000,
    datafeeder,
  });
  await app.start();
})();

rest-api 请求功能

  import { RequestParams, Requester } from 'datafeed-server';

  const getHuobiHistory = async () => {
    const apiUrl = 'https://api.huobipro.com';


    const requestParams: RequestParams = {
      symbol: 'btcusdt',
      period: '1day',
      size: 200
    };

    const requester = new Requester();
    const res = await requester.send(apiUrl, '/market/history/kline', requestParams);
    console.log(res);
  };

自定义接口功能

import { DatafeedApp, IDatafeeder } from 'datafeed-server';

(async function bootstrap() {
  const datafeeder: IDatafeeder = {
    custom: async (json: string) => {
      console.log('custom, json:', JSON.parse(json));
    },
    ...
  };
  const app = new DatafeedApp({
    port: 3000,
    datafeeder,
  });
  await app.start();
})();
```

请求例: http://127.0.0.1:3000/custom?json={"a":1,"b":"sss"}
控制台输出:custom, json: { a: 1, b: 'sss' }

FAQs

Last updated on 10 Dec 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc