Categorygithub.com/rluisr/go-bitflyer
modulepackage
1.1.2
Repository: https://github.com/rluisr/go-bitflyer.git
Documentation: pkg.go.dev

# README

go-bitflyer

License: MIT GoDoc

Bitflyer exchange API version1, renew at 2023/02.

Description

go-bitflyer is a go client library for Bitflyer lightning API.

Supported

  • All Public API
  • All Private API
  • GUI's Hidden API
  • Websocket

Usage

ClientFunctions
PublicStatus(&Request{}) (res, apiLimit, err)
PublicHelth(&Request{}) (res, apiLimit, err)
PublicTicker(&Request{}) (res, apiLimit, err)
PublicMarket(&Request{}) (res, apiLimit, err)
PublicBoard(&Request{}) (res, apiLimit, err)
PublicExecutions(&Request{}) (res, apiLimit, err)
PublicChat(&Request{}) (res, apiLimit, err)
PrivatePermissions(&Request{}) (res, apiLimit, err)
PrivateBalance(&Request{}) (res, apiLimit, err)
PrivateCollateral(&Request{}) (res, apiLimit, err)
PrivateCollateralAccounts(&Request{}) (res, apiLimit, err)
PrivateAddresses(&Request{}) (res, apiLimit, err)
PrivateCoinins(&Request{}) (res, apiLimit, err)
PrivateCoinouts(&Request{}) (res, apiLimit, err)
PrivateBanks(&Request{}) (res, apiLimit, err)
PrivateDeposits(&Request{}) (res, apiLimit, err)
PrivateWithdrawals(&Request{}) (res, apiLimit, err)
PrivateChildOrder(&Request{}) (res, apiLimit, err)
PrivateCancelChildOrder(&Request{}) (res, apiLimit, err)
PrivateParentOrder(&Request{}) (res, apiLimit, err)
PrivateCancelParentOrder(&Request{}) (res, apiLimit, err)
PrivateCancel(&Request{}) (res, apiLimit, err)
PrivateChildOrders(&Request{}) (res, apiLimit, err)
PrivateDetailParentOrder(&Request{}) (res, apiLimit, err)
PrivateMyExecutions(&Request{}) (res, apiLimit, err)
PrivateBalanceHistory(&Request{}) (res, apiLimit, err)
PrivatePositions(&Request{}) (res, apiLimit, err)
PrivateCollateralHistory(&Request{}) (res, apiLimit, err)
PrivateCommission(&Request{}) (res, apiLimit, err)
HiddenOHLCv(&Request{}) (res, err)
HiddenRanking(&Request{}) (res, err)
RealtimeConnect(&auth, []string{"channels"...}, []string{"product_codes..."...}, chan Response) error

package main

func main() {
    client := bitflyer.New(
		os.Getenv("BF_KEY"),
		os.Getenv("BF_SECRET"))

    results, managedApiLimit, err := client.Executions(&public.Executions{
        ProductCode: "BTC_JPY",
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, v := range *results {
        fmt.Println(v)
        // -> {2430391013 BUY 2.989057e+06 0.02 2025-01-01T08:47:20.577 JRF20250101-084720-050159 JRF20250101-084720-042209}...
    }
    fmt.Println(managedApiLimit.Remain)
    // API Limit remain and more
    // -> 489

	// For Ohlcv and Ranking
	hclient := hidden.New()
	ohlcv, err := hclient.OHLCv(&hidden.RequestOHLCv{
        Symbo;: "BTC_JPY",
		Period: "m",
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, v := range ohlcv {
        fmt.Println(v)
        // -> O, H, L, C, V, Volume(1day), Y(null), Timestamp
		// 0: 3003659 3004234 3003143 3003503 3.131921 311.1 0 2023-02-01T21:01:00+09:00
    }
}



package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/rluisr/go-bitflyer"
	"github.com/rluisr/go-bitflyer/public"
	"github.com/rluisr/go-bitflyer/realtime"
	"github.com/rluisr/go-bitflyer/types"
)

func main() {
	client := bitflyer.New(
		"xxxxxxxxxxxxxxxxxxx",
		"xxxxxxxxxxxxxxxxxxxxxxxx=")

    // cancel goroutine from this function
	ctx, cancel := context.WithCancel(context.Background())
	ws := realtime.New(ctx)
	defer ws.Close()

    // recive data and notification form websocket
	recived := make(chan realtime.Response, 3)
	// This Connect is sharping binary data, to each struct.
	// There's also a class that handles raw data. use realtime\raw.go
	go ws.Connect(
        // Connect to Private, if struct *Auth. 
		client.Auth, // or nil, when not subscribe to private channel

        // input channel and product code, create request paramater in function
		[]string{
			"executions",
			"ticker",
			"board",
		},
		[]string{
			types.BTCJPY,
		},
		recived)

	go Reciver(ctx, recived)

    sig := make(chan os.Signal)
    <-sig
	cancel()
	time.Sleep(time.Second)
	close(recived)

}

func Reciver(ctx context.Context, ch chan realtime.Response) {
	defer fmt.Println("func reciver was done")
L:
	for {
		select {
		case <-ctx.Done():
			break L
		case v := <-ch:
			switch v.Types {
			case realtime.TickerN:
				fmt.Print(v.ProductCode)
				fmt.Printf(" ticker comming, %.0f\n", v.Ticker.Ltp)
			case realtime.ExecutionsN:
				fmt.Print(v.ProductCode)
				fmt.Println(" executions comming, id: ", v.Executions[0].ID)
			case realtime.BoardSnapN:
				fmt.Print(v.ProductCode)
				fmt.Println(" board snapshot comming, ", v.Board.MidPrice)
			case realtime.BoardN:
				fmt.Print(v.ProductCode)
				fmt.Println(" board update comming, ", len(v.Board.Asks), len(v.Board.Bids))

			case realtime.ChildOrdersN:
				fmt.Println("child order comming, ", v.ChildOrders[0].ChildOrderID)
			case realtime.ParentOrdersN:
				fmt.Println("parent order comming, ", v.ParentOrders[0].ParentOrderID)

			default:
				// can be detected by the receiver as such this loop, so it tells the receiver to terminate.
				// you can check contains "scheduled maintenance" into error.
				fmt.Printf("error or undefind: %#v", v)
			}

		}
	}
}


Author

@_numbP

License

MIT

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
Round for order size 最小注文単位以下の枚数.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author