Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/KenmyZhang/okex-websocket

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/KenmyZhang/okex-websocket

  • v0.0.0-20211030182629-8d203ef168c5
  • Source
  • Go
  • Socket score

Version published
Created
Source

eqs

eqs是一个包括火币(Huobipro),币安(Binance),,Ok(Okex)等在内的各头部交易所的实时行情爬虫,使用websocket对接,实时获取最新行情


安装

go get okex-websocket

火币

获取行情数据
package main

import (
	"fmt"
	"okex-websocket/eqsModels"
	"okex-websocket/exchange/huobipro"
)

func main() {
	symbol := eqsModels.EqsSymbol{
		Base:  "BTC",
		Quote: "USDT",
		Sep:   "/",
	}

	// 使用默认host, 需要科学上网
	//huobiproConn := huobipro.NewDefauldHuobiproWsConn(symbol, "001")

	huobiproConn := huobipro.NewHuobiproWsConnWithHost("wss", "api.huobi.me", symbol, "001")

	go huobiproConn.StartMarketDetail()

	// 获取行情数据
	go func() {
		for {
			outData := <-huobiproConn.OutChan
			data := outData.(huobipro.HuobiproMarketDetail)
			fmt.Printf("%+v\n", data)
		}
	}()

	// 获取报错信息
	go func() {
		for {
			fmt.Println(<-huobiproConn.ErrChan)
		}
	}()

	select {}
}

Okex

获取市场成交
package main

import (
	"fmt"
	"okex-websocket/eqsModels"
	"okex-websocket/exchange/okex"
)

func main() {
	symbol := eqsModels.EqsSymbol{
		Base:  "BTC",
		Quote: "USDT",
		Sep:   "/",
	}

	okexConn := Okex.NewOkexWsConnWithHost("wss","real.okex.com:8443", symbol)
	go okexConn.StartSpotTrade()

	// 获取行情数据
	go func() {
		for {
			outData := <-okexConn.OutChan
			data := outData.(Okex.OkexSpotTrade)
			fmt.Printf("%+v\n", data)
		}
	}()

	// 获取报错信息
	go func() {
		for {
			fmt.Println(<-okexConn.ErrChan)
		}
	}()

	select {}
}

币安

获取市场逐笔成交
package main

import (
	"fmt"
	"okex-websocket/eqsModels"
	"okex-websocket/exchange/binance"
)

func main() {
	symbol := eqsModels.EqsSymbol{
		Base:  "BTC",
		Quote: "USDT",
		Sep:   "/",
	}

	binanceConn := binance.NewDefauldBinanceWsConn(symbol)
	go binanceConn.StartTrade()

	// 获取行情数据
	go func() {
		for {
			outData := <-binanceConn.OutChan
			data := outData.(binance.BinanceTrade)
			fmt.Printf("%+v\n", data)
		}
	}()

	// 获取报错信息
	go func() {
		for {
			fmt.Println(<-binanceConn.ErrChan)
		}
	}()

	select {}
}

FAQs

Package last updated on 30 Oct 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc