Skip to content

Commit

Permalink
Merge pull request #2 from baibaratsky/master
Browse files Browse the repository at this point in the history
Ticker: ignore_invalid
  • Loading branch information
onuryilmaz committed Jan 23, 2017
2 parents d9a20b5 + 33f0460 commit aa4e878
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion public.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ func (api *PublicAPI) Info() (Info, error) {

// Ticker provides all the information about currently active pairs, such as: the maximum price, the minimum price, average price, trade volume, trade volume in currency, the last trade, Buy and Sell price.
// All information is provided over the past 24 hours.
func (api *PublicAPI) Ticker(currency []string) (Ticker, error) {
func (api *PublicAPI) Ticker(currency []string, ignoreInvalid ...bool) (Ticker, error) {

url := apiURL + "ticker/"
for _, c := range currency {
url = url + c + "-"
}
if len(ignoreInvalid) > 0 && ignoreInvalid[0] {
url += "?ignore_invalid=1"
}
r, err := http.Get(url)

if err == nil {
Expand Down
21 changes: 21 additions & 0 deletions public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ func TestTicker(t *testing.T) {
})
})

Convey("Ticker data for BTC-USD and BTC-BTC", t, func() {
_, err := api.Ticker([]string{"btc_usd", "btc_btc"})

Convey("Error should occur", func() {
So(err, ShouldNotBeNil)
})
})

Convey("Ticker data for BTC-USD and BTC-BTC with the ignore invalid flag", t, func() {
tickers, err := api.Ticker([]string{"btc_usd", "btc_btc"}, true)

Convey("No error should occur", func() {
So(err, ShouldBeNil)
})

Convey("One ticker information should be returned", func() {
So(tickers, ShouldHaveSameTypeAs, Ticker{})
So(tickers, ShouldContainKey, "btc_usd")
So(tickers["btc_usd"], ShouldHaveSameTypeAs, TickerPair{})
})
})
}

func TestInfo(t *testing.T) {
Expand Down

0 comments on commit aa4e878

Please sign in to comment.