mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
99 lines
3.1 KiB
Cheetah
99 lines
3.1 KiB
Cheetah
{{define "main"}}
|
|
package {{.Name}}
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/thrasher-/gocryptotrader/common"
|
|
"github.com/thrasher-/gocryptotrader/config"
|
|
"github.com/thrasher-/gocryptotrader/exchanges"
|
|
"github.com/thrasher-/gocryptotrader/exchanges/request"
|
|
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
|
|
)
|
|
|
|
// {{.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}}.RequestCurrencyPairFormat.Delimiter = ""
|
|
{{.Variable}}.RequestCurrencyPairFormat.Uppercase = true
|
|
{{.Variable}}.ConfigCurrencyPairFormat.Delimiter = ""
|
|
{{.Variable}}.ConfigCurrencyPairFormat.Uppercase = true
|
|
{{.Variable}}.AssetTypes = assets.AssetTypes{assets.AssetTypeSpot}
|
|
{{.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}}.API.Endpoints.URLDefault = {{.Name}}APIURL
|
|
{{.Variable}}.API.Endpoints.URL = {{.Variable}}.API.Endpoints.URLDefault
|
|
{{.Variable}}.WebsocketInit()
|
|
}
|
|
|
|
// Setup takes in the supplied exchange configuration details and sets params
|
|
func ({{.Variable}} *{{.CapitalName}}) Setup(exch *config.ExchangeConfig) error {
|
|
if !exch.Enabled {
|
|
{{.Variable}}.SetEnabled(false)
|
|
} else {
|
|
{{.Variable}}.Enabled = true
|
|
{{.Variable}}.API.AuthenticatedSupport = exch.API.AuthenticatedSupport
|
|
{{.Variable}}.SetAPIKeys(exch.API.Credentials.Key, exch.API.Credentials.Secret, "", false)
|
|
{{.Variable}}.SetHTTPClientTimeout(exch.HTTPTimeout)
|
|
{{.Variable}}.SetHTTPClientUserAgent(exch.HTTPUserAgent)
|
|
{{.Variable}}.Verbose = exch.Verbose
|
|
{{.Variable}}.Websocket.SetWsStatusAndConnection(exch.Features.Enabled.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}}.SetFeatureDefaults()
|
|
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.Features.Enabled.Websocket,
|
|
// {{.Name}}Websocket,
|
|
// exch.Features.Enabled.WebsocketURL)
|
|
// if err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
}
|
|
}
|
|
{{end}}
|