bitstamp

package
v0.0.0-...-a2c5123 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 17 Imported by: 0

README

GoCryptoTrader package Bitstamp

Build Status Software License GoDoc Coverage Status Go Report Card

This bitstamp package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Bitstamp Exchange

Current Features
  • REST Support
  • Websocket Support
How to enable
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var b exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "Bitstamp" {
    b = bot.exchanges[i]
  }
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := b.GetTickerPrice()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderbookEx()
if err != nil {
  // Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := b.GetExchangeAccountInfo()
if err != nil {
  // Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := b.GetTicker()
if err != nil {
  // Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderBook()
if err != nil {
  // Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := b.GetUserInfo(...)
if err != nil {
  // Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := b.Trade(...)
if err != nil {
  // Handle error
}
How to do Websocket public/private calls
  // Exchanges will be abstracted out in further updates and examples will be
  // supplied then
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

View Source
const (
	// BitstampPusherKey holds the current pusher key
	BitstampPusherKey = "de504dc5763aeef9ff52"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Balances

type Balances struct {
	USDBalance   float64 `json:"usd_balance,string"`
	BTCBalance   float64 `json:"btc_balance,string"`
	EURBalance   float64 `json:"eur_balance,string"`
	XRPBalance   float64 `json:"xrp_balance,string"`
	USDReserved  float64 `json:"usd_reserved,string"`
	BTCReserved  float64 `json:"btc_reserved,string"`
	EURReserved  float64 `json:"eur_reserved,string"`
	XRPReserved  float64 `json:"xrp_reserved,string"`
	USDAvailable float64 `json:"usd_available,string"`
	BTCAvailable float64 `json:"btc_available,string"`
	EURAvailable float64 `json:"eur_available,string"`
	XRPAvailable float64 `json:"xrp_available,string"`
	BTCUSDFee    float64 `json:"btcusd_fee,string"`
	BTCEURFee    float64 `json:"btceur_fee,string"`
	EURUSDFee    float64 `json:"eurusd_fee,string"`
	XRPUSDFee    float64 `json:"xrpusd_fee,string"`
	XRPEURFee    float64 `json:"xrpeur_fee,string"`
	XRPBTCFee    float64 `json:"xrpbtc_fee,string"`
	Fee          float64 `json:"fee,string"`
}

Balances holds full balance information with the supplied APIKEYS

type Bitstamp

type Bitstamp struct {
	exchange.Base
	Balance Balances
}

Bitstamp is the overarching type across the bitstamp package

func (*Bitstamp) CancelAllExchangeOrders

func (b *Bitstamp) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*Bitstamp) CancelAllOrders

func (b *Bitstamp) CancelAllOrders() (bool, error)

CancelAllOrders cancels all open orders on the exchange

func (*Bitstamp) CancelExchangeOrder

func (b *Bitstamp) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*Bitstamp) CancelOrder

func (b *Bitstamp) CancelOrder(OrderID int64) (bool, error)

CancelOrder cancels order by ID

func (*Bitstamp) CryptoWithdrawal

func (b *Bitstamp) CryptoWithdrawal(amount float64, address, symbol, destTag string, instant bool) (string, error)

CryptoWithdrawal withdraws a cryptocurrency into a supplied wallet, returns ID amount - The amount you want withdrawn address - The wallet address of the cryptocurrency symbol - the type of crypto ie "ltc", "btc", "eth" destTag - only for XRP default to "" instant - only for bitcoins

func (*Bitstamp) GetBalance

func (b *Bitstamp) GetBalance() (Balances, error)

GetBalance returns full balance of currency held on the exchange

func (*Bitstamp) GetCryptoDepositAddress

func (b *Bitstamp) GetCryptoDepositAddress(crypto string) (string, error)

GetCryptoDepositAddress returns a depositing address by crypto crypto - example "btc", "ltc", "eth", or "xrp"

func (*Bitstamp) GetEURUSDConversionRate

func (b *Bitstamp) GetEURUSDConversionRate() (EURUSDConversionRate, error)

GetEURUSDConversionRate returns the conversion rate between Euro and USD

func (*Bitstamp) GetExchangeAccountInfo

func (b *Bitstamp) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the Bitstamp exchange

func (*Bitstamp) GetExchangeDepositAddress

func (b *Bitstamp) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*Bitstamp) GetExchangeFundTransferHistory

func (b *Bitstamp) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*Bitstamp) GetExchangeHistory

func (b *Bitstamp) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Bitstamp) GetExchangeOrderInfo

func (b *Bitstamp) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*Bitstamp) GetFee

func (b *Bitstamp) GetFee(currencyPair string) float64

GetFee returns fee on a currency pair

func (*Bitstamp) GetOpenOrders

func (b *Bitstamp) GetOpenOrders(currencyPair string) ([]Order, error)

GetOpenOrders returns all open orders on the exchange

func (*Bitstamp) GetOrderStatus

func (b *Bitstamp) GetOrderStatus(OrderID int64) (OrderStatus, error)

GetOrderStatus returns an the status of an order by its ID

func (*Bitstamp) GetOrderbook

func (b *Bitstamp) GetOrderbook(currency string) (Orderbook, error)

GetOrderbook Returns a JSON dictionary with "bids" and "asks". Each is a list of open orders and each order is represented as a list holding the price and the amount.

func (*Bitstamp) GetOrderbookEx

func (b *Bitstamp) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns the orderbook for a currency pair

func (*Bitstamp) GetTicker

func (b *Bitstamp) GetTicker(currency string, hourly bool) (Ticker, error)

GetTicker returns ticker information

func (*Bitstamp) GetTickerPrice

func (b *Bitstamp) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Bitstamp) GetTradingPairs

func (b *Bitstamp) GetTradingPairs() ([]TradingPair, error)

GetTradingPairs returns a list of trading pairs which Bitstamp currently supports

func (*Bitstamp) GetTransactions

func (b *Bitstamp) GetTransactions(currencyPair string, values url.Values) ([]Transactions, error)

GetTransactions returns transaction information value paramater ["time"] = "minute", "hour", "day" will collate your response into time intervals. Implementation of value in test code.

func (*Bitstamp) GetUnconfirmedBitcoinDeposits

func (b *Bitstamp) GetUnconfirmedBitcoinDeposits() ([]UnconfirmedBTCTransactions, error)

GetUnconfirmedBitcoinDeposits returns unconfirmed transactions

func (*Bitstamp) GetUserTransactions

func (b *Bitstamp) GetUserTransactions(currencyPair string) ([]UserTransactions, error)

GetUserTransactions returns an array of transactions

func (*Bitstamp) GetWithdrawalRequests

func (b *Bitstamp) GetWithdrawalRequests(timedelta int64) ([]WithdrawalRequests, error)

GetWithdrawalRequests returns withdrawal requests for the account timedelta - positive integer with max value 50000000 which returns requests from number of seconds ago to now.

func (*Bitstamp) ModifyExchangeOrder

func (b *Bitstamp) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

ModifyExchangeOrder will allow of changing orderbook placement and limit to market conversion

func (*Bitstamp) PlaceOrder

func (b *Bitstamp) PlaceOrder(currencyPair string, price float64, amount float64, buy, market bool) (Order, error)

PlaceOrder places an order on the exchange.

func (*Bitstamp) PusherClient

func (b *Bitstamp) PusherClient()

PusherClient starts the push mechanism

func (*Bitstamp) Run

func (b *Bitstamp) Run()

Run implements the Bitstamp wrapper

func (*Bitstamp) SendAuthenticatedHTTPRequest

func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url.Values, result interface{}) (err error)

SendAuthenticatedHTTPRequest sends an authenticated request

func (*Bitstamp) SendHTTPRequest

func (b *Bitstamp) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*Bitstamp) SetDefaults

func (b *Bitstamp) SetDefaults()

SetDefaults sets default for Bitstamp

func (*Bitstamp) Setup

func (b *Bitstamp) Setup(exch config.ExchangeConfig)

Setup sets configuration values to bitstamp

func (*Bitstamp) Start

func (b *Bitstamp) Start(wg *sync.WaitGroup)

Start starts the Bitstamp go routine

func (*Bitstamp) SubmitExchangeOrder

func (b *Bitstamp) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error)

SubmitExchangeOrder submits a new order

func (*Bitstamp) TransferAccountBalance

func (b *Bitstamp) TransferAccountBalance(amount float64, currency, subAccount string, toMain bool) (bool, error)

TransferAccountBalance transfers funds from either a main or sub account amount - to transfers currency - which currency to transfer subaccount - name of account toMain - bool either to or from account

func (*Bitstamp) UpdateOrderbook

func (b *Bitstamp) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bitstamp) UpdateTicker

func (b *Bitstamp) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Bitstamp) WithdrawCryptoExchangeFunds

func (b *Bitstamp) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bitstamp) WithdrawFiatExchangeFunds

func (b *Bitstamp) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bitstamp) WithdrawFiatExchangeFundsToInternationalBank

func (b *Bitstamp) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type CaptureError

type CaptureError struct {
	Status interface{} `json:"status"`
	Reason interface{} `json:"reason"`
	Code   interface{} `json:"code"`
	Error  interface{} `json:"error"`
}

CaptureError is used to capture unmarshalled errors

type EURUSDConversionRate

type EURUSDConversionRate struct {
	Buy  float64 `json:"buy,string"`
	Sell float64 `json:"sell,string"`
}

EURUSDConversionRate holds buy sell conversion rate information

type Order

type Order struct {
	ID     int64   `json:"id"`
	Date   string  `json:"datetime"`
	Type   int     `json:"type"`
	Price  float64 `json:"price"`
	Amount float64 `json:"amount"`
}

Order holds current open order data

type OrderStatus

type OrderStatus struct {
	Status       string
	Transactions []struct {
		TradeID int64   `json:"tid"`
		USD     float64 `json:"usd,string"`
		Price   float64 `json:"price,string"`
		Fee     float64 `json:"fee,string"`
		BTC     float64 `json:"btc,string"`
	}
}

OrderStatus holds order status information

type Orderbook

type Orderbook struct {
	Timestamp int64 `json:"timestamp,string"`
	Bids      []OrderbookBase
	Asks      []OrderbookBase
}

Orderbook holds orderbook information

type OrderbookBase

type OrderbookBase struct {
	Price  float64
	Amount float64
}

OrderbookBase holds singular price information

type PusherOrderbook

type PusherOrderbook struct {
	Asks [][]string `json:"asks"`
	Bids [][]string `json:"bids"`
}

PusherOrderbook holds order book information to be pushed

type PusherTrade

type PusherTrade struct {
	Price  float64 `json:"price"`
	Amount float64 `json:"amount"`
	ID     int64   `json:"id"`
}

PusherTrade holds trade information to be pushed

type Ticker

type Ticker struct {
	Last      float64 `json:"last,string"`
	High      float64 `json:"high,string"`
	Low       float64 `json:"low,string"`
	Vwap      float64 `json:"vwap,string"`
	Volume    float64 `json:"volume,string"`
	Bid       float64 `json:"bid,string"`
	Ask       float64 `json:"ask,string"`
	Timestamp int64   `json:"timestamp,string"`
	Open      float64 `json:"open,string"`
}

Ticker holds ticker information

type TradingPair

type TradingPair struct {
	Name            string `json:"name"`
	URLSymbol       string `json:"url_symbol"`
	BaseDecimals    int    `json:"base_decimals"`
	CounterDecimals int    `json:"counter_decimals"`
	MinimumOrder    string `json:"minimum_order"`
	Trading         string `json:"trading"`
	Description     string `json:"description"`
}

TradingPair holds trading pair information

type Transactions

type Transactions struct {
	Date    int64   `json:"date,string"`
	TradeID int64   `json:"tid,string"`
	Price   float64 `json:"price,string"`
	Type    int     `json:"type,string"`
	Amount  float64 `json:"amount,string"`
}

Transactions holds transaction data

type UnconfirmedBTCTransactions

type UnconfirmedBTCTransactions struct {
	Amount        float64 `json:"amount,string"`
	Address       string  `json:"address"`
	Confirmations int     `json:"confirmations"`
}

UnconfirmedBTCTransactions holds address information about unconfirmed transactions

type UserTransactions

type UserTransactions struct {
	Date    string  `json:"datetime"`
	TransID int64   `json:"id"`
	Type    int     `json:"type,string"`
	USD     float64 `json:"usd"`
	EUR     float64 `json:"eur"`
	BTC     float64 `json:"btc"`
	XRP     float64 `json:"xrp"`
	BTCUSD  float64 `json:"btc_usd"`
	Fee     float64 `json:"fee,string"`
	OrderID int64   `json:"order_id"`
}

UserTransactions holds user transaction information

type WithdrawalRequests

type WithdrawalRequests struct {
	OrderID       int64   `json:"id"`
	Date          string  `json:"datetime"`
	Type          int     `json:"type"`
	Amount        float64 `json:"amount,string"`
	Status        int     `json:"status"`
	Data          interface{}
	Address       string `json:"address"`        // Bitcoin withdrawals only
	TransactionID string `json:"transaction_id"` // Bitcoin withdrawals only
}

WithdrawalRequests holds request information on withdrawals

Jump to

Keyboard shortcuts

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