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

@bitfirer/trading-view-datafeeds

v0.0.1

Published

适用于 tradingview JS Api 的 datafeeds

Downloads

6

Readme

@bitfirer/trading-view-datafeeds

适用于 tradingview JS Api 的 datafeeds

更新日志

v.0.0.1-beta0.2

  1. Datafeeds新增了vyRefreshSymbolInfo方法,用于刷新币种信息
  2. 处理空数据异常

v.0.0.1-beta0.1

Datafeeds新增了vySetWidget方法,用于存储widget

一、使用

  1. 引入:import { Datafeeds, TradingConfig } from "path/to/TVDatafeeds.min.js";
  2. 实例化
new Datafeed({
  wsUrl: "", // ws 地址
  symbolInfo, // 即 symbolInfo
  tradingConfig, // 见下文
  reconnectCallback: Function // 重连后回调函数,参数:symbol(当前商品), interval(当前粒度)。在这里根据参数,重新初始化图表
})

symbolInfo

  1. TradingConfig({intervalMap, configurationData}) 自定义图表配置

二、方法

  • vyUnsubLastSymbol 取消订阅上一币种;
  • vyGetInterval 获取当前粒度;

三、说明

支持:

  • 断线重连;
  • 按需请求历史数据;

四、demo

<template>
  <div class="home">
    <select v-model="selectValue">
      <option value="BTC/USDT">BTC/USDT</option>
      <option value="BCH/USDT">BCH/USDT</option>
      <option value="ETH/USDT">ETH/USDT</option>
    </select>
    <button @click="getValue">切换币种</button>
    <div id="container" class="container"></div>
  </div>
</template>

<script>
import { Datafeeds, TradingConfig } from "../../dist/TVDatafeeds.min.js";
const tradingConfig = new TradingConfig({
  intervalMap: {
    1: "m1",
    5: "m5",
    15: "m15",
    30: "m30",
    60: "h1",
    120: "h2",
    D: "d1",
    "2D": "d2",
    "1W": "w1",
    "6M": "m6"
  },
  configurationData: {
    supported_resolutions: [1, 5, 15, 30, 60, 120, "D", "2D", "1W", "6M"]
  }
});

const symbolInfo = {
  minmov: 1,
  pricescale: 100,
  description: "这是商品说明",
  type: "bitcoin",
  session: "24x7",
  ticker: "",
  timezone: "Asia/Shanghai",
  has_intraday: true
};

export default {
  name: "Home",
  data() {
    return {
      widget: null,
      selectValue: "BTC/USDT",
      datafeed: null
    };
  },
  methods: {
    initConfig() {
      this.datafeed = new Datafeeds({
        wsUrl: "wss://ws.bingoex.pro/cfdMarket",
        symbolInfo,
        tradingConfig,
        reconnectCallback: this.reconnectCallback
      });
    },
    getValue() {
      this.datafeed.vyUnsubLastSymbol();
      this.widget.setSymbol(
        this.selectValue,
        this.datafeed.vyGetInterval(),
        () => {}
      );
    },
    reconnectCallback(symbol, interval) {
      this.initTradingView(symbol, interval);
    },
    initTradingView(symbolName = "BTC/USDT", interval = 5) {
      // eslint-disable-next-line new-cap
      this.widget = new window.TradingView.widget({
        symbol: symbolName,
        interval,
        container_id: "container",
        timezone: "Asia/Shanghai",
        locale: "zh",
        library_path: "/lib/charting_library/",
        datafeed: this.datafeed,
        autosize: true
        // debug: true
      });
      this.datafeed.vySetWidget(this.widget);
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initConfig();
      this.initTradingView();
      // window.addEventListener(
      //   "DOMContentLoaded",
      //   () => ,
      //   false
      // );
    });
  }
};
</script>

<style lang="less" scoped>
.container {
  margin: 0 auto;
  margin-top: 50px;
  width: 1200px;
  height: 600px;
  background-color: #f1f1f1;
}
</style>