From 80b2136ce9c74a46ce423291bac0d6aa222cd6eb Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 2 Apr 2023 10:21:13 +1000 Subject: [PATCH] GCT: fix spelling (#1164) * kodespull * fix my spelling * silly sausage, rm sneaky pointer --- README.md | 8 +-- .../fx_currencyconverterapi.tmpl | 2 +- contrib/spellcheck/exclude_lines.txt | 1 + .../currencyconverterapi/README.md | 2 +- .../forexprovider/exchangerate.host/README.md | 2 +- .../exchangeratesapi.io/README.md | 2 +- currency/forexprovider/fixer.io/README.md | 2 +- engine/currency_state_manager.md | 72 +++++++++---------- exchanges/binance/binance_test.go | 6 +- exchanges/binanceus/binanceus_test.go | 6 +- exchanges/coinbasepro/coinbasepro_wrapper.go | 57 +++++++-------- exchanges/gemini/gemini.go | 2 +- exchanges/lbank/lbank_types.go | 2 +- exchanges/order/order_test.go | 38 +++++----- 14 files changed, 102 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 6d2e10e4..aacf9b4a 100644 --- a/README.md +++ b/README.md @@ -143,10 +143,10 @@ Binaries will be published once the codebase reaches a stable condition. |User|Contribution Amount| |--|--| -| [thrasher-](https://github.com/thrasher-) | 670 | -| [shazbert](https://github.com/shazbert) | 269 | -| [gloriousCode](https://github.com/gloriousCode) | 205 | -| [dependabot[bot]](https://github.com/apps/dependabot) | 139 | +| [thrasher-](https://github.com/thrasher-) | 675 | +| [shazbert](https://github.com/shazbert) | 273 | +| [gloriousCode](https://github.com/gloriousCode) | 208 | +| [dependabot[bot]](https://github.com/apps/dependabot) | 157 | | [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 88 | | [xtda](https://github.com/xtda) | 47 | | [lrascao](https://github.com/lrascao) | 27 | diff --git a/cmd/documentation/currency_templates/fx_currencyconverterapi.tmpl b/cmd/documentation/currency_templates/fx_currencyconverterapi.tmpl index a7b101bd..3bbf4c24 100644 --- a/cmd/documentation/currency_templates/fx_currencyconverterapi.tmpl +++ b/cmd/documentation/currency_templates/fx_currencyconverterapi.tmpl @@ -2,7 +2,7 @@ {{template "header" .}} ## Current Features for {{.Name}} -+ Fetches up to date curency data from [Currency Coverter API](https://free.currencyconverterapi.com/) ++ Fetches up to date curency data from [Currency Converter API](https://free.currencyconverterapi.com/) ### How to enable diff --git a/contrib/spellcheck/exclude_lines.txt b/contrib/spellcheck/exclude_lines.txt index 4185a4bf..075cc6ee 100644 --- a/contrib/spellcheck/exclude_lines.txt +++ b/contrib/spellcheck/exclude_lines.txt @@ -13,6 +13,7 @@ currency.HAV: 10, currency.GARD: 100, currency.DASHS: 0.01, + currency.ALIS: 0.05, const pressXToJSON = `[0,"bu",[4131.85,4131.85]]` wsTradeExecuted = "te" wsBalanceUpdate = "bu" diff --git a/currency/forexprovider/currencyconverterapi/README.md b/currency/forexprovider/currencyconverterapi/README.md index 88de0a4f..7f2d4d82 100644 --- a/currency/forexprovider/currencyconverterapi/README.md +++ b/currency/forexprovider/currencyconverterapi/README.md @@ -20,7 +20,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader ## Current Features for currencyconverterapi -+ Fetches up to date curency data from [Currency Coverter API](https://free.currencyconverterapi.com/) ++ Fetches up to date curency data from [Currency Converter API](https://free.currencyconverterapi.com/) ### How to enable diff --git a/currency/forexprovider/exchangerate.host/README.md b/currency/forexprovider/exchangerate.host/README.md index c5776881..a19597d4 100644 --- a/currency/forexprovider/exchangerate.host/README.md +++ b/currency/forexprovider/exchangerate.host/README.md @@ -1,4 +1,4 @@ -# GoCryptoTrader package Exchangerate.Host +# GoCryptoTrader package Exchangerate.host diff --git a/currency/forexprovider/exchangeratesapi.io/README.md b/currency/forexprovider/exchangeratesapi.io/README.md index 5e913a43..4c37dcea 100644 --- a/currency/forexprovider/exchangeratesapi.io/README.md +++ b/currency/forexprovider/exchangeratesapi.io/README.md @@ -1,4 +1,4 @@ -# GoCryptoTrader package Exchangeratesapi.Io +# GoCryptoTrader package Exchangeratesapi.io diff --git a/currency/forexprovider/fixer.io/README.md b/currency/forexprovider/fixer.io/README.md index a358488d..87651998 100644 --- a/currency/forexprovider/fixer.io/README.md +++ b/currency/forexprovider/fixer.io/README.md @@ -1,4 +1,4 @@ -# GoCryptoTrader package Fixer.Io +# GoCryptoTrader package Fixer.io diff --git a/engine/currency_state_manager.md b/engine/currency_state_manager.md index b3ec29aa..e84b08aa 100644 --- a/engine/currency_state_manager.md +++ b/engine/currency_state_manager.md @@ -1,22 +1,22 @@ -# GoCryptoTrader package Currency state manager - - - - -[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) -[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) -[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) -[![Coverage Status](http://codecov.io/github/thrasher-corp/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-corp/gocryptotrader?branch=master) -[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) - - -This currency_state_manager package is part of the GoCryptoTrader codebase. - -## This is still in active development - -You can track ideas, planned features and what's in progress on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader). - -Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) +# GoCryptoTrader package Currency state manager + + + + +[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml) +[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE) +[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager) +[![Coverage Status](http://codecov.io/github/thrasher-corp/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-corp/gocryptotrader?branch=master) +[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader) + + +This currency_state_manager package is part of the GoCryptoTrader codebase. + +## This is still in active development + +You can track ideas, planned features and what's in progress on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader). + +Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk) ## Current Features for Currency state manager + The state manager keeps currency states up to date, which include: @@ -27,22 +27,22 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader + This allows for an internal state check to compliment internal and external strategies. + +## Contribution + +Please feel free to submit any pull requests or suggest any desired features to be added. + +When submitting a PR, please abide by our coding guidelines: + ++ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). ++ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. ++ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). ++ Pull requests need to be based on and opened against the `master` branch. -## Contribution - -Please feel free to submit any pull requests or suggest any desired features to be added. - -When submitting a PR, please abide by our coding guidelines: - -+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). -+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines. -+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md). -+ Pull requests need to be based on and opened against the `master` branch. - -## Donations - - - -If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: - +## Donations + + + +If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to: + ***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc*** diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index a0949063..893680f7 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -2638,7 +2638,7 @@ func TestWsOrderExecutionReport(t *testing.T) { // cannot run in parallel due to inspecting the DataHandler result payload := []byte(`{"stream":"jTfvpakT2yT0hVIo5gYWVihZhdM2PrBgJUZ5PyfZ4EVpCkx4Uoxk5timcrQc","data":{"e":"executionReport","E":1616627567900,"s":"BTCUSDT","c":"c4wyKsIhoAaittTYlIVLqk","S":"BUY","o":"LIMIT","f":"GTC","q":"0.00028400","p":"52789.10000000","P":"0.00000000","F":"0.00000000","g":-1,"C":"","x":"NEW","X":"NEW","r":"NONE","i":5340845958,"l":"0.00000000","z":"0.00000000","L":"0.00000000","n":"0","N":"BTC","T":1616627567900,"t":-1,"I":11388173160,"w":true,"m":false,"M":false,"O":1616627567900,"Z":"0.00000000","Y":"0.00000000","Q":"0.00000000"}}`) // this is a buy BTC order, normally commission is charged in BTC, vice versa. - expRes := order.Detail{ + expectedResult := order.Detail{ Price: 52789.1, Amount: 0.00028400, AverageExecutedPrice: 0, @@ -2672,8 +2672,8 @@ func TestWsOrderExecutionReport(t *testing.T) { res := <-b.Websocket.DataHandler switch r := res.(type) { case *order.Detail: - if !reflect.DeepEqual(expRes, *r) { - t.Errorf("Results do not match:\nexpected: %v\nreceived: %v", expRes, *r) + if !reflect.DeepEqual(expectedResult, *r) { + t.Errorf("Results do not match:\nexpected: %v\nreceived: %v", expectedResult, *r) } default: t.Fatalf("expected type order.Detail, found %T", res) diff --git a/exchanges/binanceus/binanceus_test.go b/exchanges/binanceus/binanceus_test.go index ccc0bd54..daad9a14 100644 --- a/exchanges/binanceus/binanceus_test.go +++ b/exchanges/binanceus/binanceus_test.go @@ -1862,7 +1862,7 @@ func TestProcessUpdate(t *testing.T) { func TestWebsocketOrderExecutionReport(t *testing.T) { payload := []byte(`{"stream":"jTfvpakT2yT0hVIo5gYWVihZhdM2PrBgJUZ5PyfZ4EVpCkx4Uoxk5timcrQc","data":{"e":"executionReport","E":1616627567900,"s":"BTCUSDT","c":"c4wyKsIhoAaittTYlIVLqk","S":"BUY","o":"LIMIT","f":"GTC","q":"0.00028400","p":"52789.10000000","P":"0.00000000","F":"0.00000000","g":-1,"C":"","x":"NEW","X":"NEW","r":"NONE","i":5340845958,"l":"0.00000000","z":"0.00000000","L":"0.00000000","n":"0","N":"BTC","T":1616627567900,"t":-1,"I":11388173160,"w":true,"m":false,"M":false,"O":1616627567900,"Z":"0.00000000","Y":"0.00000000","Q":"0.00000000"}}`) - expRes := order.Detail{ + expectedResult := order.Detail{ Price: 52789.1, Amount: 0.00028400, RemainingAmount: 0.00028400, @@ -1889,8 +1889,8 @@ func TestWebsocketOrderExecutionReport(t *testing.T) { res := <-bi.Websocket.DataHandler switch r := res.(type) { case *order.Detail: - if !reflects.DeepEqual(expRes, *r) { - t.Errorf("Binanceus Results do not match:\nexpected: %v\nreceived: %v", expRes, *r) + if !reflects.DeepEqual(expectedResult, *r) { + t.Errorf("Binanceus Results do not match:\nexpected: %v\nreceived: %v", expectedResult, *r) } default: t.Fatalf("Binanceus expected type order.Detail, found %T", res) diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index b29d00b2..bacbac33 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -601,50 +601,51 @@ func (c *CoinbasePro) CancelAllOrders(ctx context.Context, _ *order.Cancel) (ord } // GetOrderInfo returns order information based on order ID -func (c *CoinbasePro) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (order.Detail, error) { - genOrderDetail, errGo := c.GetOrder(ctx, orderID) - if errGo != nil { - return order.Detail{}, fmt.Errorf("error retrieving order %s : %s", orderID, errGo) +func (c *CoinbasePro) GetOrderInfo(ctx context.Context, orderID string, _ currency.Pair, _ asset.Item) (order.Detail, error) { + genOrderDetail, err := c.GetOrder(ctx, orderID) + if err != nil { + return order.Detail{}, fmt.Errorf("error retrieving order %s : %w", orderID, err) } - os, errOs := order.StringToOrderStatus(genOrderDetail.Status) - if errOs != nil { - return order.Detail{}, fmt.Errorf("error parsing order status: %s", errOs) + orderStatus, err := order.StringToOrderStatus(genOrderDetail.Status) + if err != nil { + return order.Detail{}, fmt.Errorf("error parsing order status: %w", err) } - tt, errOt := order.StringToOrderType(genOrderDetail.Type) - if errOt != nil { - return order.Detail{}, fmt.Errorf("error parsing order type: %s", errOt) + orderType, err := order.StringToOrderType(genOrderDetail.Type) + if err != nil { + return order.Detail{}, fmt.Errorf("error parsing order type: %w", err) } - ss, errOss := order.StringToOrderSide(genOrderDetail.Side) - if errOss != nil { - return order.Detail{}, fmt.Errorf("error parsing order side: %s", errOss) + orderSide, err := order.StringToOrderSide(genOrderDetail.Side) + if err != nil { + return order.Detail{}, fmt.Errorf("error parsing order side: %w", err) } - p, errP := currency.NewPairDelimiter(genOrderDetail.ProductID, "-") - if errP != nil { - return order.Detail{}, fmt.Errorf("error parsing order side: %s", errP) + pair, err := currency.NewPairDelimiter(genOrderDetail.ProductID, "-") + if err != nil { + return order.Detail{}, fmt.Errorf("error parsing order side: %w", err) } response := order.Detail{ Exchange: c.GetName(), OrderID: genOrderDetail.ID, - Pair: p, - Side: ss, - Type: tt, + Pair: pair, + Side: orderSide, + Type: orderType, Date: genOrderDetail.DoneAt, - Status: os, + Status: orderStatus, Price: genOrderDetail.Price, Amount: genOrderDetail.Size, ExecutedAmount: genOrderDetail.FilledSize, RemainingAmount: genOrderDetail.Size - genOrderDetail.FilledSize, Fee: genOrderDetail.FillFees, } - fillResponse, errGF := c.GetFills(ctx, orderID, genOrderDetail.ProductID) - if errGF != nil { - return response, fmt.Errorf("error retrieving the order fills: %s", errGF) + fillResponse, err := c.GetFills(ctx, orderID, genOrderDetail.ProductID) + if err != nil { + return order.Detail{}, fmt.Errorf("error retrieving the order fills: %w", err) } for i := range fillResponse { - trSi, errTSi := order.StringToOrderSide(fillResponse[i].Side) - if errTSi != nil { - return response, fmt.Errorf("error parsing order Side: %s", errTSi) + var fillSide order.Side + fillSide, err = order.StringToOrderSide(fillResponse[i].Side) + if err != nil { + return order.Detail{}, fmt.Errorf("error parsing fill Side: %w", err) } response.Trades = append(response.Trades, order.TradeHistory{ Timestamp: fillResponse[i].CreatedAt, @@ -652,8 +653,8 @@ func (c *CoinbasePro) GetOrderInfo(ctx context.Context, orderID string, pair cur Price: fillResponse[i].Price, Amount: fillResponse[i].Size, Exchange: c.GetName(), - Type: tt, - Side: trSi, + Type: orderType, + Side: fillSide, Fee: fillResponse[i].Fee, }) } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index 85b8cdc3..eac92bfa 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -325,7 +325,7 @@ func (g *Gemini) WithdrawCrypto(ctx context.Context, address, currency string, a } // PostHeartbeat sends a maintenance heartbeat to the exchange for all heartbeat -// maintaned sessions +// maintained sessions func (g *Gemini) PostHeartbeat(ctx context.Context) (string, error) { type Response struct { Result string `json:"result"` diff --git a/exchanges/lbank/lbank_types.go b/exchanges/lbank/lbank_types.go index 897752c6..032bb0c5 100644 --- a/exchanges/lbank/lbank_types.go +++ b/exchanges/lbank/lbank_types.go @@ -24,7 +24,7 @@ type TickerResponse struct { Ticker Ticker `json:"ticker"` } -// MarketDepthResponse stores arrays for asks, bids and a timestamp for a currecy pair +// MarketDepthResponse stores arrays for asks, bids and a timestamp for a currency pair type MarketDepthResponse struct { ErrCapture `json:",omitempty"` Data struct { diff --git a/exchanges/order/order_test.go b/exchanges/order/order_test.go index 41e6b45d..499b02ba 100644 --- a/exchanges/order/order_test.go +++ b/exchanges/order/order_test.go @@ -1450,9 +1450,9 @@ func TestMatchFilter(t *testing.T) { } tests := map[int]struct { - f Filter - o Detail - expRes bool + f Filter + o Detail + expectedResult bool }{ 0: {filters[1], orders[1], true}, 1: {filters[1], orders[0], false}, @@ -1495,7 +1495,7 @@ func TestMatchFilter(t *testing.T) { } // specific tests for num, tt := range tests { - if tt.o.MatchFilter(&tt.f) != tt.expRes { + if tt.o.MatchFilter(&tt.f) != tt.expectedResult { t.Errorf("tests[%v] failed", num) } } @@ -1510,8 +1510,8 @@ func TestIsActive(t *testing.T) { } amountTests := map[int]struct { - o Detail - expRes bool + o Detail + expectedResult bool }{ 0: {orders[0], false}, 1: {orders[1], true}, @@ -1520,14 +1520,14 @@ func TestIsActive(t *testing.T) { } // specific tests for num, tt := range amountTests { - if tt.o.IsActive() != tt.expRes { + if tt.o.IsActive() != tt.expectedResult { t.Errorf("amountTests[%v] failed", num) } } statusTests := map[int]struct { - o Detail - expRes bool + o Detail + expectedResult bool }{ // For now force inactive on any status 0: {Detail{Amount: 1.0, ExecutedAmount: 0.0, Status: AnyStatus}, false}, @@ -1552,7 +1552,7 @@ func TestIsActive(t *testing.T) { } // specific tests for num, tt := range statusTests { - if tt.o.IsActive() != tt.expRes { + if tt.o.IsActive() != tt.expectedResult { t.Fatalf("statusTests[%v] failed", num) } } @@ -1579,8 +1579,8 @@ func TestIsInactive(t *testing.T) { } amountTests := map[int]struct { - o Detail - expRes bool + o Detail + expectedResult bool }{ 0: {orders[0], true}, 1: {orders[1], false}, @@ -1589,14 +1589,14 @@ func TestIsInactive(t *testing.T) { } // specific tests for num, tt := range amountTests { - if tt.o.IsInactive() != tt.expRes { + if tt.o.IsInactive() != tt.expectedResult { t.Errorf("amountTests[%v] failed", num) } } statusTests := map[int]struct { - o Detail - expRes bool + o Detail + expectedResult bool }{ // For now force inactive on any status 0: {Detail{Amount: 1.0, ExecutedAmount: 0.0, Status: AnyStatus}, true}, @@ -1621,7 +1621,7 @@ func TestIsInactive(t *testing.T) { } // specific tests for num, tt := range statusTests { - if tt.o.IsInactive() != tt.expRes { + if tt.o.IsInactive() != tt.expectedResult { t.Errorf("statusTests[%v] failed", num) } } @@ -1641,8 +1641,8 @@ func BenchmarkIsInactive(b *testing.B) { func TestIsOrderPlaced(t *testing.T) { t.Parallel() statusTests := map[int]struct { - o Detail - expRes bool + o Detail + expectedResult bool }{ 0: {Detail{Amount: 1.0, ExecutedAmount: 0.0, Status: AnyStatus}, false}, 1: {Detail{Amount: 1.0, ExecutedAmount: 0.0, Status: New}, true}, @@ -1669,7 +1669,7 @@ func TestIsOrderPlaced(t *testing.T) { tt := tt t.Run(fmt.Sprintf("TEST CASE: %d", num), func(t *testing.T) { t.Parallel() - if tt.o.WasOrderPlaced() != tt.expRes { + if tt.o.WasOrderPlaced() != tt.expectedResult { t.Errorf("statusTests[%v] failed", num) } })