mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 07:26:47 +00:00
* Initial commit setting up a map orderbook system with a buffer. It will write to the buffer, sort apply to main orderbook and then process. * Moves namespaces again * Updates orderbook to use a sweet new WebsocketOrderbookUpdate type to handle all updates whether its using ID or not. So good. Adds many tests * Starting to implement orderbook update handling per exchange. Updates namespaces again. Hopefuylly will find a way to update via ID not timestamp, too many endpoints dont provide update timestamps * Changes orderbookbuffer to use BufferUpdate type instead of orderbook.Base to achieve more functionality and no need for type conversion functions. Updates tests * Updates all instances of ws.orderbook.Update. Simplifies some orderbook logic * Introduces toggleable buffer. Renames orderbooks. Completes implementation for everywhere but OKGroup due to hash calculation * Implements orderbook update for okgroup, but forgets about the orderbook hash checking * Fixes okgroup checksum calculation. Fixes linting issue. Removes redundant Kraken tests. * Introduces sorting toggle and separates from buffer toggle. Uses benchmarks to highlight performance gains * Fixes Gemini rate limit and parsing. Removes comments and fixes typos * Fixes bitfinex orderbook processing * Inbuilt sorting, minor fixes for websocket implementations. Improves test coverage * Adds surprise LakeBTC websocket support * Fixes data race * Fixes rebasing issues due to namespace movements * Addresses PR nits: moves folder namespace from ws to websocket. Removes line spaces in imports. Fixes lakebtc websocket returns and defer fucntions. Fixes comments * Adds poloniex orderook sorting support * Enables bitstamp and hitbtc orderbook sorting. Fixes poloniex's sorting * Renames namespaces and combines monitor and connection into wshandler. Removes unused SPOT const. Changes how orderbook stuff is loaded. It is done in startup with a setup. Removes exchange name from loadsnapshot as well * Removes the connection.go from rebasing issues. Removes error response from functions used in goroutines * Fixes test with exchange name output change * Fixes issues where copy and paste and replace all were used poorly
113 lines
3.9 KiB
Cheetah
113 lines
3.9 KiB
Cheetah
{{define "main"}}
|
|
package {{.Name}}
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/common"
|
|
"github.com/thrasher-corp/gocryptotrader/config"
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/wshandler"
|
|
log "github.com/thrasher-corp/gocryptotrader/logger"
|
|
)
|
|
|
|
// {{.CapitalName}} is the overarching type across this package
|
|
type {{.CapitalName}} struct {
|
|
exchange.Base
|
|
}
|
|
|
|
const (
|
|
{{.Name}}APIURL = ""
|
|
{{.Name}}APIVersion = ""
|
|
|
|
// Public endpoints
|
|
|
|
// Authenticated endpoints
|
|
|
|
)
|
|
|
|
// SetDefaults sets the basic defaults for {{.CapitalName}}
|
|
func ({{.Variable}} *{{.CapitalName}}) SetDefaults() {
|
|
{{.Variable}}.Name = "{{.CapitalName}}"
|
|
{{.Variable}}.Enabled = false
|
|
{{.Variable}}.Verbose = false
|
|
{{.Variable}}.RESTPollingDelay = 10
|
|
{{.Variable}}.RequestCurrencyPairFormat.Delimiter = ""
|
|
{{.Variable}}.RequestCurrencyPairFormat.Uppercase = true
|
|
{{.Variable}}.ConfigCurrencyPairFormat.Delimiter = ""
|
|
{{.Variable}}.ConfigCurrencyPairFormat.Uppercase = true
|
|
{{.Variable}}.AssetTypes = []string{ticker.Spot}
|
|
{{.Variable}}.SupportsAutoPairUpdating = false
|
|
{{.Variable}}.SupportsRESTTickerBatching = false
|
|
{{.Variable}}.Requester = request.New({{.Variable}}.Name,
|
|
request.NewRateLimit(time.Second, 0),
|
|
request.NewRateLimit(time.Second, 0),
|
|
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
|
{{.Variable}}.APIUrlDefault = {{.Name}}APIURL
|
|
{{.Variable}}.APIUrl = {{.Variable}}.APIUrlDefault
|
|
{{.Variable}}.Websocket = monitor.New()
|
|
{{.Variable}}.WebsocketResponseMaxLimit = exchange.DefaultWebsocketResponseMaxLimit
|
|
{{.Variable}}.WebsocketResponseCheckTimeout = exchange.DefaultWebsocketResponseCheckTimeout
|
|
}
|
|
|
|
// Setup takes in the supplied exchange configuration details and sets params
|
|
func ({{.Variable}} *{{.CapitalName}}) Setup(exch *config.ExchangeConfig) {
|
|
if !exch.Enabled {
|
|
{{.Variable}}.SetEnabled(false)
|
|
} else {
|
|
{{.Variable}}.Enabled = true
|
|
{{.Variable}}.AuthenticatedAPISupport = exch.AuthenticatedAPISupport
|
|
{{.Variable}}.AuthenticatedWebsocketAPISupport = exch.AuthenticatedWebsocketAPISupport
|
|
{{.Variable}}.SetAPIKeys(exch.APIKey, exch.APISecret, "", false)
|
|
{{.Variable}}.SetHTTPClientTimeout(exch.HTTPTimeout)
|
|
{{.Variable}}.SetHTTPClientUserAgent(exch.HTTPUserAgent)
|
|
{{.Variable}}.RESTPollingDelay = exch.RESTPollingDelay
|
|
{{.Variable}}.Verbose = exch.Verbose
|
|
{{.Variable}}.Websocket.SetWsStatusAndConnection(exch.Websocket)
|
|
{{.Variable}}.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
|
|
{{.Variable}}.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
|
|
{{.Variable}}.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
|
|
err := {{.Variable}}.SetCurrencyPairFormat()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
err = {{.Variable}}.SetAssetTypes()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
err = {{.Variable}}.SetAutoPairDefaults()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
err = {{.Variable}}.SetAPIURL(exch)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
err = {{.Variable}}.SetClientProxyAddress(exch.ProxyAddress)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// If the exchange supports websocket, update the below block
|
|
// err = {{.Variable}}.WebsocketSetup({{.Variable}}.WsConnect,
|
|
// exch.Name,
|
|
// exch.Websocket,
|
|
// {{.Name}}Websocket,
|
|
// exch.WebsocketURL)
|
|
// if err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
// {{.Variable}}.WebsocketConn = &wshandler.WebsocketConnection{
|
|
// ExchangeName: {{.Variable}}.Name,
|
|
// URL: {{.Variable}}.Websocket.GetWebsocketURL(),
|
|
// ProxyURL: {{.Variable}}.Websocket.GetProxyAddress(),
|
|
// Verbose: {{.Variable}}.Verbose,
|
|
// ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout,
|
|
// ResponseMaxLimit: exch.WebsocketResponseMaxLimit,
|
|
// }
|
|
}
|
|
}
|
|
{{end}}
|