parmesan

package module
v0.0.0-...-2eb4a02 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

README

Parmesan

API wrapper for v3 of the Bittrex API

Motivation

v1.1 of the Bittrex API will no longer be supported after 30/9/2020, and I want a go wrapper for their API.

You can see the Bittrex API documentation here

⚠ This repo is in development ⚠

Most features are missing at the time of writing, use what exists at your own risk. There may be breaking changes.

Installation

go get github.com/elliotcubit/parmesan

Usage

import (
  "github.com/elliotcubit/parmesan"
)

Code examples will live in the examples directory.

Features

/account

/addresses

/balances

/conditional-orders

/currencies

/deposits

/markets

/orders

/ping

/subaccounts

/transfers

/withdrawals

websocket streams

Contribute

If you'd like to contribute to this project, please be sure to go fmt your code before submitting a pull request.

TODO

Zero values are probably going to be problematic for some responses with optional fields; type wrappers should be used

Dates should be an actual date type instead of leaving it as a string

Testing in a way that won't potentially cost me much money :)

Documentation

Index

Constants

View Source
const (
	MinuteOne  = "MINUTE_1"
	MinuteFive = "MINUTE_5"
	HourOne    = "HOUR_1"
	DayOne     = "DAY_1"

	HistoricalDayOne   = "MINUTE_1"
	HistoricalMonthOne = "HOUR_1"
	HistoricalYearOne  = "DAY_1"
)

By weird design, recent intervals and historical intervals use the same string enum, but have different effects.. Bittrex?

View Source
const (
	OPERAND_LTE                         = "LTE"
	OPERAND_GTE                         = "GTE"
	STATUS_OPEN                         = "OPEN"
	STATUS_COMPLETED                    = "COMPLETED"
	STATUS_CANCELLED                    = "CANCELLED"
	STATUS_FAILED                       = "FAILED"
	DIRECTION_BUY                       = "BUY"
	DIRECTION_SELL                      = "SELL"
	TYPE_LIMIT                          = "LIMIT"
	TYPE_MARKET                         = "MARKET"
	TYPE_CEILING_LIMIT                  = "CEILING_LIMIT"
	TYPE_CEILING_MARKET                 = "CEILING_MARKET"
	PERIOD_GOOD_TILL_CANCELLED          = "GOOD_TILL_CANCELLED"
	PERIOD_IMMEDIATE_OR_CANCEL          = "IMMEDIATE_OR_CANCEL"
	PERIOD_FILL_OR_KILL                 = "FILL_OR_KILL"
	PERIOD_POST_ONLY_GOOD_TIL_CANCELLED = "POST_ONLY_GOOD_TIL_CANCELLED"
	PERIOD_BUY_NOW                      = "BUY_NOW"
)

===== Order Enums =====

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	SubaccountId string `json:"subaccountId"`
	AccountId    string `json:"accountId"`
}

===== Account =====

type AccountVolume

type AccountVolume struct {
	Updated      string          `json:"updated"`
	Volume30Days decimal.Decimal `json:"volume30days"`
}

type Address

type Address struct {
	Status           string `json:"status"`
	CurrencySymbol   string `json:"currencySymbol"`
	CryptoAddress    string `json:"cryptoAddress"`
	CryptoAddressTag string `json:"cryptoAddressTag"`
}

===== Addresses =====

type AddressList

type AddressList []Address

type Balance

type Balance struct {
	CurrencySymbol string          `json:"currencySymbol"`
	Total          decimal.Decimal `json:"total"`
	Available      decimal.Decimal `json:"available"`
	UpdatedAt      string          `json:"updatedAt"`
}

===== Balances =====

type BalanceList

type BalanceList []Balance

type BittrexClient

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

func New

func New(apiKey, apiSecret string) *BittrexClient

func (*BittrexClient) GetAccount

func (b *BittrexClient) GetAccount() (result Account, err error)

func (*BittrexClient) GetAccountVolume

func (b *BittrexClient) GetAccountVolume() (result AccountVolume, err error)

func (*BittrexClient) GetAddress

func (b *BittrexClient) GetAddress(symbol string) (result Address, err error)

func (*BittrexClient) GetAddresses

func (b *BittrexClient) GetAddresses() (result AddressList, err error)

func (*BittrexClient) GetBalance

func (b *BittrexClient) GetBalance(symbol string) (result Balance, err error)

func (*BittrexClient) GetBalances

func (b *BittrexClient) GetBalances() (result BalanceList, err error)

func (*BittrexClient) GetConditionalOrder

func (b *BittrexClient) GetConditionalOrder(id string) (result ConditionalOrder, err error)

func (*BittrexClient) GetCurrencies

func (b *BittrexClient) GetCurrencies() (result CurrencyList, err error)

func (*BittrexClient) GetCurrency

func (b *BittrexClient) GetCurrency(symbol string) (result Currency, err error)

func (*BittrexClient) GetHistoricalCandles

func (b *BittrexClient) GetHistoricalCandles(symbol, period string, year, month, day int) (result CandleList, err error)

TODO validate date specifications & throw our own nice error here Date fields are expected to be 1-indexed.

func (*BittrexClient) GetMarket

func (b *BittrexClient) GetMarket(symbol string) (result Market, err error)

func (*BittrexClient) GetMarketOrderbook

func (b *BittrexClient) GetMarketOrderbook(symbol string) (result MarketOrderbook, err error)

TODO add depth parameter

func (*BittrexClient) GetMarketSummary

func (b *BittrexClient) GetMarketSummary(symbol string) (result MarketSummary, err error)

func (*BittrexClient) GetMarketSummaryList

func (b *BittrexClient) GetMarketSummaryList() (result MarketSummaryList, err error)

func (*BittrexClient) GetMarketTicker

func (b *BittrexClient) GetMarketTicker(symbol string) (result MarketTicker, err error)

func (*BittrexClient) GetMarketTickerList

func (b *BittrexClient) GetMarketTickerList() (result MarketTickerList, err error)

func (*BittrexClient) GetMarketTrades

func (b *BittrexClient) GetMarketTrades(symbol string) (result MarketTrades, err error)

func (*BittrexClient) GetMarkets

func (b *BittrexClient) GetMarkets() (result MarketList, err error)

func (*BittrexClient) GetRecentCandles

func (b *BittrexClient) GetRecentCandles(symbol, period string) (result CandleList, err error)

func (*BittrexClient) Ping

func (b *BittrexClient) Ping() (result PingResponse, err error)

type Candle

type Candle struct {
	StartsAt    string          `json:"startsAt"`
	Open        decimal.Decimal `json:"open"`
	High        decimal.Decimal `json:"high"`
	Low         decimal.Decimal `json:"low"`
	Close       decimal.Decimal `json:"close"`
	Volume      decimal.Decimal `json:"volume"`
	QuoteVolume decimal.Decimal `json:"quoteVolume"`
}

type CandleList

type CandleList []Candle

type ConditionalOrder

type ConditionalOrder struct {
	Id                       string                    `json:"id"`
	MarketSymbol             string                    `json:"marketSymbol"`
	Operand                  string                    `json:"operand"`
	TriggerPrice             decimal.Decimal           `json:"triggerPrice"`
	TrailingStopPercent      decimal.Decimal           `json:"trailingStopPercent"`
	CreatedOrderId           string                    `json:"createdOrderId"`
	OrderToCreate            NewOrder                  `json:"orderToCreate"`
	OrderToCancel            NewCancelConditionalOrder `json:"newCancelConditionalOrder"`
	ClientConditionalOrderId string                    `json:"clientConditionalOrderId"`
	Status                   string                    `json:"status"`
	OrderCreationErrorCode   string                    `json:"orderCreationErrorCode"`
	CreatedAt                string                    `json:"createdAt"`
	UpdatedAt                string                    `json:"updatedAt"`
	ClosedAt                 string                    `json:"closedAt"`
}

===== Conditional Orders =====

type Currency

type Currency struct {
	Symbol           string          `json:"symbol"`
	Name             string          `json:"name"`
	CoinType         string          `json:"coinType"`
	Status           string          `json:"status"`
	MinConfirmations int32           `json:"minConfirmations"`
	Notice           string          `json:"notice"`
	TxFee            decimal.Decimal `json:"txFee"`
	LogoUrl          string          `json:"logoUrl"`
	ProhibitedIn     []string        `json:"prohibitedIn"`
}

type CurrencyList

type CurrencyList []Currency

type Market

type Market struct {
	Symbol              string          `json:"symbol"`
	BaseCurrencySymbol  string          `json:"baseCurrencySymbol"`
	QuoteCurrencySymbol string          `json:"quoteCurrencySymbol"`
	MinTradeSize        decimal.Decimal `json:"minTradeSize"`
	Precision           int32           `json:"precision"`
	Status              string          `json:"status"`
	CreatedAt           string          `json:"createdAt"`
	Notice              string          `json:"notice"`
	ProhibitedIn        []string        `json:"prohibitedIn"`
}

===== Markets =====

type MarketList

type MarketList []Market

type MarketOrderbook

type MarketOrderbook struct {
	Bid []OrderBookEntry `json:"bid"`
	Ask []OrderBookEntry `json:"ask"`
}

type MarketSummary

type MarketSummary struct {
	Symbol        string          `json:"symbol"`
	High          decimal.Decimal `json:"high"`
	Low           decimal.Decimal `json:"low"`
	Volume        decimal.Decimal `json:"volume"`
	QuoteVolume   decimal.Decimal `json:"quoteVolume"`
	PercentChange decimal.Decimal `json:"percentChange"`
	UpdatedAt     string          `json:"updatedAt"`
}

type MarketSummaryList

type MarketSummaryList []MarketSummary

type MarketTicker

type MarketTicker struct {
	Symbol        string          `json:"symbol"`
	LastTradeRate decimal.Decimal `json:"lastTradeRate"`
	BidRate       decimal.Decimal `json:"bidRate"`
	AskRate       decimal.Decimal `json:"askRate"`
}

type MarketTickerList

type MarketTickerList []MarketTicker

type MarketTrades

type MarketTrades []Trade

type NewCancelConditionalOrder

type NewCancelConditionalOrder struct {
	Type string `json:"type"`
	Id   string `json:"id"`
}

type NewOrder

type NewOrder struct {
	MarketSymbol  string          `json:"marketSymbol"`
	Direction     string          `json:"direction"`
	Type          string          `json:"type"`
	Quantity      decimal.Decimal `json:"quantity"`
	Ceiling       decimal.Decimal `json:"ceiling"`
	Limit         decimal.Decimal `json:"limit"`
	TimeInForce   string          `json:"timeInForce"`
	ClientOrderId string          `json:"clientOrderId"`
	UseAwards     bool            `json:"useAwards"`
}

type OrderBookEntry

type OrderBookEntry struct {
	Quantity decimal.Decimal `json:"quantity"`
	Rate     decimal.Decimal `json:"rate"`
}

type PingResponse

type PingResponse struct {
	ServerTime int64 `json:"serverTime"`
}

===== Ping =====

type Trade

type Trade struct {
	Id         string          `json:"id"`
	ExecutedAt string          `json:"executedAt"`
	Quantity   decimal.Decimal `json:"quantity"`
	Rate       decimal.Decimal `json:"rate"`
	TakerSide  string          `json:"takerSide"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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