script: implementation of error insertion on return (#986)

* exchanges/account: shift credentials to account package and segregate funds to keys

* merge: fixes

* linter: fix

* Update exchanges/account/account.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits + protection for string panic

* glorious_suggestion: add method for matching keys

* linter: fix tests

* account: add protected method for credentials minimizing access, display full account details to rpc.

* linter: spelling kweeeeeeen

* accounts/portfolio: clean/check portfolio code and quickly check balances from change. Add protected method for future matching.

* accounts: theres no point in pointerising everything

* linter: ok pointerise this then...

* exchanges: fix regression add in little notes.

* glorious: nits

* Update exchanges/account/credentials.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/account/credentials_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/account/credentials_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* gloriously: fix glorious glorious test gloriously

* script: initial implementation of error insertion on return

* script: make script context aware(ish) and update error handle in examples

* script: add tests

* script: add syntax highlighting to readme

* Update gctscript/vm/vm.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/vm/vm.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/examples/exchange/account_info.gct

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/examples/exchange/cancel_order.gct

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/examples/verbose.gct

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* rm: bros

* scripts: handle errors in examples when they are going to use the data after fetching

* linter: fix rides again

* SCOTT_SPELL_CHECK_LINTER: fix

* gctscript: fix tests

* glorious: niiiiiiiiiiiiits

* scriptmodules/gct: standardize runtime errors

* Update gctscript/modules/gct/exchange.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/exchange.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/exchange.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/exchange.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update gctscript/modules/gct/gct.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits/reverts

* go mod: tidy

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2022-08-17 14:18:53 +10:00
committed by GitHub
parent 68588560e3
commit e93ee83563
42 changed files with 1110 additions and 372 deletions

View File

@@ -6,7 +6,14 @@ atr := import("indicator/atr")
load := func() {
start := t.date(2017, 8 , 17, 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := atr.calculate(ohlcvData.candles, 14)
fmt.println(ret)

View File

@@ -6,7 +6,14 @@ bbands := import("indicator/bbands")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := bbands.calculate("close", ohlcvData.candles, 20, 2.0, 2.0, "sma")
fmt.println(ret)

View File

@@ -6,8 +6,20 @@ cc := import("indicator/correlationcoefficient")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvDataBTC := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
ohlcvDataETH := exch.ohlcv("binance", "ETH-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvDataBTC := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvDataBTC) {
// handle error
fmt.println(ohlcvDataBTC)
return
}
ohlcvDataETH := exch.ohlcv(ctx, "binance", "ETH-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvDataETH) {
// handle error
fmt.println(ohlcvDataETH)
return
}
ret := cc.calculate(ohlcvDataBTC.candles, ohlcvDataETH.candles, 20)
fmt.println(ret)
}

View File

@@ -7,8 +7,14 @@ ema := import("indicator/ema")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := ema.calculate(ohlcvData.candles, 9)
fmt.println(ret)

View File

@@ -6,8 +6,14 @@ macd := import("indicator/macd")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := macd.calculate(ohlcvData.candles, 12, 26, 9)
fmt.println(ret)
}

View File

@@ -6,7 +6,14 @@ mfi := import("indicator/mfi")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := mfi.calculate(ohlcvData.candles, 14)
fmt.println(ret)

View File

@@ -6,7 +6,14 @@ obv := import("indicator/obv")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := obv.calculate(ohlcvData.candles)
fmt.println(ret)

View File

@@ -6,7 +6,14 @@ rsi := import("indicator/rsi")
load := func() {
start := t.date(2017, 8 , 17 , 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// 'ctx' is already defined when we construct our bytecode from file.
// To add debugging information to the request, see verbose.gct. To add account credentials, see account.gct
ohlcvData := exch.ohlcv(ctx, "binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
if is_error(ohlcvData) {
// handle error
fmt.println(ohlcvData)
return
}
ret := rsi.calculate(ohlcvData.candles, 14)
fmt.println(ret)