Skip to content

Commit

Permalink
Engine QA (thrasher-corp#381)
Browse files Browse the repository at this point in the history
* 1) Update Dockerfile/docker-compose.yml
2) Remove inline strings for buy/sell/test pairs
3) Remove dangerous order submission values
4) Fix consistency with audit_events (all other spec files use
CamelCase)
5) Update web websocket endpoint
6) Fix main param set (and induce dryrun mode on specific command line
params)

* Engine QA

Link up exchange syncer to cmd params, disarm market selling bombs and fix OKEX endpoints

* Fix linter issue after merge

* Engine QA changes

Template updates
Wrapper code cleanup
Disarmed order bombs
Documentation updates

* Daily engine QA

Bitstamp improvements
Spelling mistakes
Add Coinbene exchange to support list
Protect API authenticated calls for Coinbene/LBank

* Engine QA changes

Fix exchange_wrapper_coverage tool
Add SupportsAsset to exchange interface
Fix inline string usage and add BCH withdrawal support

* Engine QA

Fix Bitstamp types
Inform user of errors when parsing time accross the codebase
Change time parsing warnings to errors (as they are)
Update markdown docs [with linter fixes]

* Engine QA changes

1) Add test for dryrunParamInteraction
2) Disarm OKCoin/OKEX bombs if someone accidently sets canManipulateRealOrders to true and runs all package tests
3) Actually check exchange setup errors for BTSE and Coinbene, plus address this in the wrapper template
4) Hardcode missing/non-retrievable contributors and bump the contributors
5) Convert numbers/strings to meaningful types in Bitstamp and OKEX
6) If WS is supported for the exchange wrapper template, preset authWebsocketSupport var

* Fix the shadow people

* Link the SyncContinuously paramerino

* Also show SyncContinuously in engine.PrintSettings

* Address nitterinos and use correct filepath for logs

* Bitstamp: Extract ALL THE APM

* Fix additional nitterinos

* Fix time parsing error for Bittrex
  • Loading branch information
thrasher- authored Nov 22, 2019
1 parent 52e2686 commit 63191ce
Show file tree
Hide file tree
Showing 102 changed files with 3,581 additions and 1,848 deletions.
57 changes: 29 additions & 28 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In order to maintain a consistent style across the codebase, the following codin
- In line with gofmt, for loops and if statements don't require parenthesis.

Block style example:

```go
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)
Expand All @@ -38,51 +39,51 @@ func SendHTTPRequest(method, path string, headers map[string]string, body io.Rea
```

## Effective Go Guidelines
[CodeLingo](https://codelingo.io) automatically checks every pull request against the following guidelines from [Effective Go](https://golang.org/doc/effective_go.html).

[CodeLingo](https://codelingo.io) automatically checks every pull request against the following guidelines from [Effective Go](https://golang.org/doc/effective_go.html).

### Comment First Word as Subject

Doc comments work best as complete sentences, which allow a wide variety of automated presentations.
The first sentence should be a one-sentence summary that starts with the name being declared.


### Good Package Name
It's helpful if everyone using the package can use the same name
to refer to its contents, which implies that the package name should
be good: short, concise, evocative. By convention, packages are
given lower case, single-word names; there should be no need for
underscores or mixedCaps. Err on the side of brevity, since everyone
using your package will be typing that name. And don't worry about
collisions a priori. The package name is only the default name for
imports; it need not be unique across all source code, and in the
rare case of a collision the importing package can choose a different
name to use locally. In any case, confusion is rare because the file
name in the import determines just which package is being used.

It's helpful if everyone using the package can use the same name
to refer to its contents, which implies that the package name should
be good: short, concise, evocative. By convention, packages are
given lower case, single-word names; there should be no need for
underscores or mixedCaps. Err on the side of brevity, since everyone
using your package will be typing that name. And don't worry about
collisions a priori. The package name is only the default name for
imports; it need not be unique across all source code, and in the
rare case of a collision the importing package can choose a different
name to use locally. In any case, confusion is rare because the file
name in the import determines just which package is being used.

### Package Comment
Every package should have a package comment, a block comment preceding the package clause.
For multi-file packages, the package comment only needs to be present in one file, and any one will do.
The package comment should introduce the package and provide information relevant to the package as a
whole. It will appear first on the godoc page and should set up the detailed documentation that follows.

Every package should have a package comment, a block comment preceding the package clause.
For multi-file packages, the package comment only needs to be present in one file, and any one will do.
The package comment should introduce the package and provide information relevant to the package as a
whole. It will appear first on the godoc page and should set up the detailed documentation that follows.

### Single Method Interface Name
By convention, one-method interfaces are named by the method name plus an -er suffix

By convention, one-method interfaces are named by the method name plus an -er suffix
or similar modification to construct an agent noun: Reader, Writer, Formatter, CloseNotifier etc.

There are a number of such names and it's productive to honor them and the function names they capture.
Read, Write, Close, Flush, String and so on have canonical signatures and meanings. To avoid confusion,
don't give your method one of those names unless it has the same signature and meaning. Conversely,
if your type implements a method with the same meaning as a method on a well-known type, give it the
There are a number of such names and it's productive to honor them and the function names they capture.
Read, Write, Close, Flush, String and so on have canonical signatures and meanings. To avoid confusion,
don't give your method one of those names unless it has the same signature and meaning. Conversely,
if your type implements a method with the same meaning as a method on a well-known type, give it the
same name and signature; call your string-converter method String not ToString.


### Avoid Annotations in Comments

Comments do not need extra formatting such as banners of stars. The generated output
may not even be presented in a fixed-width font, so don't depend on spacing for alignment—godoc,
like gofmt, takes care of that. The comments are uninterpreted plain text, so HTML and other
annotations such as _this_ will reproduce verbatim and should not be used. One adjustment godoc
does do is to display indented text in a fixed-width font, suitable for program snippets.
may not even be presented in a fixed-width font, so don't depend on spacing for alignment—godoc,
like gofmt, takes care of that. The comments are uninterpreted plain text, so HTML and other
annotations such as _this_ will reproduce verbatim and should not be used. One adjustment godoc
does do is to display indented text in a fixed-width font, suitable for program snippets.
The package comment for the fmt package uses this to good effect.

6 changes: 5 additions & 1 deletion .github/CONTRIBUTING_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In order to maintain a consistent style across the codebase, the following codin
- In line with gofmt, for loops and if statements don't require parenthesis.

Block style example:

```go
func SendHTTPRequest(method, path string, headers map[string]string, body io.Reader) (string, error) {
result := strings.ToUpper(method)
Expand All @@ -38,9 +39,12 @@ func SendHTTPRequest(method, path string, headers map[string]string, body io.Rea
```

## Effective Go Guidelines

[CodeLingo](https://codelingo.io) automatically checks every pull request against the following guidelines from [Effective Go](https://golang.org/doc/effective_go.html).

{{range .}}

### {{.title}}

{{.body}}
{{end}}
{{end}}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Please provide detailed steps for reproducing the issue.

### Failure Logs

By default, GoCryptoTrader stores its `debug.log` file in `%APPDATA%\GoCryptoTrader` on Windows and `~/.gocryptotrader` on Linux/Unix/macOS. Raw text or a link to a pastebin type site is preferred.
By default and if file logging is enabled, GoCryptoTrader stores its `log.txt` file in `%APPDATA%\GoCryptoTrader\logs` on Windows and `~/.gocryptotrader/logs` on Linux/Unix/macOS. Raw text or a link to a pastebin type site is preferred.
22 changes: 11 additions & 11 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Description
# PR Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Please include a summary of the change, feature or issue which this pull request addresses. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Expand All @@ -13,22 +13,22 @@ Please delete options that are not relevant and add an `x` in `[]` as item is co
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?
## How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.

## Please also consider improving test coverage whilst working on a certain package
- [ ] go test ./... -race
- [ ] golangci-lint run
- [ ] Test X

- [ ] Test A
- [ ] Test B

# Checklist:
## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [ ] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally and on Travis with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Any dependent changes have been merged and published in downstream modules
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ermalguni | https://github.com/ermalguni
vadimzhukck | https://github.com/vadimzhukck
140am | https://github.com/140am
marcofranssen | https://github.com/marcofranssen
cranktakular | https://github.com/cranktakular
MadCozBadd | https://github.com/MadCozBadd
cranktakular | https://github.com/cranktakular
leilaes | https://github.com/leilaes
crackcomm | https://github.com/crackcomm
andreygrehov | https://github.com/andreygrehov
Expand All @@ -30,6 +30,7 @@ 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
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
FROM golang:1.12 as build
FROM golang:1.13 as build
WORKDIR /go/src/github.com/thrasher-corp/gocryptotrader
COPY . .
RUN GO111MODULE=on go mod vendor
RUN mv -vn config_example.json config.json \
&& GOARCH=386 GOOS=linux CGO_ENABLED=0 go build . \
&& mv gocryptotrader /go/bin/gocryptotrader
&& GOARCH=386 GOOS=linux go build . \
&& GOARCH=386 GOOS=linux go build ./cmd/gctcli \
&& mv gocryptotrader /go/bin/gocryptotrader \
&& mv gctcli /go/bin/gctcli

FROM alpine:latest
RUN apk update && apk add --no-cache ca-certificates
VOLUME /root/.gocryptotrader
RUN apk update && apk add --no-cache ca-certificates bash
COPY --from=build /go/bin/gocryptotrader /app/
COPY --from=build /go/bin/gctcli /app/
COPY --from=build /go/src/github.com/thrasher-corp/gocryptotrader/config.json /app/
EXPOSE 9050-9053
CMD ["/app/gocryptotrader"]
ENTRYPOINT [ "/app/gocryptotrader" ]
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@ Binaries will be published once the codebase reaches a stable condition.

|User|Contribution Amount|
|--|--|
| [thrasher-](https://github.com/thrasher-) | 548 |
| [thrasher-](https://github.com/thrasher-) | 551 |
| [shazbert](https://github.com/shazbert) | 176 |
| [gloriousCode](https://github.com/gloriousCode) | 155 |
| [xtda](https://github.com/xtda) | 18 |
| [ermalguni](https://github.com/ermalguni) | 14 |
| [vadimzhukck](https://github.com/vadimzhukck) | 10 |
| [140am](https://github.com/140am) | 8 |
| [marcofranssen](https://github.com/marcofranssen) | 8 |
| [MadCozBadd](https://github.com/MadCozBadd) | 6 |
| [cranktakular](https://github.com/cranktakular) | 5 |
| [MadCozBadd](https://github.com/MadCozBadd) | 3 |
| [leilaes](https://github.com/leilaes) | 3 |
| [crackcomm](https://github.com/crackcomm) | 3 |
| [andreygrehov](https://github.com/andreygrehov) | 2 |
Expand All @@ -168,8 +168,9 @@ Binaries will be published once the codebase reaches a stable condition.
| [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 |
| [zeldrinn](https://github.com/zeldrinn) | 1 |
38 changes: 38 additions & 0 deletions cmd/documentation/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,44 @@ func main() {
err)
}

// idoall's contributors were forked and merged, so his contributions
// aren't automatically retrievable
contributors = append(contributors, Contributor{
Login: "idoall",
URL: "https://github.com/idoall",
Contributions: 1,
})

// Github API missing contributors
missingAPIContributors := []Contributor{
{
Login: "mattkanwisher",
URL: "https://github.com/mattkanwisher",
Contributions: 1,
},
{
Login: "mKurrels",
URL: "https://github.com/mKurrels",
Contributions: 1,
},
{
Login: "m1kola",
URL: "https://github.com/m1kola",
Contributions: 1,
},
{
Login: "cavapoo2",
URL: "https://github.com/cavapoo2",
Contributions: 1,
},
{
Login: "zeldrinn",
URL: "https://github.com/zeldrinn",
Contributions: 1,
},
}
contributors = append(contributors, missingAPIContributors...)

if *verbose {
fmt.Println("Contributor List Fetched")
for i := range contributors {
Expand Down
6 changes: 3 additions & 3 deletions cmd/documentation/exchanges_templates/coinbene.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ main.go
```go
var c exchange.IBotExchange

for i := range bot.exchanges {
if bot.exchanges[i].GetName() == "Coinbene" {
c = bot.exchanges[i]
for i := range Bot.Exchanges {
if Bot.Exchanges[i].GetName() == "Coinbene" {
c = Bot.Exchanges[i]
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/documentation/exchanges_templates/lbank.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ main.go
```go
var l exchange.IBotExchange

for i := range bot.exchanges {
if bot.exchanges[i].GetName() == "Lbank" {
l = bot.exchanges[i]
for i := range Bot.Exchanges {
if Bot.Exchanges[i].GetName() == "Lbank" {
l = Bot.Exchanges[i]
}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := l.GetTickerPrice()
tick, err := l.FetchTicker()
if err != nil {
// Handle error
}

// Fetches current orderbook information
ob, err := l.GetOrderbookEx()
ob, err := l.FetchOrderbook()
if err != nil {
// Handle error
}
Expand Down
24 changes: 14 additions & 10 deletions cmd/exchange_template/exchange_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
packageReadme = "README.md"

exchangePackageLocation = "../../exchanges"
exchangeLocation = "../../exchange.go"
exchangeConfigPath = "../../testdata/configtest.json"
)

Expand All @@ -35,7 +34,6 @@ var (
exchangeWrapper string
exchangeMain string
exchangeReadme string
exchangeJSON string
)

type exchange struct {
Expand Down Expand Up @@ -119,17 +117,22 @@ func main() {
newExchConfig.Enabled = true
newExchConfig.API.Credentials.Key = "Key"
newExchConfig.API.Credentials.Secret = "Secret"

newExchConfig.CurrencyPairs = &currency.PairsManager{
AssetTypes: asset.Items{
asset.Spot,
},
UseGlobalFormat: true,
RequestFormat: &currency.PairFormat{
Uppercase: true,
},
ConfigFormat: &currency.PairFormat{
Uppercase: true,
},
}

configTestFile.Exchanges = append(configTestFile.Exchanges, newExchConfig)
// TODO sorting function so exchanges are in alphabetical order - low priority

err = configTestFile.SaveConfig(exchangeJSON, false)
err = configTestFile.SaveConfig(exchangeConfigPath, false)
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating configuration error - cannot save")
}
Expand Down Expand Up @@ -217,12 +220,13 @@ func main() {
}

fmt.Println("GoCryptoTrader: Exchange templating tool service complete")
fmt.Println("When wrapper is finished add exchange to exchange.go")
fmt.Println("Test exchange.go")
fmt.Println("Update the config_test.go file")
fmt.Println("Test config.go")
fmt.Println("When the exchange code implementation has been completed (REST/Websocket/wrappers and tests), please add the exchange to engine/exchange.go")
fmt.Println("Add the exchange config settings to config_example.json (it will automatically be added to testdata/configtest.json)")
fmt.Println("Increment the available exchanges counter in config/config_test.go")
fmt.Println("Add the exchange name to exchanges/support.go")
fmt.Println("Ensure go test ./... -race passes")
fmt.Println("Open a pull request")
fmt.Println("If help is needed please post a message on Slack.")
fmt.Println("If help is needed, please post a message in Slack.")
}

func newFile(path string) {
Expand Down
Loading

0 comments on commit 63191ce

Please sign in to comment.