Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API: implement candlestick method #5

Closed
odeke-em opened this issue Aug 30, 2017 · 0 comments
Closed

REST API: implement candlestick method #5

odeke-em opened this issue Aug 30, 2017 · 0 comments

Comments

@odeke-em
Copy link
Member

A method to retrieve candlesticks as described at https://www.okcoin.com/rest_api.html#spapi
screen shot 2017-08-29 at 10 51 10 pm

odeke-em added a commit that referenced this issue Aug 30, 2017
Fixes #5

* Implements a method to get candlesticks with varying
criteria

Exhibit:
```go
package main

import (
	"fmt"
	"log"

	"github.com/orijtech/okcoin/v1"
)

func main() {
	client, err := okcoin.NewDefaultClient()
	if err != nil {
		log.Fatal(err)
	}

	cres, err := client.CandleStick(&okcoin.CandleStickRequest{
		Symbol: okcoin.ETHUSD,
		Period: okcoin.P5Min,
		Since:  1504068023.163283,
		N:      20,
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("CandleSticks for %s Period: %v\n\n", cres.Symbol, cres.Period)
	for i, cstick := range cres.CandleSticks {
		fmt.Printf("*%d %+v\n", i, cstick)
	}
}
```

which gives

```shell
CandleSticks for eth_usd Period: 5min

*0 &{TimeStampMs:1.5040626e+12 Open:398.02 High:398.15 Low:398.02
Close:398.02 Volume:0.152}
*1 &{TimeStampMs:1.5040629e+12 Open:398.02 High:398.02 Low:398.02
Close:398.02 Volume:0}
*2 &{TimeStampMs:1.5040632e+12 Open:398.02 High:398.02 Low:398.02
Close:398.02 Volume:0}
*3 &{TimeStampMs:1.5040635e+12 Open:398.02 High:398.25 Low:395.21
Close:398.25 Volume:5.652}
*4 &{TimeStampMs:1.5040638e+12 Open:395.21 High:398.25 Low:395.21
Close:397.81 Volume:3.768}
*5 &{TimeStampMs:1.5040641e+12 Open:397.81 High:397.81 Low:397.81
Close:397.81 Volume:0}
*6 &{TimeStampMs:1.5040644e+12 Open:395.31 High:397.81 Low:395.31
Close:395.36 Volume:12.696}
*7 &{TimeStampMs:1.5040647e+12 Open:395.08 High:395.36 Low:395 Close:395
Volume:17.156}
*8 &{TimeStampMs:1.504065e+12 Open:395 High:396.99 Low:395 Close:396.99
Volume:2.27}
*9 &{TimeStampMs:1.5040653e+12 Open:396.98 High:396.99 Low:396.89
Close:396.89 Volume:1.67}
*10 &{TimeStampMs:1.5040656e+12 Open:396.89 High:396.89 Low:396.89
Close:396.89 Volume:0}
*11 &{TimeStampMs:1.5040659e+12 Open:395.74 High:398 Low:395.74
Close:396.87 Volume:15.478}
*12 &{TimeStampMs:1.5040662e+12 Open:398.99 High:399.71 Low:398.99
Close:399.63 Volume:4.464}
*13 &{TimeStampMs:1.5040665e+12 Open:399.81 High:399.81 Low:399.81
Close:399.81 Volume:0.416}
*14 &{TimeStampMs:1.5040668e+12 Open:399.81 High:401.27 Low:399.69
Close:401.27 Volume:45.75}
*15 &{TimeStampMs:1.5040671e+12 Open:403.46 High:403.47 Low:403.46
Close:403.47 Volume:7.036}
*16 &{TimeStampMs:1.5040674e+12 Open:403.47 High:403.68 Low:403.47
Close:403.68 Volume:0.08}
*17 &{TimeStampMs:1.5040677e+12 Open:403.68 High:404.5 Low:403.68
Close:404.5 Volume:1.236}
*18 &{TimeStampMs:1.504068e+12 Open:404.49 High:404.5 Low:403
Close:404.47 Volume:11.646}
*19 &{TimeStampMs:1.5040683e+12 Open:404.47 High:404.47 Low:402
Close:402 Volume:13.068}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant