Documentation ¶
Index ¶
- type Balance
- type Candle
- type CandleHandler
- type Client
- func (c *Client) Balances() ([]Balance, error)
- func (c *Client) Cancel(orderUUID string) error
- func (c *Client) LimitBuy(market string, quantity, rate float64) error
- func (c *Client) LimitSell(market string, quantity, rate float64) error
- func (c *Client) Markets() ([]Market, error)
- func (c *Client) OrderHistory() ([]Order, error)
- func (c *Client) ProcessCandles(interval time.Duration, candleHandler CandleHandler)
- func (c *Client) Register(h TradeHandler)
- func (c *Client) SetCustomID(id string) error
- func (c *Client) Subscribe(market string, errHandler ErrHandler) error
- func (c *Client) Ticks(market string) ([]Tick, error)
- type ErrHandler
- type Market
- type Order
- type RequestParamsRecorder
- type Tick
- type Trade
- type TradeHandler
- type TradeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
type Balance struct { Currency string Balance float64 Available float64 Pending float64 CryptoAddress string }
Balance represents an account balance.
type Candle ¶
type Candle struct { Market string Time time.Time Open float64 High float64 Low float64 Close float64 Volume float64 }
Candle contains the open, high, low, close, and volume data for a market.
type Client ¶
type Client struct { // HTTPClient is optional. It can be used to inject a custom underlying HTTP // client to perform HTTP operations. HTTPClient *http.Client // HTTPTransport is optional. It can be used to inject a custom underlying // HTTP transport into the underlying HTTP client. HTTPTransport *http.Transport // MaxRetries indicates the maximum number of times to attempt an HTTP // operation before failing. MaxRetries int // RetryWaitDuration is used to determine how long to wait between retries // of various operations. RetryWaitDuration time.Duration // A Bittrex-supplied API key and secret. APIKey string APISecret string // HostAddr address is the address of the Bittrex server providing the service // we're using. Using this variable allows us to more simply test // functionality in this package. HostAddr string // contains filtered or unexported fields }
Client provides an interface by which people can call the Bittrex API endpoints (both the REST and the WebSocket APIs).
func (*Client) OrderHistory ¶
OrderHistory gets the latest orders made through Bittrex for the user's account.
func (*Client) ProcessCandles ¶
func (c *Client) ProcessCandles(interval time.Duration, candleHandler CandleHandler)
ProcessCandles monitors the trade data for all subscribed markets and produces candle data for the specified interval.
func (*Client) Register ¶
func (c *Client) Register(h TradeHandler)
Register saves the specified trade handler to a slice of handlers that will be run against each incoming trade.
func (*Client) SetCustomID ¶
SetCustomID assigns the specified id to the underlying SignalR client.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(market string, errHandler ErrHandler) error
Subscribe sends a request to Bittrex to start sending us the market data for the indicated market.
func (*Client) Ticks ¶
Ticks gets a little under 10 days of candle data (14365 minutes) at the one minute interval. However, it is usually missing the last few minutes, so a way to monitor trades (such as the Trades() function) is still required to get up-to-the-minute data.
As a general approach when monitoring data for strategic analysis, this function should be called once a minute for a few minutes until the timestamps from the live trade data (Trades() function) overlap with the data returned by this function. You shouldn't have to wait more than about 5-10 minutes for this to occur; at that point you likely only need to use live trade data and perhaps then use this function as the source of truth for validating your data.
Intervals provided by the underlying Bittrex API are: day, hour, thirtyMin, fiveMin, and oneMin.
type Market ¶
type Market struct { MarketCurrency string BaseCurrency string MarketCurrencyLong string BaseCurrencyLong string MinTradeSize float64 Name string `json:"MarketName"` IsActive bool Created string Notice *string IsSponsored *bool LogoURL string `json:"LogoUrl"` }
Market represents a market on Bittrex for trading between two currencies: the market currency and the base currency.
type Order ¶
type Order struct { OrderUUID string `json:"OrderUuid"` Exchange string TimeStamp string // format: 2014-07-09T02:58:46.27 OrderType string Limit float64 Quantity float64 QuantityRemaining float64 Commission float64 Price float64 PricePerUnit float64 IsConditional bool Condition string ConditionTarget *json.RawMessage ImmediateOrCancel bool Closed string // This is a timestamp. }
Order represents an order that is placed on Bittrex.
type RequestParamsRecorder ¶
RequestParamsRecorder provides a way to record request parameters.
func NewMockRestServer ¶
func NewMockRestServer() (*httptest.Server, *RequestParamsRecorder)
NewMockRestServer returns a new httptest server that can be used to record parameters passed in by each request.
func (*RequestParamsRecorder) SaveParams ¶
func (rr *RequestParamsRecorder) SaveParams(r *http.Request)
SaveParams saves the parameters passed in by the specified HTTP request.
type Tick ¶
type Tick struct { Open float64 `json:"O"` High float64 `json:"H"` Low float64 `json:"L"` Close float64 `json:"C"` Volume float64 `json:"V"` Timestamp string `json:"T"` BV float64 }
Tick represents the open, high, low, and close values along with some other bits of data received from Bittrex.
For example, many of these ticks will be returned by navigating to the following website: https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-WAVES&tickInterval=oneMin
Here is an example of what they should look like:
{ "O":0.00061830, "H":0.00061830, "L":0.00061798, "C":0.00061798, "V":1220.69744635, "T":"2017-11-17T16:51:00", "BV":0.75448216 }
type Trade ¶
type Trade struct { BaseCurrency string MarketCurrency string Type TradeType Price float64 Quantity float64 Time time.Time }
Trade represents a trade that is planned or that already happened using the Bittrex API.