mtgox

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

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

Go to latest
Published: Sep 3, 2013 License: MIT Imports: 13 Imported by: 0

README

mtgox

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

Note: This API is experimental.

Documentation

Example below. API Documentation on Godoc.

Example

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

	tickers := gox.Ticker
	if err != nil {
		panic(err)
	}

	go func() {
		for ticker := range tickers {
			fmt.Println("Got ticker", ticker)
		}
	}()


	orderchan := gox.SubmitOrder("bid", 100000000, 10000) // Both are in _int notation

	order := <-orderchan
    fmt.Println("Yay submitted an order!", order)
}

License

MIT found in LICENSE file.

Documentation

Overview

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

type Depth

type Depth struct {
	Type             int64
	Type_str         string
	Volume           float64   `json:",string"`
	Volume_int       int64     `json:",string"`
	Now              EpochTime `json:",string"`
	Price            float64   `json:",string"`
	Price_int        int64     `json:",string"`
	Item             string
	Currency         string
	Total_volume_int int64 `json:",string"`
}

type EpochTime

type EpochTime struct {
	time.Time
}

func (*EpochTime) UnmarshalJSON

func (t *EpochTime) UnmarshalJSON(b []byte) error

type Info

type Info struct {
	Created       SimpleTime `json:",string"`
	Id            string
	Index         string
	Language      string
	Last_login    SimpleTime `json:",string"`
	Link          string
	Login         string
	Montly_Volume Value
	Trade_fee     float64
	Rights        []string
	Wallets       map[string]Wallet
}

type Order

type Order struct {
	Oid              string
	Currency         string
	Item             string
	Type             string
	Amount           Value
	Effective_amount Value
	Price            Value
	Status           string
	Date             EpochTime
	Priority         EpochTime `json:",string"`
	Actions          []string
}

type Rate

type Rate struct {
	To   string
	From string
	Rate float64
}

type SimpleTime

type SimpleTime struct {
	time.Time
}

func (*SimpleTime) UnmarshalJSON

func (t *SimpleTime) UnmarshalJSON(b []byte) error

type StreamingApi

type StreamingApi struct {
	Errors chan error
	Ticker chan Ticker
	Info   chan Info
	Depth  chan Depth
	Trade  chan Trade
	Orders chan []Order
	// contains filtered or unexported fields
}
Example
gox, err := NewFromConfig(os.ExpandEnv("$MTGOX_CONFIG"))
gox.Start()
if err != nil {
	panic(err)
}

tickers := gox.Ticker
if err != nil {
	panic(err)
}

go func() {
	for ticker := range tickers {
		fmt.Println("Got ticker", ticker)
	}
}()

orderchan := gox.SubmitOrder("bid", 100000000, 10000) // Both are in _int notation

order := <-orderchan
fmt.Println("Yay submitted an order!", order)
Output:

func New

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

func NewFromConfig

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

func (*StreamingApi) Close

func (api *StreamingApi) Close() error

func (*StreamingApi) HandleErrors

func (api *StreamingApi) HandleErrors(f func(error))

func (*StreamingApi) RequestInfo

func (api *StreamingApi) RequestInfo() (c chan Info)

func (*StreamingApi) RequestOrders

func (api *StreamingApi) RequestOrders() (c chan []Order)

func (*StreamingApi) Start

func (api *StreamingApi) Start()

func (*StreamingApi) SubmitOrder

func (api *StreamingApi) SubmitOrder(typ string, amount, price int64) chan []Order

type Ticker

type Ticker struct {
	Vol        Value // Volume
	Item       string
	High       Value //Highest value
	Low        Value // Lowest Value
	Last       Value // == Last_local
	Last_local Value // Last trade in auxilary currency
	Last_all   Value // Last trade converted to auxilary currency
	Last_orig  Value // Last trade in any currency
	Buy        Value
	Sell       Value
	VWap       Value     // Volume weighted average price
	Avg        Value     // Averaged price
	Now        EpochTime `json:",string"`
}

type Trade

type Trade struct {
	Type           string
	Trade_type     string
	Properties     string
	Now            time.Time
	Amount         float64
	Amount_int     int64
	Primary        string
	Price          float64
	Price_int      int64
	Item           string
	Price_currency string
}

type Value

type Value struct {
	Value         float64 `json:",string"`
	Value_int     int64   `json:",string"`
	Display       string
	Display_short string
	Currency      string
}

type Wallet

type Wallet struct {
	Balance              Value
	Daily_Withdraw_Limit Value
	Max_Withdraw         Value
	// Monthly_Withdraw_Limit nil
	Open_Orders Value
	Operations  int64
}

Jump to

Keyboard shortcuts

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