### Install tradingview-scraper Go Module Source: https://github.com/verzth/tradingview-scraper/blob/main/README.md Instructions to install the tradingview-scraper Go module using `go get`. ```golang go get github.com/verzth/tradingview-scraper/v2@latest ``` -------------------------------- ### Connect to TradingView Socket with Callbacks Source: https://github.com/verzth/tradingview-scraper/blob/main/README.md Demonstrates how to establish a connection to the TradingView socket using the `Connect()` function. It requires two callback functions: one for handling new market data and another for error handling during the connection. ```golang import socket "github.com/verzth/tradingview-scraper/v2" func main() { tradingviewsocket, err := socket.Connect( func(symbol string, data *socket.QuoteData) { fmt.Printf("%#v", symbol) fmt.Printf("%#v", data) }, func(err error, context string) { fmt.Printf("%#v", "error -> "+err.Error()) fmt.Printf("%#v", "context -> "+context) }, ) if err != nil { panic("Error while initializing the trading view socket -> " + err.Error()) } } ``` -------------------------------- ### Handle TradingView Socket Market Data Callback Source: https://github.com/verzth/tradingview-scraper/blob/main/README.md Explains the structure of the `QuoteData` received in the market data callback, which includes `Price`, `Volume`, `Bid`, and `Ask`. It clarifies that not all parameters will always be available, and `nil` indicates no change for that specific parameter. ```golang callbackFn := func(symbol string, data *socket.QuoteData) { fmt.Printf("%#v", symbol) fmt.Printf("%#v", data) if data.Price != nil { fmt.Printf("%#v", "Price has changed") } if data.Volume != nil { fmt.Printf("%#v", "Volume has changed") } if data.Bid != nil { fmt.Printf("%#v", "Bid has changed") } if data.Ask != nil { fmt.Printf("%#v", "Ask has changed") } } ``` -------------------------------- ### Add Symbols to TradingView Socket for Real-time Data Source: https://github.com/verzth/tradingview-scraper/blob/main/README.md Shows how to subscribe to real-time market data for specific symbols using `AddSymbol()` after the socket connection is established. The symbol format is `broker or exchange name`:`market`. ```golang tradingviewsocket.AddSymbol("OANDA:EURUSD") tradingviewsocket.AddSymbol("BITSTAMP:BTCUSD") // etc etc ``` -------------------------------- ### Remove Symbols from TradingView Socket Source: https://github.com/verzth/tradingview-scraper/blob/main/README.md Illustrates how to stop receiving updates for a particular market by calling `RemoveSymbol()`. ```golang tradingviewsocket.RemoveSymbol("OANDA:EURUSD") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.