southxchange

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

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 13 Imported by: 0

README

go-southxchange

go-southxchange is an implementation of the SouthXchange API (public and private) in Golang.

Import

import "github.com/bitbandi/go-southxchange"

Usage

In order to use the client with go's default http client settings you can do:

package main

import (
	"fmt"
	"github.com/bitbandi/go-southxchange"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	// southxchange client
	southxchange := southxchange.New(API_KEY, API_SECRET, "user-agent")

	// Get balances
	balances, err := southxchange.GetBalances()
	fmt.Println(err, balances)
}

In order to use custom settings for the http client do:

package main

import (
	"fmt"
	"net/http"
	"time"
	"github.com/bitbandi/go-southxchange"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	httpClient := &http.Client{
		Timeout: time.Second * 10,
	}

	// southxchange client
	bc := southxchange.NewWithCustomHttpClient(API_KEY, API_SECRET, "user-agent", httpClient)

	// Get balances
	balances, err := southxchange.GetBalances()
	fmt.Println(err, balances)
}

See "Examples" folder for more... examples

Documentation

Overview

Package SouthXchange is an implementation of the SouthXchange API in Golang.

Index

Constants

View Source
const (
	API_BASE    = "https://www.southxchange.com/api" // SouthXchange API endpoint
	API_BASE_V2 = "https://www.southxchange.com/api/v2"
)

Variables

This section is empty.

Functions

func DecodeData

func DecodeData(body []byte, indexes []int) (ret []byte, err error)

func NewClient

func NewClient(apiKey, apiSecret, userAgent string) (c *client)

NewClient return a new SouthXchange HTTP client

func NewClientWithCustomHttpConfig

func NewClientWithCustomHttpConfig(apiKey, apiSecret, userAgent string, httpClient *http.Client) (c *client)

NewClientWithCustomHttpConfig returns a new SouthXchange HTTP client using the predefined http client

func NewClientWithCustomTimeout

func NewClientWithCustomTimeout(apiKey, apiSecret, userAgent string, timeout time.Duration) (c *client)

NewClient returns a new SouthXchange HTTP client with custom timeout

Types

type Balance

type Balance struct {
	Currency    string
	Deposited   float64
	Available   float64
	Unconfirmed float64
}

type Book

type Book struct {
	BuyOrders  []BookOrder `json:"BuyOrders"`
	SellOrders []BookOrder `json:"SellOrders"`
}

type BookOrder

type BookOrder struct {
	Index  int     `json:"Index"`
	Amount float64 `json:"Amount"`
	Price  float64 `json:"Price"`
}

type MarketPrice

type MarketPrice struct {
	Bid           float64 `json:"Bid"`
	Ask           float64 `json:"Ask"`
	Last          float64 `json:"Last"`
	Variation24Hr float64 `json:"Variation24Hr"`
	Volume24Hr    float64 `json:"Volume24Hr"`
}

type MarketSummary

type MarketSummary struct {
	Coin string `json:"Coin"`
	Base string `json:"Base"`
}

func (*MarketSummary) UnmarshalJSON

func (n *MarketSummary) UnmarshalJSON(buf []byte) error

type Order

type Order struct {
	Code              string
	Type              string
	Amount            float64
	OriginalAmount    float64
	LimitPrice        float64
	ListingCurrency   string
	ReferenceCurrency string
	Status            string
	DateAdded         string
}

type OrderType

type OrderType string
const (
	Buy  OrderType = "buy"
	Sell OrderType = "sell"
)

type SouthXchange

type SouthXchange struct {
	// contains filtered or unexported fields
}

SouthXchange represent a SouthXchange client

func New

func New(apiKey, apiSecret, userAgent string) *SouthXchange

New returns an instantiated SouthXchange struct

func NewWithCustomHttpClient

func NewWithCustomHttpClient(apiKey, apiSecret, userAgent string, httpClient *http.Client) *SouthXchange

NewWithCustomHttpClient returns an instantiated SouthXchange struct with custom http client

func NewWithCustomTimeout

func NewWithCustomTimeout(apiKey, apiSecret, userAgent string, timeout time.Duration) *SouthXchange

NewWithCustomTimeout returns an instantiated SouthXchange struct with custom timeout

func (*SouthXchange) GetBalances

func (o *SouthXchange) GetBalances() (balances []Balance, err error)

GetBalances is used to retrieve all balances from your account

func (*SouthXchange) GetBookOrders

func (b *SouthXchange) GetBookOrders(listing string, reference string) (book Book, err error)

func (*SouthXchange) GetDepositAddress

func (b *SouthXchange) GetDepositAddress(currency string) (address string, err error)

GetDepositAddress is sed to generate or retrieve an address for a specific currency. currency a string literal for the currency (ie. BTC)

func (*SouthXchange) GetMarketPrice

func (s *SouthXchange) GetMarketPrice(listing string, reference string) (marketPrice MarketPrice, err error)

func (*SouthXchange) GetMarketSummaries

func (b *SouthXchange) GetMarketSummaries() (marketSummaries []MarketSummary, err error)

GetMarketSummaries is used to get the last 24 hour summary of all active exchanges

func (*SouthXchange) GetOpenOrders

func (b *SouthXchange) GetOpenOrders() (openOrders []Order, err error)

GetOpenOrders returns orders that you currently have opened.

func (*SouthXchange) GetOrder

func (b *SouthXchange) GetOrder(orderCode string) (order Order, err error)

GetOrder returns an order based on the orderCode

func (*SouthXchange) GetTransactions

func (b *SouthXchange) GetTransactions(transactionType string, start uint64, limit uint32, sort string, desc bool) (transactions []Transaction, err error)

GetTransactions is used to retrieve your transaction history

func (*SouthXchange) ListOrders

func (o *SouthXchange) ListOrders() (orders []string, err error)

gets and array containing all orders

func (*SouthXchange) PlaceOrder

func (o *SouthXchange) PlaceOrder(listing string, reference string, orderSide OrderType, amount float64, limitPrice float64, marketPrice bool) (orderCode string, err error)

listing string reference string orderSide string enum amount float the quantity of coins to sell limitPrice float optional price in reference currency. ff nil then order is executed at market price

func (*SouthXchange) SetDebug

func (o *SouthXchange) SetDebug(enable bool)

set enable/disable http request/response dump

func (*SouthXchange) Withdraw

func (o *SouthXchange) Withdraw(address string, currency string, quantity float64) (withdraw WithdrawalInfo, err error)

Withdraw is used to withdraw funds from your account. address string the address where to send the funds. currency string literal for the currency (ie. BTC) quantity float the quantity of coins to withdraw fee float the quantity of coins to withdraw

type Timestamp

type Timestamp time.Time

func (Timestamp) Diff

func (t Timestamp) Diff(u Timestamp) time.Duration

func (Timestamp) Format

func (t Timestamp) Format(layout string) string

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(body []byte) (err error)

type Transaction

type Transaction struct {
	TradeId       int
	MovementId    int64
	Date          Timestamp
	Type          string
	Amount        float64
	TotalBalance  float64
	Price         float64
	OtherAmount   float64
	OtherCurrency string
	OrderCode     string
	Status        string
	Address       string
	Hash          string
}

type WithdrawalInfo

type WithdrawalInfo struct {
	Status     string
	Max        float64
	MaxDaily   float64
	MovementId int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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