Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
artlevitan committed Jan 21, 2023
1 parent 9ac6b03 commit ef1fe6c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 53 deletions.
112 changes: 59 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,87 @@
# go-tradingview-ta [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

An unofficial Go API simple wrapper to retrieve technical analysis from TradingView.

<img src="/editor/images/promo.jpg" alt="Go TradingView" style="max-width:100%">

### Predefined constants

```go
const (
// Intervals
Interval1min = "1min"
Interval5min = "5min"
Interval15min = "15min"
Interval30min = "30min"
Interval1hour = "1hour"
Interval2hour = "2hour"
Interval4hour = "4hour"
Interval1day = "1day"
Interval1week = "1week"
Interval1month = "1month"

// Result
SignalStrongBuy = 2 // STRONG_BUY
SignalBuy = 1 // BUY
SignalNeutral = 0 // NEUTRAL
SignalSell = -1 // SELL
SignalStrongSell = -2 // STRONG_SELL
// Intervals
Interval1min = "1min"
Interval5min = "5min"
Interval15min = "15min"
Interval30min = "30min"
Interval1hour = "1hour"
Interval2hour = "2hour"
Interval4hour = "4hour"
Interval1day = "1day"
Interval1week = "1week"
Interval1month = "1month"

// Result
SignalStrongBuy = 2 // STRONG_BUY
SignalBuy = 1 // BUY
SignalNeutral = 0 // NEUTRAL
SignalSell = -1 // SELL
SignalStrongSell = -2 // STRONG_SELL
)

```

## Example

```go
package main

import (
"fmt"
"fmt"

tradingview "github.com/artlevitan/go-tradingview-ta"
tradingview "github.com/artlevitan/go-tradingview-ta"
)

func main() {
var ta tradingview.TradingView
err := ta.Get("BINANCE:BTCUSDT", tradingview.Interval4hour)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v\n", ta) // Full Data

// Get the value by key
recSummary := ta.Recommend.Summary // Summary
fmt.Println(recSummary)

recOsc := ta.Recommend.Oscillators // Oscillators
fmt.Println(recOsc)

recMA := ta.Recommend.MA // Moving Averages
fmt.Println(recMA)

// Text recommendation
switch recSummary {
case tradingview.SignalStrongSell:
fmt.Println("STRONG_SELL")
case tradingview.SignalSell:
fmt.Println("SELL")
case tradingview.SignalNeutral:
fmt.Println("NEUTRAL")
case tradingview.SignalBuy:
fmt.Println("BUY")
case tradingview.SignalStrongBuy:
fmt.Println("STRONG_BUY")
default:
fmt.Println("An error has occurred")
}
var ta tradingview.TradingView
err := ta.Get("BINANCE:BTCUSDT", tradingview.Interval4hour)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%#v\n", ta) // Full Data

// Get the value by key
recSummary := ta.Recommend.Summary // Summary
fmt.Println(recSummary)

recOsc := ta.Recommend.Oscillators // Oscillators
fmt.Println(recOsc)

recMA := ta.Recommend.MA // Moving Averages
fmt.Println(recMA)

// Text recommendation
switch recSummary {
case tradingview.SignalStrongSell:
fmt.Println("STRONG_SELL")
case tradingview.SignalSell:
fmt.Println("SELL")
case tradingview.SignalNeutral:
fmt.Println("NEUTRAL")
case tradingview.SignalBuy:
fmt.Println("BUY")
case tradingview.SignalStrongBuy:
fmt.Println("STRONG_BUY")
default:
fmt.Println("An error has occurred")
}
}

```

## License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added editor/images/promo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ef1fe6c

Please sign in to comment.