Giter Site home page Giter Site logo

bitflyer's Introduction

bitflyer

GoDoc GitHub license

bitflyer api for trading bot.

this liibrary contains

  • realtime api
  • private api
  • public api

Install

$ go get -u github.com/sodefrin/bitflyer

requirements: go1.13

Usage

realtime api

using ticker

package main

import (
	"context"
	"log"
	"time"

	"github.com/sodefrin/bitflyer"
)

func main() {
	bf := bitflyer.NewBitflyer()
	realtime, err := bf.GetRealtimeAPIClient()
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()
	go realtime.Subscribe(ctx)

	ticker := time.NewTicker(time.Second)
	defer ticker.Stop()
	for {
		<-ticker.C
		mid, bids, ask := realtime.GetBoard()
		// you can recieve board data.
		// ...

		exs := realtime.GetExecutions(time.Second)
		// you can recieve execution data within 1 second.
		// ...
	}
}

using callback

package main

import (
	"context"
	"log"

	"github.com/sodefrin/bitflyer"
)

func main() {
	bf := bitflyer.NewBitflyer()
	realtime, err := bf.GetRealtimeAPIClient()
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()
	realtime.AddOnBoardCallback(ctx, func(mid float64, bids, asks []*bitflyer.Price) {
		// you can recieve board diff data by callback.
		// ...
	})
	realtime.AddOnExecutionCallback(ctx, func(exs []*bitflyer.Execution) {
		// you can recieve execution diff data by callback.
		// ...
	})

	// blocking.
	if err := realtime.Subscribe(ctx); err != nil {
		log.Fatal(err)
	}
}

parivate api

create order

package main

import (
	"log"

	"github.com/sodefrin/bitflyer"
)

func main() {
	bf := bitflyer.NewBitflyer()
	private, err := bf.PrivateAPIClient("your api key", "your api secret")
	if err != nil {
		log.Fatal(err)
	}

	if _, err = private.CreateOrder("BUY", 910000, 0.01, "LIMIT"); err != nil {
		log.Fatal(err)
	}
}

bitflyer's People

Contributors

habuka036 avatar sodefrin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.