General engine improvements (#437)

* Add exchange manager to engine

* Several improvements for engine and friends

1) New file.Exists func
2) gRPC TLS cert expiration date check and regeneration
3) New donation var for use across the codebase
4) Use Go log package until the logger is initialised

* Add cert tests and create dir tree if it doesn't exist for file.Write

* Link up donation address to documentation tool plus minor adjustments

* Fix remaining donation addrs

* Move non-needed reload exchange funcs

* Revert accidental config_example.json changes 🕯️

* Use go logger for logging until the logger has initiliased, otherwise no output will be seen

* Link up portfolio delay val and other fixes

* Run go mod tidy after dependabot PR

* Address nitterinos
This commit is contained in:
Adrian Gallagher
2020-02-06 12:32:01 +11:00
committed by GitHub
parent 2e6ff1c398
commit b949388994
186 changed files with 922 additions and 604 deletions

View File

@@ -5,6 +5,7 @@ shazbert | https://github.com/shazbert
gloriousCode | https://github.com/gloriousCode
xtda | https://github.com/xtda
ermalguni | https://github.com/ermalguni
dependabot-preview[bot] | https://github.com/apps/dependabot-preview
vadimzhukck | https://github.com/vadimzhukck
140am | https://github.com/140am
marcofranssen | https://github.com/marcofranssen
@@ -14,6 +15,7 @@ crackcomm | https://github.com/crackcomm
andreygrehov | https://github.com/andreygrehov
bretep | https://github.com/bretep
woshidama323 | https://github.com/woshidama323
vazha | https://github.com/vazha
gam-phon | https://github.com/gam-phon
cornelk | https://github.com/cornelk
if1live | https://github.com/if1live
@@ -21,18 +23,19 @@ lozdog245 | https://github.com/lozdog245
soxipy | https://github.com/soxipy
herenow | https://github.com/herenow
blombard | https://github.com/blombard
Christian-Achilli | https://github.com/Christian-Achilli
CodeLingoBot | https://github.com/CodeLingoBot
CodeLingoTeam | https://github.com/CodeLingoTeam
Daanikus | https://github.com/Daanikus
daniel-cohen | https://github.com/daniel-cohen
DirectX | https://github.com/DirectX
frankzougc | https://github.com/frankzougc
starit | https://github.com/starit
Jimexist | https://github.com/Jimexist
lookfirst | https://github.com/lookfirst
idoall | https://github.com/idoall
mattkanwisher | https://github.com/mattkanwisher
mKurrels | https://github.com/mKurrels
m1kola | https://github.com/m1kola
cavapoo2 | https://github.com/cavapoo2
zeldrinn | https://github.com/zeldrinn
starit | https://github.com/starit
Jimexist | https://github.com/Jimexist
lookfirst | https://github.com/lookfirst

View File

@@ -58,7 +58,7 @@ We are aiming to support the top 20 highest volume exchanges based off the [Coin
+ REST API support for all exchanges.
+ Websocket support for applicable exchanges.
+ Ability to turn off/on certain exchanges.
+ Communication packages (Slack, SMS via SMSGlobal, Telegram and SMTP)
+ Communication packages (Slack, SMS via SMSGlobal, Telegram and SMTP).
+ HTTP rate limiter package.
+ Unified API for exchange usage.
+ Customisation of HTTP client features including setting a proxy, user agent and adjusting transport settings.
@@ -68,11 +68,11 @@ We are aiming to support the top 20 highest volume exchanges based off the [Coin
+ Connection monitor package.
+ gRPC service and JSON RPC proxy. See [gRPC service](/gctrpc/README.md).
+ gRPC client. See [gctcli](/cmd/gctcli/README.md).
+ Forex currency converter packages (CurrencyConverterAPI, CurrencyLayer, Fixer.io, OpenExchangeRates)
+ Forex currency converter packages (CurrencyConverterAPI, CurrencyLayer, Fixer.io, OpenExchangeRates).
+ Packages for handling currency pairs, tickers and orderbooks.
+ Portfolio management tool; fetches balances from supported exchanges and allows for custom address tracking.
+ Basic event trigger system.
+ Scripting support. See [gctscript](/gctscript/README.md)
+ Scripting support. See [gctscript](/gctscript/README.md).
+ WebGUI (discontinued).
## Planned Features
@@ -126,7 +126,7 @@ copy config_example.json %APPDATA%\GoCryptoTrader\config.json
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***
## Binaries
@@ -138,11 +138,12 @@ Binaries will be published once the codebase reaches a stable condition.
|User|Contribution Amount|
|--|--|
| [thrasher-](https://github.com/thrasher-) | 625 |
| [shazbert](https://github.com/shazbert) | 185 |
| [gloriousCode](https://github.com/gloriousCode) | 163 |
| [xtda](https://github.com/xtda) | 34 |
| [thrasher-](https://github.com/thrasher-) | 630 |
| [shazbert](https://github.com/shazbert) | 186 |
| [gloriousCode](https://github.com/gloriousCode) | 166 |
| [xtda](https://github.com/xtda) | 38 |
| [ermalguni](https://github.com/ermalguni) | 14 |
| [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 12 |
| [vadimzhukck](https://github.com/vadimzhukck) | 10 |
| [140am](https://github.com/140am) | 8 |
| [marcofranssen](https://github.com/marcofranssen) | 8 |
@@ -152,6 +153,7 @@ Binaries will be published once the codebase reaches a stable condition.
| [andreygrehov](https://github.com/andreygrehov) | 2 |
| [bretep](https://github.com/bretep) | 2 |
| [woshidama323](https://github.com/woshidama323) | 2 |
| [vazha](https://github.com/vazha) | 2 |
| [gam-phon](https://github.com/gam-phon) | 2 |
| [cornelk](https://github.com/cornelk) | 2 |
| [if1live](https://github.com/if1live) | 2 |
@@ -159,18 +161,19 @@ Binaries will be published once the codebase reaches a stable condition.
| [soxipy](https://github.com/soxipy) | 2 |
| [herenow](https://github.com/herenow) | 2 |
| [blombard](https://github.com/blombard) | 1 |
| [Christian-Achilli](https://github.com/Christian-Achilli) | 1 |
| [CodeLingoBot](https://github.com/CodeLingoBot) | 1 |
| [CodeLingoTeam](https://github.com/CodeLingoTeam) | 1 |
| [Daanikus](https://github.com/Daanikus) | 1 |
| [daniel-cohen](https://github.com/daniel-cohen) | 1 |
| [DirectX](https://github.com/DirectX) | 1 |
| [frankzougc](https://github.com/frankzougc) | 1 |
| [starit](https://github.com/starit) | 1 |
| [Jimexist](https://github.com/Jimexist) | 1 |
| [lookfirst](https://github.com/lookfirst) | 1 |
| [idoall](https://github.com/idoall) | 1 |
| [mattkanwisher](https://github.com/mattkanwisher) | 1 |
| [mKurrels](https://github.com/mKurrels) | 1 |
| [m1kola](https://github.com/m1kola) | 1 |
| [cavapoo2](https://github.com/cavapoo2) | 1 |
| [zeldrinn](https://github.com/zeldrinn) | 1 |
| [starit](https://github.com/starit) | 1 |
| [Jimexist](https://github.com/Jimexist) | 1 |
| [lookfirst](https://github.com/lookfirst) | 1 |

View File

@@ -31,14 +31,15 @@ func main() {
log.Println("Done.")
var cfgs []config.ExchangeConfig
for x := range engine.Bot.Exchanges {
exchanges := engine.GetExchanges()
for x := range exchanges {
var cfg *config.ExchangeConfig
cfg, err = engine.Bot.Exchanges[x].GetDefaultConfig()
cfg, err = exchanges[x].GetDefaultConfig()
if err != nil {
log.Printf("Failed to get exchanges default config. Err: %s", err)
continue
}
log.Printf("Adding %s", engine.Bot.Exchanges[x].GetName())
log.Printf("Adding %s", exchanges[x].GetName())
cfgs = append(cfgs, *cfg)
}

View File

@@ -94,4 +94,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -59,5 +59,5 @@ upper := strings.ToUpper(testString)
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -19,5 +19,5 @@ upper := strings.ToUpper(testString)
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -8,5 +8,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -22,5 +22,5 @@ for more details
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -51,5 +51,5 @@ via Slack:
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -41,5 +41,5 @@ err := s.Connect
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -43,5 +43,5 @@ err := s.Connect
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -51,5 +51,5 @@ via Telegram:
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -213,5 +213,5 @@ servers are configured by the pool array and attempted first to last allowedDiff
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -18,5 +18,5 @@ bitcoinString := newPair.GetFirstCurrency
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -10,5 +10,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -17,5 +17,5 @@ symbol := symbol.GetSymbolByCurrencyName(chineseYen)
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -16,5 +16,5 @@ b := translation.HasTranslation("BTC")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -9,5 +9,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -7,5 +7,5 @@ providers.
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -36,5 +36,5 @@ mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -36,5 +36,5 @@ mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -36,5 +36,5 @@ mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{- end}}

View File

@@ -36,5 +36,5 @@ mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -36,5 +36,5 @@ mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -100,11 +100,12 @@ type DocumentationDetails struct {
// Attributes defines specific documentation attributes when a template is
// executed
type Attributes struct {
Name string
Contributors []Contributor
NameURL string
Year int
CapitalName string
Name string
Contributors []Contributor
NameURL string
Year int
CapitalName string
DonationAddress string
}
func main() {
@@ -199,6 +200,21 @@ func main() {
URL: "https://github.com/zeldrinn",
Contributions: 1,
},
{
Login: "starit",
URL: "https://github.com/starit",
Contributions: 1,
},
{
Login: "Jimexist",
URL: "https://github.com/Jimexist",
Contributions: 1,
},
{
Login: "lookfirst",
URL: "https://github.com/lookfirst",
Contributions: 1,
},
}...)
if verbose {
@@ -378,11 +394,12 @@ func GetContributorList(repo string) ([]Contributor, error) {
// GetDocumentationAttributes returns specific attributes for a file template
func GetDocumentationAttributes(packageName string, contributors []Contributor) Attributes {
return Attributes{
Name: GetPackageName(packageName, false),
Contributors: contributors,
NameURL: GetGoDocURL(packageName),
Year: time.Now().Year(),
CapitalName: GetPackageName(packageName, true),
Name: GetPackageName(packageName, false),
Contributors: contributors,
NameURL: GetGoDocURL(packageName),
Year: time.Now().Year(),
CapitalName: GetPackageName(packageName, true),
DonationAddress: core.BitcoinDonationAddress,
}
}

View File

@@ -6,5 +6,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -10,5 +10,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -101,5 +101,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -95,5 +95,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -95,5 +95,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -37,5 +37,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -9,5 +9,5 @@ implementation
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -10,5 +10,5 @@ enabled exchanges i.e.
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -38,5 +38,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -101,5 +101,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -101,5 +101,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -95,5 +95,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -6,5 +6,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -9,5 +9,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -102,5 +102,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -7,5 +7,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -94,5 +94,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -101,5 +101,5 @@ if err != nil {
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -6,5 +6,5 @@
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -59,7 +59,7 @@ We are aiming to support the top 20 highest volume exchanges based off the [Coin
+ REST API support for all exchanges.
+ Websocket support for applicable exchanges.
+ Ability to turn off/on certain exchanges.
+ Communication packages (Slack, SMS via SMSGlobal, Telegram and SMTP)
+ Communication packages (Slack, SMS via SMSGlobal, Telegram and SMTP).
+ HTTP rate limiter package.
+ Unified API for exchange usage.
+ Customisation of HTTP client features including setting a proxy, user agent and adjusting transport settings.
@@ -69,10 +69,11 @@ We are aiming to support the top 20 highest volume exchanges based off the [Coin
+ Connection monitor package.
+ gRPC service and JSON RPC proxy. See [gRPC service](/gctrpc/README.md).
+ gRPC client. See [gctcli](/cmd/gctcli/README.md).
+ Forex currency converter packages (CurrencyConverterAPI, CurrencyLayer, Fixer.io, OpenExchangeRates)
+ Forex currency converter packages (CurrencyConverterAPI, CurrencyLayer, Fixer.io, OpenExchangeRates).
+ Packages for handling currency pairs, tickers and orderbooks.
+ Portfolio management tool; fetches balances from supported exchanges and allows for custom address tracking.
+ Basic event trigger system.
+ Scripting support. See [gctscript](/gctscript/README.md).
+ WebGUI (discontinued).
## Planned Features
@@ -120,13 +121,7 @@ copy config_example.json %APPDATA%\GoCryptoTrader\config.json
+ Make any neccessary changes to the `config.json` file.
+ Run the `gocryptotrader` binary file inside your GOPATH bin folder.
## Donations
<img src="https://github.com/thrasher-corp/gocryptotrader/blob/master/web/src/assets/donate.png?raw=true" hspace="70">
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
{{template "donations" .}}
## Binaries

View File

@@ -5,5 +5,5 @@
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***{{.DonationAddress}}***
{{- end}}

View File

@@ -6,5 +6,5 @@ This folder contains a configuration test file for non-deployement test params.
It also has the code coverage test files that allow us to monitor our entire
codebase, click this link for more information [https://codecov.io/](https://codecov.io/).
{{template "contributions"}}
{{template "donations" -}}
{{end}}
{{template "donations" .}}
{{- end}}

View File

@@ -16,5 +16,5 @@ go run ./config.go -infile path/of/config.json -outfile path/of/new/config.json
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -19,5 +19,5 @@ go run gocryptotrader.go -r
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -19,5 +19,5 @@ go run exchange_template.go -name Bitmex -ws -rest
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -16,5 +16,5 @@ go run main.go
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -14,5 +14,5 @@ go run portfolio.go -infile path/to/config.json -key AESDecryptionKey
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -12,5 +12,5 @@ This folder contains an assortment of tools.
Please see individual tool's README file
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -14,5 +14,5 @@ go run main.go
### Please click GoDocs chevron above to view current GoDoc information for this package
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -62,5 +62,5 @@ Voila! You can use your Angular + Electron app in a local development environmen
|Maxime GRIS|https://github.com/maximegris |Angular4 + Electron Base|
|Shazbert|https://github.com/shazbert |Initial designs|
{{template "contributions"}}
{{template "donations"}}
{{template "donations" .}}
{{end}}

View File

@@ -46,11 +46,12 @@ func main() {
log.Printf("Testing exchange wrappers..")
results := make(map[string][]string)
wg = sync.WaitGroup{}
for x := range engine.Bot.Exchanges {
exchanges := engine.GetExchanges()
for x := range exchanges {
wg.Add(1)
go func(num int) {
name := engine.Bot.Exchanges[num].GetName()
results[name] = testWrappers(engine.Bot.Exchanges[num])
name := exchanges[num].GetName()
results[name] = testWrappers(exchanges[num])
wg.Done()
}(x)
}

View File

@@ -88,8 +88,9 @@ func main() {
log.Println("Testing exchange wrappers..")
var exchangeResponses []ExchangeResponses
for x := range engine.Bot.Exchanges {
base := engine.Bot.Exchanges[x].GetBase()
exchs := engine.GetExchanges()
for x := range exchs {
base := exchs[x].GetBase()
if !base.Config.Enabled {
log.Printf("Exchange %v not enabled, skipping", base.GetName())
continue
@@ -101,13 +102,13 @@ func main() {
wg.Add(1)
go func(num int) {
name := engine.Bot.Exchanges[num].GetName()
name := exchs[num].GetName()
authenticated := setExchangeAPIKeys(name, wrapperConfig.Exchanges, base)
wrapperResult := ExchangeResponses{
ID: fmt.Sprintf("Exchange%v", num),
ExchangeName: name,
APIKeysSet: authenticated,
AssetPairResponses: testWrappers(engine.Bot.Exchanges[num], base, &wrapperConfig),
AssetPairResponses: testWrappers(exchs[num], base, &wrapperConfig),
}
for i := range wrapperResult.AssetPairResponses {
wrapperResult.ErrorCount += wrapperResult.AssetPairResponses[i].ErrorCount

View File

@@ -54,4 +54,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -63,5 +63,5 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -5,12 +5,19 @@ import (
"io"
"io/ioutil"
"os"
"path/filepath"
)
// Write writes selected data to a file or returns an error if it fails. This
// func also ensures that all files are set to this permission (only rw access
// for the running user and the group the user is a member of)
func Write(file string, data []byte) error {
basePath := filepath.Dir(file)
if !Exists(basePath) {
if err := os.MkdirAll(basePath, 0770); err != nil {
return err
}
}
return ioutil.WriteFile(file, data, 0770)
}
@@ -45,3 +52,9 @@ func Move(sourcePath, destPath string) error {
return os.Remove(sourcePath)
}
// Exists returns whether or not a file or path exists
func Exists(name string) bool {
_, err := os.Stat(name)
return !os.IsNotExist(err)
}

View File

@@ -26,7 +26,8 @@ func TestWrite(t *testing.T) {
}
var tests []testTable
testFile := filepath.Join(os.TempDir(), "gcttest.txt")
tempDir := filepath.Join(os.TempDir(), "gct-temp")
testFile := filepath.Join(tempDir, "gcttest.txt")
switch runtime.GOOS {
case "windows":
tests = []testTable{
@@ -46,6 +47,10 @@ func TestWrite(t *testing.T) {
t.Errorf("Test %d failed, unexpected err %s\n", x, err)
}
}
if err := os.RemoveAll(tempDir); err != nil {
t.Errorf("unable to remove temp test dir %s, manual deletion required", tempDir)
}
}
func TestMove(t *testing.T) {
@@ -104,3 +109,19 @@ func TestMove(t *testing.T) {
}
}
}
func TestExists(t *testing.T) {
if e := Exists("non-existent"); e {
t.Error("non-existent file should not exist")
}
tmpFile := filepath.Join(os.TempDir(), "gct-test.txt")
if err := ioutil.WriteFile(tmpFile, []byte("hello world"), os.ModeAppend); err != nil {
t.Fatal(err)
}
if e := Exists(tmpFile); !e {
t.Error("file should exist")
}
if err := os.Remove(tmpFile); err != nil {
t.Errorf("unable to remove %s, manual deletion is required", tmpFile)
}
}

View File

@@ -57,5 +57,5 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -43,4 +43,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -86,4 +86,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -76,4 +76,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -78,5 +78,5 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -86,4 +86,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -248,4 +248,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -8,7 +8,6 @@ import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strconv"
@@ -1336,11 +1335,9 @@ func (c *Config) CheckConnectionMonitorConfig() {
// Helpful for printing application usage
func DefaultFilePath() string {
f := filepath.Join(common.GetDefaultDataDir(runtime.GOOS), File)
_, err := os.Stat(f)
if os.IsNotExist(err) {
if !file.Exists(f) {
encFile := filepath.Join(common.GetDefaultDataDir(runtime.GOOS), EncryptedFile)
_, err = os.Stat(encFile)
if !os.IsNotExist(err) {
if file.Exists(encFile) {
return encFile
}
}
@@ -1390,12 +1387,10 @@ func GetFilePath(configfile string) (string, error) {
// First upgrade the old dir config file if it exists to the corresponding
// new one
for x := range oldDirs {
_, err := os.Stat(oldDirs[x])
if os.IsNotExist(err) {
if !file.Exists(oldDirs[x]) {
continue
}
_, err = os.Stat(newDirs[x])
if !os.IsNotExist(err) {
if file.Exists(newDirs[x]) {
log.Warnf(log.ConfigMgr,
"config.json file found in root dir and gct dir; cannot overwrite, defaulting to gct dir config.json at %s",
newDirs[x])
@@ -1424,8 +1419,7 @@ func GetFilePath(configfile string) (string, error) {
// Secondly check to see if the new config file extension is correct or not
for x := range newDirs {
_, err := os.Stat(newDirs[x])
if os.IsNotExist(err) {
if !file.Exists(newDirs[x]) {
continue
}

View File

@@ -9,10 +9,10 @@ import (
"errors"
"fmt"
"io"
"log"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/crypto"
log "github.com/thrasher-corp/gocryptotrader/logger"
"golang.org/x/crypto/scrypt"
)
@@ -35,7 +35,7 @@ var (
// PromptForConfigEncryption asks for encryption key
func (c *Config) PromptForConfigEncryption(configPath string, dryrun bool) bool {
fmt.Println("Would you like to encrypt your config file (y/n)?")
log.Println("Would you like to encrypt your config file (y/n)?")
input := ""
_, err := fmt.Scanln(&input)
@@ -47,7 +47,7 @@ func (c *Config) PromptForConfigEncryption(configPath string, dryrun bool) bool
c.EncryptConfig = fileEncryptionDisabled
err := c.SaveConfig(configPath, dryrun)
if err != nil {
log.Errorf(log.ConfigMgr, "cannot save config %s", err)
log.Printf("Cannot save config. Error: %s\n", err)
}
return false
}
@@ -59,7 +59,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
var cryptoKey []byte
for {
fmt.Println("Please enter in your password: ")
log.Println("Please enter in your password: ")
pwPrompt := func(i *[]byte) error {
_, err := fmt.Scanln(i)
return err
@@ -77,7 +77,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
}
var p2 []byte
fmt.Println("Please re-enter your password: ")
log.Println("Please re-enter your password: ")
err = pwPrompt(&p2)
if err != nil {
return nil, err
@@ -87,7 +87,7 @@ func PromptForConfigKey(initialSetup bool) ([]byte, error) {
cryptoKey = p1
break
}
fmt.Printf("Passwords did not match, please try again.")
log.Println("Passwords did not match, please try again.")
}
return cryptoKey, nil
}

4
core/donation.go Normal file
View File

@@ -0,0 +1,4 @@
package core
// BitcoinDonationAddress is the GoCryptoTrader BTC donation address
const BitcoinDonationAddress = "bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc"

View File

@@ -45,4 +45,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -44,4 +44,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -42,4 +42,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -71,4 +71,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -71,4 +71,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -71,4 +71,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -71,4 +71,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -71,4 +71,4 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -161,5 +161,5 @@ When submitting a PR, please abide by our coding guidelines:
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***

View File

@@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
"log"
"path/filepath"
"runtime"
"strings"
@@ -15,10 +16,9 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/currency/coinmarketcap"
"github.com/thrasher-corp/gocryptotrader/dispatch"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
gctscript "github.com/thrasher-corp/gocryptotrader/gctscript/vm"
log "github.com/thrasher-corp/gocryptotrader/logger"
gctlog "github.com/thrasher-corp/gocryptotrader/logger"
"github.com/thrasher-corp/gocryptotrader/portfolio"
"github.com/thrasher-corp/gocryptotrader/utils"
)
@@ -28,7 +28,6 @@ import (
type Engine struct {
Config *config.Config
Portfolio *portfolio.Base
Exchanges []exchange.IBotExchange
ExchangeCurrencyPairManager *ExchangeCurrencyPairSyncer
NTPManager ntpManager
ConnectionManager connectionManager
@@ -37,6 +36,7 @@ type Engine struct {
OrderManager orderManager
PortfolioManager portfolioManager
CommsManager commsManager
exchangeManager exchangeManager
DepositAddressManager *DepositAddressManager
Settings Settings
Uptime time.Time
@@ -77,7 +77,7 @@ func NewFromSettings(settings *Settings) (*Engine, error) {
return nil, err
}
log.Debugf(log.Global, "Loading config file %s..\n", filePath)
log.Printf("Loading config file %s..\n", filePath)
err = b.Config.LoadConfig(filePath, settings.EnableDryRun)
if err != nil {
return nil, fmt.Errorf("failed to load config. Err: %s", err)
@@ -89,8 +89,9 @@ func NewFromSettings(settings *Settings) (*Engine, error) {
}
if *b.Config.Logging.Enabled {
log.SetupGlobalLogger()
log.SetupSubLoggers(b.Config.Logging.SubLoggers)
gctlog.SetupGlobalLogger()
gctlog.SetupSubLoggers(b.Config.Logging.SubLoggers)
gctlog.Infoln(gctlog.Global, "Logger initialised.")
}
b.Settings.ConfigFile = filePath
@@ -114,12 +115,19 @@ func ValidateSettings(b *Engine, s *Settings) {
b.Settings.EnableDryRun = s.EnableDryRun
b.Settings.EnableAllExchanges = s.EnableAllExchanges
b.Settings.EnableAllPairs = s.EnableAllPairs
b.Settings.EnablePortfolioManager = s.EnablePortfolioManager
b.Settings.EnableCoinmarketcapAnalysis = s.EnableCoinmarketcapAnalysis
b.Settings.EnableDatabaseManager = s.EnableDatabaseManager
b.Settings.EnableGCTScriptManager = s.EnableGCTScriptManager
b.Settings.MaxVirtualMachines = s.MaxVirtualMachines
b.Settings.EnableDispatcher = s.EnableDispatcher
b.Settings.EnablePortfolioManager = s.EnablePortfolioManager
if b.Settings.EnablePortfolioManager {
if b.Settings.PortfolioManagerDelay != time.Duration(0) && s.PortfolioManagerDelay > 0 {
b.Settings.PortfolioManagerDelay = s.PortfolioManagerDelay
} else {
b.Settings.PortfolioManagerDelay = PortfolioSleepDelay
}
}
if flagSet["grpc"] {
b.Settings.EnableGRPC = s.EnableGRPC
@@ -226,64 +234,65 @@ func ValidateSettings(b *Engine, s *Settings) {
// PrintSettings returns the engine settings
func PrintSettings(s *Settings) {
log.Debugln(log.Global)
log.Debugf(log.Global, "ENGINE SETTINGS")
log.Debugf(log.Global, "- CORE SETTINGS:")
log.Debugf(log.Global, "\t Verbose mode: %v", s.Verbose)
log.Debugf(log.Global, "\t Enable dry run mode: %v", s.EnableDryRun)
log.Debugf(log.Global, "\t Enable all exchanges: %v", s.EnableAllExchanges)
log.Debugf(log.Global, "\t Enable all pairs: %v", s.EnableAllPairs)
log.Debugf(log.Global, "\t Enable coinmarketcap analaysis: %v", s.EnableCoinmarketcapAnalysis)
log.Debugf(log.Global, "\t Enable portfolio manager: %v", s.EnablePortfolioManager)
log.Debugf(log.Global, "\t Enable gPRC: %v", s.EnableGRPC)
log.Debugf(log.Global, "\t Enable gRPC Proxy: %v", s.EnableGRPCProxy)
log.Debugf(log.Global, "\t Enable websocket RPC: %v", s.EnableWebsocketRPC)
log.Debugf(log.Global, "\t Enable deprecated RPC: %v", s.EnableDeprecatedRPC)
log.Debugf(log.Global, "\t Enable comms relayer: %v", s.EnableCommsRelayer)
log.Debugf(log.Global, "\t Enable event manager: %v", s.EnableEventManager)
log.Debugf(log.Global, "\t Event manager sleep delay: %v", s.EventManagerDelay)
log.Debugf(log.Global, "\t Enable order manager: %v", s.EnableOrderManager)
log.Debugf(log.Global, "\t Enable exchange sync manager: %v", s.EnableExchangeSyncManager)
log.Debugf(log.Global, "\t Enable deposit address manager: %v\n", s.EnableDepositAddressManager)
log.Debugf(log.Global, "\t Enable websocket routine: %v\n", s.EnableWebsocketRoutine)
log.Debugf(log.Global, "\t Enable NTP client: %v", s.EnableNTPClient)
log.Debugf(log.Global, "\t Enable Database manager: %v", s.EnableDatabaseManager)
log.Debugf(log.Global, "\t Enable dispatcher: %v", s.EnableDispatcher)
log.Debugf(log.Global, "\t Dispatch package max worker amount: %d", s.DispatchMaxWorkerAmount)
log.Debugf(log.Global, "\t Dispatch package jobs limit: %d", s.DispatchJobsLimit)
log.Debugf(log.Global, "- EXCHANGE SYNCER SETTINGS:\n")
log.Debugf(log.Global, "\t Exchange sync continuously: %v\n", s.SyncContinuously)
log.Debugf(log.Global, "\t Exchange sync workers: %v\n", s.SyncWorkers)
log.Debugf(log.Global, "\t Enable ticker syncing: %v\n", s.EnableTickerSyncing)
log.Debugf(log.Global, "\t Enable orderbook syncing: %v\n", s.EnableOrderbookSyncing)
log.Debugf(log.Global, "\t Enable trade syncing: %v\n", s.EnableTradeSyncing)
log.Debugf(log.Global, "\t Exchange sync timeout: %v\n", s.SyncTimeout)
log.Debugf(log.Global, "- FOREX SETTINGS:")
log.Debugf(log.Global, "\t Enable currency conveter: %v", s.EnableCurrencyConverter)
log.Debugf(log.Global, "\t Enable currency layer: %v", s.EnableCurrencyLayer)
log.Debugf(log.Global, "\t Enable fixer: %v", s.EnableFixer)
log.Debugf(log.Global, "\t Enable OpenExchangeRates: %v", s.EnableOpenExchangeRates)
log.Debugf(log.Global, "- EXCHANGE SETTINGS:")
log.Debugf(log.Global, "\t Enable exchange auto pair updates: %v", s.EnableExchangeAutoPairUpdates)
log.Debugf(log.Global, "\t Disable all exchange auto pair updates: %v", s.DisableExchangeAutoPairUpdates)
log.Debugf(log.Global, "\t Enable exchange websocket support: %v", s.EnableExchangeWebsocketSupport)
log.Debugf(log.Global, "\t Enable exchange verbose mode: %v", s.EnableExchangeVerbose)
log.Debugf(log.Global, "\t Enable exchange HTTP rate limiter: %v", s.EnableExchangeHTTPRateLimiter)
log.Debugf(log.Global, "\t Enable exchange HTTP debugging: %v", s.EnableExchangeHTTPDebugging)
log.Debugf(log.Global, "\t Exchange max HTTP request jobs: %v", s.MaxHTTPRequestJobsLimit)
log.Debugf(log.Global, "\t Exchange HTTP request timeout retry amount: %v", s.RequestTimeoutRetryAttempts)
log.Debugf(log.Global, "\t Exchange HTTP timeout: %v", s.ExchangeHTTPTimeout)
log.Debugf(log.Global, "\t Exchange HTTP user agent: %v", s.ExchangeHTTPUserAgent)
log.Debugf(log.Global, "\t Exchange HTTP proxy: %v\n", s.ExchangeHTTPProxy)
log.Debugf(log.Global, "- GCTSCRIPT SETTINGS: ")
log.Debugf(log.Global, "\t Enable GCTScript manager: %v", s.EnableGCTScriptManager)
log.Debugf(log.Global, "\t GCTScript max virtual machines: %v", s.MaxVirtualMachines)
log.Debugf(log.Global, "- COMMON SETTINGS:")
log.Debugf(log.Global, "\t Global HTTP timeout: %v", s.GlobalHTTPTimeout)
log.Debugf(log.Global, "\t Global HTTP user agent: %v", s.GlobalHTTPUserAgent)
log.Debugf(log.Global, "\t Global HTTP proxy: %v", s.ExchangeHTTPProxy)
gctlog.Debugln(gctlog.Global)
gctlog.Debugf(gctlog.Global, "ENGINE SETTINGS")
gctlog.Debugf(gctlog.Global, "- CORE SETTINGS:")
gctlog.Debugf(gctlog.Global, "\t Verbose mode: %v", s.Verbose)
gctlog.Debugf(gctlog.Global, "\t Enable dry run mode: %v", s.EnableDryRun)
gctlog.Debugf(gctlog.Global, "\t Enable all exchanges: %v", s.EnableAllExchanges)
gctlog.Debugf(gctlog.Global, "\t Enable all pairs: %v", s.EnableAllPairs)
gctlog.Debugf(gctlog.Global, "\t Enable coinmarketcap analaysis: %v", s.EnableCoinmarketcapAnalysis)
gctlog.Debugf(gctlog.Global, "\t Enable portfolio manager: %v", s.EnablePortfolioManager)
gctlog.Debugf(gctlog.Global, "\t Portfolio manager sleep delay: %v\n", s.PortfolioManagerDelay)
gctlog.Debugf(gctlog.Global, "\t Enable gPRC: %v", s.EnableGRPC)
gctlog.Debugf(gctlog.Global, "\t Enable gRPC Proxy: %v", s.EnableGRPCProxy)
gctlog.Debugf(gctlog.Global, "\t Enable websocket RPC: %v", s.EnableWebsocketRPC)
gctlog.Debugf(gctlog.Global, "\t Enable deprecated RPC: %v", s.EnableDeprecatedRPC)
gctlog.Debugf(gctlog.Global, "\t Enable comms relayer: %v", s.EnableCommsRelayer)
gctlog.Debugf(gctlog.Global, "\t Enable event manager: %v", s.EnableEventManager)
gctlog.Debugf(gctlog.Global, "\t Event manager sleep delay: %v", s.EventManagerDelay)
gctlog.Debugf(gctlog.Global, "\t Enable order manager: %v", s.EnableOrderManager)
gctlog.Debugf(gctlog.Global, "\t Enable exchange sync manager: %v", s.EnableExchangeSyncManager)
gctlog.Debugf(gctlog.Global, "\t Enable deposit address manager: %v\n", s.EnableDepositAddressManager)
gctlog.Debugf(gctlog.Global, "\t Enable websocket routine: %v\n", s.EnableWebsocketRoutine)
gctlog.Debugf(gctlog.Global, "\t Enable NTP client: %v", s.EnableNTPClient)
gctlog.Debugf(gctlog.Global, "\t Enable Database manager: %v", s.EnableDatabaseManager)
gctlog.Debugf(gctlog.Global, "\t Enable dispatcher: %v", s.EnableDispatcher)
gctlog.Debugf(gctlog.Global, "\t Dispatch package max worker amount: %d", s.DispatchMaxWorkerAmount)
gctlog.Debugf(gctlog.Global, "\t Dispatch package jobs limit: %d", s.DispatchJobsLimit)
gctlog.Debugf(gctlog.Global, "- EXCHANGE SYNCER SETTINGS:\n")
gctlog.Debugf(gctlog.Global, "\t Exchange sync continuously: %v\n", s.SyncContinuously)
gctlog.Debugf(gctlog.Global, "\t Exchange sync workers: %v\n", s.SyncWorkers)
gctlog.Debugf(gctlog.Global, "\t Enable ticker syncing: %v\n", s.EnableTickerSyncing)
gctlog.Debugf(gctlog.Global, "\t Enable orderbook syncing: %v\n", s.EnableOrderbookSyncing)
gctlog.Debugf(gctlog.Global, "\t Enable trade syncing: %v\n", s.EnableTradeSyncing)
gctlog.Debugf(gctlog.Global, "\t Exchange sync timeout: %v\n", s.SyncTimeout)
gctlog.Debugf(gctlog.Global, "- FOREX SETTINGS:")
gctlog.Debugf(gctlog.Global, "\t Enable currency conveter: %v", s.EnableCurrencyConverter)
gctlog.Debugf(gctlog.Global, "\t Enable currency layer: %v", s.EnableCurrencyLayer)
gctlog.Debugf(gctlog.Global, "\t Enable fixer: %v", s.EnableFixer)
gctlog.Debugf(gctlog.Global, "\t Enable OpenExchangeRates: %v", s.EnableOpenExchangeRates)
gctlog.Debugf(gctlog.Global, "- EXCHANGE SETTINGS:")
gctlog.Debugf(gctlog.Global, "\t Enable exchange auto pair updates: %v", s.EnableExchangeAutoPairUpdates)
gctlog.Debugf(gctlog.Global, "\t Disable all exchange auto pair updates: %v", s.DisableExchangeAutoPairUpdates)
gctlog.Debugf(gctlog.Global, "\t Enable exchange websocket support: %v", s.EnableExchangeWebsocketSupport)
gctlog.Debugf(gctlog.Global, "\t Enable exchange verbose mode: %v", s.EnableExchangeVerbose)
gctlog.Debugf(gctlog.Global, "\t Enable exchange HTTP rate limiter: %v", s.EnableExchangeHTTPRateLimiter)
gctlog.Debugf(gctlog.Global, "\t Enable exchange HTTP debugging: %v", s.EnableExchangeHTTPDebugging)
gctlog.Debugf(gctlog.Global, "\t Exchange max HTTP request jobs: %v", s.MaxHTTPRequestJobsLimit)
gctlog.Debugf(gctlog.Global, "\t Exchange HTTP request timeout retry amount: %v", s.RequestTimeoutRetryAttempts)
gctlog.Debugf(gctlog.Global, "\t Exchange HTTP timeout: %v", s.ExchangeHTTPTimeout)
gctlog.Debugf(gctlog.Global, "\t Exchange HTTP user agent: %v", s.ExchangeHTTPUserAgent)
gctlog.Debugf(gctlog.Global, "\t Exchange HTTP proxy: %v\n", s.ExchangeHTTPProxy)
gctlog.Debugf(gctlog.Global, "- GCTSCRIPT SETTINGS: ")
gctlog.Debugf(gctlog.Global, "\t Enable GCTScript manager: %v", s.EnableGCTScriptManager)
gctlog.Debugf(gctlog.Global, "\t GCTScript max virtual machines: %v", s.MaxVirtualMachines)
gctlog.Debugf(gctlog.Global, "- COMMON SETTINGS:")
gctlog.Debugf(gctlog.Global, "\t Global HTTP timeout: %v", s.GlobalHTTPTimeout)
gctlog.Debugf(gctlog.Global, "\t Global HTTP user agent: %v", s.GlobalHTTPUserAgent)
gctlog.Debugf(gctlog.Global, "\t Global HTTP proxy: %v", s.ExchangeHTTPProxy)
log.Debugln(log.Global)
gctlog.Debugln(gctlog.Global)
}
// Start starts the engine
@@ -294,37 +303,37 @@ func (e *Engine) Start() error {
if e.Settings.EnableDatabaseManager {
if err := e.DatabaseManager.Start(); err != nil {
log.Errorf(log.Global, "Database manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "Database manager unable to start: %v", err)
}
}
if e.Settings.EnableDispatcher {
if err := dispatch.Start(e.Settings.DispatchMaxWorkerAmount, e.Settings.DispatchJobsLimit); err != nil {
log.Errorf(log.DispatchMgr, "Dispatcher unable to start: %v", err)
gctlog.Errorf(gctlog.DispatchMgr, "Dispatcher unable to start: %v", err)
}
}
// Sets up internet connectivity monitor
if e.Settings.EnableConnectivityMonitor {
if err := e.ConnectionManager.Start(); err != nil {
log.Errorf(log.Global, "Connection manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "Connection manager unable to start: %v", err)
}
}
if e.Settings.EnableNTPClient {
if err := e.NTPManager.Start(); err != nil {
log.Errorf(log.Global, "NTP manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "NTP manager unable to start: %v", err)
}
}
e.Uptime = time.Now()
log.Debugf(log.Global, "Bot '%s' started.\n", e.Config.Name)
log.Debugf(log.Global, "Using data dir: %s\n", e.Settings.DataDir)
gctlog.Debugf(gctlog.Global, "Bot '%s' started.\n", e.Config.Name)
gctlog.Debugf(gctlog.Global, "Using data dir: %s\n", e.Settings.DataDir)
if *e.Config.Logging.Enabled && strings.Contains(e.Config.Logging.Output, "file") {
log.Debugf(log.Global, "Using log file: %s\n",
filepath.Join(log.LogPath, e.Config.Logging.LoggerFileConfig.FileName))
gctlog.Debugf(gctlog.Global, "Using log file: %s\n",
filepath.Join(gctlog.LogPath, e.Config.Logging.LoggerFileConfig.FileName))
}
log.Debugf(log.Global,
gctlog.Debugf(gctlog.Global,
"Using %d out of %d logical processors for runtime performance\n",
runtime.GOMAXPROCS(-1), runtime.NumCPU())
@@ -333,24 +342,24 @@ func (e *Engine) Start() error {
enabledExchanges = len(e.Config.Exchanges)
}
log.Debugln(log.Global, "EXCHANGE COVERAGE")
log.Debugf(log.Global, "\t Available Exchanges: %d. Enabled Exchanges: %d.\n",
gctlog.Debugln(gctlog.Global, "EXCHANGE COVERAGE")
gctlog.Debugf(gctlog.Global, "\t Available Exchanges: %d. Enabled Exchanges: %d.\n",
len(e.Config.Exchanges), enabledExchanges)
if e.Settings.ExchangePurgeCredentials {
log.Debugln(log.Global, "Purging exchange API credentials.")
gctlog.Debugln(gctlog.Global, "Purging exchange API credentials.")
e.Config.PurgeExchangeAPICredentials()
}
log.Debugln(log.Global, "Setting up exchanges..")
gctlog.Debugln(gctlog.Global, "Setting up exchanges..")
SetupExchanges()
if len(Bot.Exchanges) == 0 {
if Bot.exchangeManager.Len() == 0 {
return errors.New("no exchanges are loaded")
}
if e.Settings.EnableCommsRelayer {
if err := e.CommsManager.Start(); err != nil {
log.Errorf(log.Global, "Communications manager unable to start: %v\n", err)
gctlog.Errorf(gctlog.Global, "Communications manager unable to start: %v\n", err)
}
}
@@ -377,7 +386,7 @@ func (e *Engine) Start() error {
e.Settings.DataDir,
e.Settings.Verbose)
if err != nil {
log.Errorf(log.Global, "currency updater system failed to start %v", err)
gctlog.Errorf(gctlog.Global, "Currency updater system failed to start %v", err)
}
if e.Settings.EnableGRPC {
@@ -395,7 +404,7 @@ func (e *Engine) Start() error {
if e.Settings.EnablePortfolioManager {
if err = e.PortfolioManager.Start(); err != nil {
log.Errorf(log.Global, "Fund manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "Fund manager unable to start: %v", err)
}
}
@@ -406,7 +415,7 @@ func (e *Engine) Start() error {
if e.Settings.EnableOrderManager {
if err = e.OrderManager.Start(); err != nil {
log.Errorf(log.Global, "Order manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "Order manager unable to start: %v", err)
}
}
@@ -423,7 +432,7 @@ func (e *Engine) Start() error {
e.ExchangeCurrencyPairManager, err = NewCurrencyPairSyncer(exchangeSyncCfg)
if err != nil {
log.Warnf(log.Global, "Unable to initialise exchange currency pair syncer. Err: %s", err)
gctlog.Warnf(gctlog.Global, "Unable to initialise exchange currency pair syncer. Err: %s", err)
} else {
go e.ExchangeCurrencyPairManager.Start()
}
@@ -440,7 +449,7 @@ func (e *Engine) Start() error {
if e.Settings.EnableGCTScriptManager {
if e.Config.GCTScript.Enabled {
if err := e.GctScriptManager.Start(); err != nil {
log.Errorf(log.Global, "GCTScript manager unable to start: %v", err)
gctlog.Errorf(gctlog.Global, "GCTScript manager unable to start: %v", err)
}
}
}
@@ -450,7 +459,7 @@ func (e *Engine) Start() error {
// Stop correctly shuts down engine saving configuration files
func (e *Engine) Stop() {
log.Debugln(log.Global, "Engine shutting down..")
gctlog.Debugln(gctlog.Global, "Engine shutting down..")
if len(portfolio.Portfolio.Addresses) != 0 {
e.Config.Portfolio = portfolio.Portfolio
@@ -458,64 +467,64 @@ func (e *Engine) Stop() {
if e.GctScriptManager.Started() {
if err := e.GctScriptManager.Stop(); err != nil {
log.Errorf(log.Global, "GCTScript manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "GCTScript manager unable to stop. Error: %v", err)
}
}
if e.OrderManager.Started() {
if err := e.OrderManager.Stop(); err != nil {
log.Errorf(log.Global, "Order manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "Order manager unable to stop. Error: %v", err)
}
}
if e.NTPManager.Started() {
if err := e.NTPManager.Stop(); err != nil {
log.Errorf(log.Global, "NTP manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "NTP manager unable to stop. Error: %v", err)
}
}
if e.CommsManager.Started() {
if err := e.CommsManager.Stop(); err != nil {
log.Errorf(log.Global, "Communication manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "Communication manager unable to stop. Error: %v", err)
}
}
if e.PortfolioManager.Started() {
if err := e.PortfolioManager.Stop(); err != nil {
log.Errorf(log.Global, "Fund manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "Fund manager unable to stop. Error: %v", err)
}
}
if e.ConnectionManager.Started() {
if err := e.ConnectionManager.Stop(); err != nil {
log.Errorf(log.Global, "Connection manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "Connection manager unable to stop. Error: %v", err)
}
}
if e.DatabaseManager.Started() {
if err := e.DatabaseManager.Stop(); err != nil {
log.Errorf(log.Global, "Database manager unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.Global, "Database manager unable to stop. Error: %v", err)
}
}
if dispatch.IsRunning() {
if err := dispatch.Stop(); err != nil {
log.Errorf(log.DispatchMgr, "Dispatch system unable to stop. Error: %v", err)
gctlog.Errorf(gctlog.DispatchMgr, "Dispatch system unable to stop. Error: %v", err)
}
}
if !e.Settings.EnableDryRun {
err := e.Config.SaveConfig(e.Settings.ConfigFile, false)
if err != nil {
log.Errorln(log.Global, "Unable to save config.")
gctlog.Errorln(gctlog.Global, "Unable to save config.")
} else {
log.Debugln(log.Global, "Config file saved successfully.")
gctlog.Debugln(gctlog.Global, "Config file saved successfully.")
}
}
// Wait for services to gracefully shutdown
e.ServicesWG.Wait()
err := log.CloseLogger()
err := gctlog.CloseLogger()
if err != nil {
fmt.Printf("Failed to close logger %v", err)
log.Printf("Failed to close logger. Error: %v\n", err)
}
}

View File

@@ -17,6 +17,7 @@ type Settings struct {
EnableAllPairs bool
EnableCoinmarketcapAnalysis bool
EnablePortfolioManager bool
PortfolioManagerDelay time.Duration
EnableGRPC bool
EnableGRPCProxy bool
EnableWebsocketRPC bool

Some files were not shown because too many files have changed in this diff Show More