mtgox

package module
v0.0.0-...-c622919 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2013 License: MIT Imports: 15 Imported by: 0

README

mtgox

An implementation of a Mt. Gox client in Go. It uses the websocket interface.

Note: This API mostly complete but untested in production.

Documentation

Example below. API Documentation on Godoc.

Example

func ExampleMtGoxApi() {
	gox, err := NewFromConfig(os.ExpandEnv("$MTGOX_CONFIG"))
	if err != nil {
		panic(err)
	}

	c, err := gox.Subscribe("ticker", "depth")
	if err != nil {
		panic(err)
	}

	go func() {
		for msg := range c {
			fmt.Println("Got ticker or depth:", msg)
		}
	}()

	orderchan, err := gox.SubmitOrder("bid", 100000000, 10000) // Both are in _int notation. Will add float later
	if err != nil {
		panic(err)
	}

	order := <- orderchan
	if order.Success {
		fmt.Println("Yay submitted an order!", order.Result)
	} else {
		fmt.Println("Boo. Failure!", order.Error)
	}
}

License

MIT found in LICENSE file.

Documentation

Overview

Package mtgox provides a streaming implementation of Mt. Gox's bitcoin trading API.

Index

Constants

View Source
const (
	TICKER StreamType = "ticker"
	DEPTH  StreamType = "depth"
	TRADES StreamType = "trades"

	BID OrderType = "bid"
	ASK OrderType = "ask"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallResult

type CallResult struct {
	Result  map[string]interface{}
	Success bool
	Error   string
}

type Config

type Config struct {
	Currencies []string
	Key        string
	Secret     string
}

type OrderType

type OrderType string

type StreamType

type StreamType string

type StreamingApi

type StreamingApi struct {
	*msgwatch.MsgWatcher
	// contains filtered or unexported fields
}

func New

func New(key, secret string, currencies ...string) (*StreamingApi, error)

func NewFromConfig

func NewFromConfig(cfgfile string) (*StreamingApi, error)

Initialize a StreamingApi based on a json file unmarshalled into a Config object

func (*StreamingApi) AddPrivateKey

func (api *StreamingApi) AddPrivateKey(key string, desc string) (chan *CallResult, error)

func (*StreamingApi) AddWallet

func (api *StreamingApi) AddWallet(walletdat, description string) (chan *CallResult, error)

func (*StreamingApi) Address

func (api *StreamingApi) Address(description string) (chan *CallResult, error)

func (*StreamingApi) AddressDetails

func (api *StreamingApi) AddressDetails(addr string) (chan *CallResult, error)

func (*StreamingApi) CancelOrder

func (api *StreamingApi) CancelOrder(oid string) (chan *CallResult, error)

func (*StreamingApi) Close

func (api *StreamingApi) Close() error

func (*StreamingApi) FullHistory

func (api *StreamingApi) FullHistory(currency string, page int) (chan *CallResult, error)

func (*StreamingApi) IdKey

func (api *StreamingApi) IdKey() (chan *CallResult, error)

func (*StreamingApi) Info

func (api *StreamingApi) Info() (chan *CallResult, error)

func (*StreamingApi) Lag

func (api *StreamingApi) Lag() (chan *CallResult, error)

func (*StreamingApi) OrderResult

func (api *StreamingApi) OrderResult(oid string) (chan *CallResult, error)

func (*StreamingApi) Orders

func (api *StreamingApi) Orders() (chan *CallResult, error)

func (*StreamingApi) QueryHistory

func (api *StreamingApi) QueryHistory(currency string, typ string, begin, end *time.Time, page int) (chan *CallResult, error)

func (*StreamingApi) Send

func (api *StreamingApi) Send(addr string, amount_int uint64) (chan *CallResult, error)

func (*StreamingApi) SubmitOrder

func (api *StreamingApi) SubmitOrder(typ string, amount, price uint64) (chan *CallResult, error)

func (*StreamingApi) Subscribe

func (api *StreamingApi) Subscribe(typs ...StreamType) (chan map[string]interface{}, error)

Subscribe to a type of channel. Returns the Listen(typ) listener.

func (*StreamingApi) Unsubscribe

func (api *StreamingApi) Unsubscribe(name string) error

Unsubscribe from a named channel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL