Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
evsamsonov committed Aug 16, 2022
1 parent 7749a64 commit 93cfb1e
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/evsamsonov/trading-timeseries)](https://goreportcard.com/report/github.com/evsamsonov/trading-timeseries)
[![codecov](https://codecov.io/gh/evsamsonov/trading-timeseries/branch/master/graph/badge.svg?token=6HV8Z6ZAE0)](https://codecov.io/gh/evsamsonov/trading-timeseries)

Timeseries provides structure for series of trading candles.
Timeseries provides structures for trading candles series and tick series.

## Installation

Expand All @@ -14,40 +14,5 @@ $ go get github.com/evsamsonov/trading-timeseries
```

## Usage
[See documentation and examples](https://pkg.go.dev/github.com/evsamsonov/trading-timeseries)


```go
dataset := []struct {
Time time.Time
High float64
Low float64
Open float64
Close float64
Volume int64
}{
{Time: time.Unix(1, 0), High: 1, Low: 2, Open: 3, Close: 4, Volume: 5},
{Time: time.Unix(2, 0), High: 6, Low: 7, Open: 8, Close: 9, Volume: 10},
}

series := timeseries.New()
for _, item := range dataset {
candle := timeseries.NewCandle(item.Time)
candle.Open = item.Open
candle.Close = item.Close
candle.High = item.High
candle.Low = item.Low
candle.Volume = item.Volume

err := series.AddCandle(candle)
if err != nil {
log.Printf("Failed to add candle: %v\n", err)
}
}

fmt.Println(series.Candle(0)) // &{1970-01-01 03:00:01 +0300 MSK 1 2 3 4 5}
fmt.Println(series.LastCandle()) // &{1970-01-01 03:00:02 +0300 MSK 6 7 8 9 10}
fmt.Println(series.Length()) // 2
```

TODO
tickseries

0 comments on commit 93cfb1e

Please sign in to comment.