Skip to content
/ bfldb Public

Wrapper around Binance's Futures Leaderboard API, in Go.

License

Notifications You must be signed in to change notification settings

rtunazzz/bfldb

Repository files navigation

bfldb GoDoc

BFLDB is a wrapper around Binance's Futures Leaderboard API, in Golang.

This library provides a convenient way to access Binance's futures leaderboard API, which allows you to subscribe to positions opened by leading futures traders (that are sharing their positions publicly via Binance) and query other leaderboard data. Keep in mind that this is not a publicly documented API.

Installation

go get -u github.com/rtunazzz/bfldb

Example usage

Subscribe to a trader's positions
package main

import (
	"context"
	"fmt"

	"github.com/rtunazzz/bfldb"
)

func main() {
	// You can find this UID (encryptedUid) in the end of a leaderboard profile URL. 
	// For example: https://www.binance.com/en/futures-activity/leaderboard/user?encryptedUid=47E6D002EBB1173967A6561F72B9395C
	u := bfldb.NewUser("47E6D002EBB1173967A6561F72B9395C")
	cp, ce := u.SubscribePositions(context.Background())

	for {
		select {
		case position := <-cp:
			// Handle the new position as you need... Send a notification, copytrade...
			fmt.Printf("new position: %+v\n", position)
		case err := <-ce:
			fmt.Println("error has occured:", err)
			break
		}
	}
}

For more examples, check out the examples/ directory.