Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8333e5c
tag optional sonic and allow full library conversion
Aug 20, 2024
c47137c
Add workflow and disallow arm and darwin usage
Aug 20, 2024
6e24f60
Add basic hotswap benchmark
Aug 20, 2024
b70b9e7
linter: fix
Aug 20, 2024
84dd409
use bash
Aug 20, 2024
711db77
linter: fix?
Aug 20, 2024
223f786
Fix whoopsie, add to make file, also add mention in features list.
Aug 20, 2024
9a72688
Merge branch 'master' into encoding_swap
Aug 24, 2024
2f69362
Merge branch 'master' into encoding_swap
Sep 2, 2024
79c85c9
Merge branch 'master' into encoding_swap
Sep 13, 2024
b4f0243
Merge branch 'master' into encoding_swap
Sep 13, 2024
417e0aa
Merge branch 'master' into encoding_swap
Sep 15, 2024
83f1d57
Merge branch 'master' into encoding_swap
Oct 2, 2024
f2d56cf
Merge branch 'master' into encoding_swap
Oct 10, 2024
7bd7cc4
Merge branch 'master' into encoding_swap
Oct 23, 2024
79ebfa1
Merge branch 'master' into encoding_swap
Nov 11, 2024
6b6fb5e
test enforcement
Nov 11, 2024
ac47cc6
actually read documentation see if this works
Nov 11, 2024
135e2b6
linter: fix
Nov 11, 2024
2d08549
Merge branch 'master' into encoding_swap
Nov 25, 2024
1a82764
Merge branch 'master' into encoding_swap
Jan 8, 2025
1ca8eaa
linter: fix
Jan 8, 2025
ab5fd01
sonic: bump tagged version
Jan 10, 2025
1697977
encoding/json: drop build tag arch and os filters
Jan 10, 2025
3905b62
encoding/json: consolidate tests
Jan 10, 2025
1c9f9c2
encoding/json: log build tag usage
Jan 10, 2025
4f8e487
Merge branch 'master' into encoding_swap
Jan 13, 2025
9cffc8f
rm superfluous builds
Jan 13, 2025
1b15e4c
glorious/nits: add template change and regen docs
Jan 28, 2025
a7ac15d
glorious/nits: update commentary on nolint directive
Jan 28, 2025
f23f3c3
glorious/nits: rm init func and log results in main.go
Jan 28, 2025
fba5316
Test to actually pull flag in
Jan 28, 2025
880cd37
Merge branch 'master' into encoding_swap
Feb 2, 2025
dde84c7
Merge branch 'master' into encoding_swap
Feb 11, 2025
c936252
linter: fix
Feb 11, 2025
a843b58
thrasher: nits
Feb 12, 2025
09bac6c
gk: nits 4 goflags goooooooooo!
Feb 13, 2025
a9ce5aa
gk: nits rn
Feb 14, 2025
625ae13
Merge branch 'master' into encoding_swap
Feb 19, 2025
9fff614
make sonic default json implementation
Feb 19, 2025
b8a5070
screen 386
Feb 19, 2025
9a52e19
linter: fix
Feb 20, 2025
9c154ca
Add commentary
Feb 20, 2025
ce01376
glorious: nits Makefile not working
Feb 20, 2025
fcc0b27
gk: nits
Feb 20, 2025
d49cf8e
gk: nits whoops
Feb 20, 2025
ad20589
whoopsirino
Feb 20, 2025
c1f1216
mention 32bit systems won't be sonic
Feb 20, 2025
00ebc20
gk: super-duper nit of extremes
Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,32 @@ jobs:
goarch: amd64
psql: true
skip_wrapper_tests: false
sonic: true
- os: ubuntu-latest
goarch: 386
psql: true
skip_wrapper_tests: true
sonic: true # sonic is disabled for 386 this ensures fall back to legacy code
- os: macos-latest
goarch: amd64
psql: true
skip_wrapper_tests: true
sonic: true
- os: macos-13 # beta
goarch: amd64
psql: true
skip_wrapper_tests: true
sonic: true
- os: windows-latest
goarch: amd64
psql: true
skip_wrapper_tests: true
sonic: true
- os: ubuntu-latest
goarch: amd64
psql: true
skip_wrapper_tests: false
sonic: false

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -84,6 +94,13 @@ jobs:
echo "CGO_ENABLED=1" >> $GITHUB_ENV
shell: bash

- name: Set GOFLAGS
run: |
if [ "${{ matrix.sonic }}" = "false" ]; then
echo "GOFLAGS=${GOFLAGS} -tags=sonic_off" >> $GITHUB_ENV
fi
shell: bash

- name: Test
run: | # PGSERVICEFILE isn't supported by lib/pq and will cause a panic if set
unset PGSERVICEFILE
Expand Down Expand Up @@ -169,4 +186,4 @@ jobs:
cd web/
npm install
npm run lint
npm run build
npm run build
14 changes: 12 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ linters:
- copyloopvar
# - cyclop
- decorder
# - depguard
- depguard
- dogsled
# - dupl
- dupword
Expand Down Expand Up @@ -117,6 +117,17 @@ linters:
# - zerologlint

linters-settings:
depguard:
rules:
prevent_json_package_use:
list-mode: lax # allow unless explicitely denied
files:
- $all
allow:
- github.com/thrasher-corp/gocryptotrader/encoding/json
deny:
- pkg: encoding/json
desc: "Please use the custom JSON package github.com/thrasher-corp/gocryptotrader/encoding/json instead of encoding/json to allow sonic/json switching."
govet:
enable:
- shadow
Expand All @@ -141,7 +152,6 @@ linters-settings:
- float-compare
# We deliberately use Equal over Len to avoid spamming the contents of large Slices
- len

issues:
max-issues-per-linter: 0
max-same-issues: 0
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ endef
check-jq:
@printf "Checking if jq is installed... "
@command -v jq >/dev/null 2>&1 && { printf "OK\n"; } || { printf "FAILED. Please install jq to proceed.\n"; exit 1; }

.PHONY: no_sonic
no_sonic:
go build $(LDFLAGS) -tags "sonic_off"
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,11 @@ When submitting a PR, please abide by our coding guidelines:
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md).
+ Pull requests need to be based on and opened against the `master` branch.

## Compiling instructions
## Compiling and Running instructions

Download and install Go from [Go Downloads](https://golang.org/dl/) for your
platform.
Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform.

### Linux/OSX

GoCryptoTrader is built using [Go Modules](https://github.com/golang/go/wiki/Modules) and requires Go 1.11 or above
Using Go Modules you now clone this repository **outside** your GOPATH
### Linux/macOS

```bash
git clone https://github.com/thrasher-corp/gocryptotrader.git
Expand All @@ -124,11 +120,18 @@ cp config_example.json ~/.gocryptotrader/config.json
git clone https://github.com/thrasher-corp/gocryptotrader.git
cd gocryptotrader
go build
mkdir %AppData%\GoCryptoTrader
copy config_example.json %APPDATA%\GoCryptoTrader\config.json
```

By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:

```bash
go build -tags=sonic_off
```

+ Make any necessary changes to the `config.json` file.
+ Run the `gocryptotrader` binary file inside your GOPATH bin folder.
+ Run the `gocryptotrader` binary file.

## Donations

Expand All @@ -149,10 +152,10 @@ Binaries will be published once the codebase reaches a stable condition.
|User|Contribution Amount|
|--|--|
| [thrasher-](https://github.com/thrasher-) | 704 |
| [shazbert](https://github.com/shazbert) | 358 |
| [shazbert](https://github.com/shazbert) | 359 |
| [dependabot[bot]](https://github.com/apps/dependabot) | 351 |
| [gloriousCode](https://github.com/gloriousCode) | 236 |
| [gbjk](https://github.com/gbjk) | 113 |
| [gbjk](https://github.com/gbjk) | 115 |
| [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 88 |
| [xtda](https://github.com/xtda) | 47 |
| [lrascao](https://github.com/lrascao) | 27 |
Expand Down
2 changes: 1 addition & 1 deletion backtester/btcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"encoding/json"
"fmt"
"log"
"os"
Expand All @@ -13,6 +12,7 @@ import (

"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/gctrpc/auth"
"github.com/thrasher-corp/gocryptotrader/signaler"
"github.com/urfave/cli/v2"
Expand Down
2 changes: 1 addition & 1 deletion backtester/config/backtesterconfig.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package config

import (
"encoding/json"
"fmt"
"os"
"path/filepath"

"github.com/thrasher-corp/gocryptotrader/backtester/common"
"github.com/thrasher-corp/gocryptotrader/common/file"
gctconfig "github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
)

// ReadBacktesterConfigFromPath will take a config from a path
Expand Down
2 changes: 1 addition & 1 deletion backtester/config/batcktesterconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package config

import (
"encoding/json"
"errors"
"path/filepath"
"testing"

"github.com/thrasher-corp/gocryptotrader/backtester/common"
"github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
)

func TestLoadBacktesterConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion backtester/config/strategyconfig.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"encoding/json"
"fmt"
"os"
"strings"
Expand All @@ -13,6 +12,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/backtester/eventhandlers/strategies/base"
gctcommon "github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/log"
)
Expand Down
2 changes: 1 addition & 1 deletion backtester/config/strategyconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"encoding/json"
"errors"
"os"
"path/filepath"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/database"
"github.com/thrasher-corp/gocryptotrader/database/drivers"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
Expand Down
2 changes: 1 addition & 1 deletion backtester/config/strategyconfigbuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bufio"
"encoding/json"
"errors"
"fmt"
"log"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/database"
dbPSQL "github.com/thrasher-corp/gocryptotrader/database/drivers/postgres"
dbsqlite3 "github.com/thrasher-corp/gocryptotrader/database/drivers/sqlite3"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
gctkline "github.com/thrasher-corp/gocryptotrader/exchanges/kline"
)
Expand Down
2 changes: 1 addition & 1 deletion backtester/eventhandlers/statistics/statistics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package statistics

import (
"encoding/json"
"fmt"
"time"

Expand All @@ -17,6 +16,7 @@ import (
gctcommon "github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/key"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/log"
)

Expand Down
2 changes: 1 addition & 1 deletion backtester/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"net/http"
Expand All @@ -15,6 +14,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/backtester/plugins/strategies"
"github.com/thrasher-corp/gocryptotrader/common/convert"
"github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/engine"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/signaler"
Expand Down
2 changes: 1 addition & 1 deletion cmd/apichecker/apicheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
Expand All @@ -18,6 +17,7 @@ import (

"github.com/thrasher-corp/gocryptotrader/common"
gctfile "github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/log"
Expand Down
2 changes: 1 addition & 1 deletion cmd/apichecker/apicheck_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
"encoding/json"
"os"
"reflect"
"testing"

gctfile "github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/log"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package main

import (
"context"
"encoding/json"
"log"
"sync"

"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/engine"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/documentation/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand Down
19 changes: 11 additions & 8 deletions cmd/documentation/root_templates/root_readme.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,11 @@ When submitting a PR, please abide by our coding guidelines:
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md).
+ Pull requests need to be based on and opened against the `master` branch.

## Compiling instructions
## Compiling and Running instructions

Download and install Go from [Go Downloads](https://golang.org/dl/) for your
platform.
Download and install Go from [Go Downloads](https://golang.org/dl/) for your platform.

### Linux/OSX

GoCryptoTrader is built using [Go Modules](https://github.com/golang/go/wiki/Modules) and requires Go 1.11 or above
Using Go Modules you now clone this repository **outside** your GOPATH
### Linux/macOS

```bash
git clone https://github.com/thrasher-corp/gocryptotrader.git
Expand All @@ -125,11 +121,18 @@ cp config_example.json ~/.gocryptotrader/config.json
git clone https://github.com/thrasher-corp/gocryptotrader.git
cd gocryptotrader
go build
mkdir %AppData%\GoCryptoTrader
copy config_example.json %APPDATA%\GoCryptoTrader\config.json
```

By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:

```bash
go build -tags=sonic_off
```

+ Make any necessary changes to the `config.json` file.
+ Run the `gocryptotrader` binary file inside your GOPATH bin folder.
+ Run the `gocryptotrader` binary file.

{{template "donations" .}}

Expand Down
4 changes: 2 additions & 2 deletions cmd/exchange_wrapper_issues/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/common/file"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/engine"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
Expand Down Expand Up @@ -1028,7 +1028,7 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, config *Config)
}

func jsonifyInterface(params []interface{}) json.RawMessage {
response, _ := json.MarshalIndent(params, "", " ") //nolint:errchkjson // TODO: ignore this for now
response, _ := json.MarshalIndent(params, "", " ")
return response
}

Expand Down
Loading
Loading