Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[codespell]
skip = ./.git,./web,./currency/code_types.go,*.json,*.sum,*.html,./vendor
skip = ./.git,./web,./currency/code_types.go,*.json,*.sum,*.html,./vendor,./contrib/spellcheck/codespell_custom_dictionary.txt
exclude-file = ./contrib/spellcheck/exclude_lines.txt
ignore-words = ./contrib/spellcheck/ignore_words.txt
ignore-regex = currency\.\w+
dictionary = ./contrib/spellcheck/codespell_custom_dictionary.txt,-
2 changes: 2 additions & 0 deletions .github/workflows/spell-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ jobs:
steps:
- uses: actions/checkout@v6
- uses: codespell-project/actions-codespell@master
with:
args: --dictionary=-,./contrib/spellcheck/codespell_custom_dictionary.txt
2 changes: 1 addition & 1 deletion cmd/documentation/exchanges_templates/orders.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Deletion of order
- Order tracking

+ For futures orders, this package also contains a futures position controller. It is responsible for tracking all futures orders that GoCryptoTrader processes. It keeps a running history of realised and unreaslied PNL to allow a trader to track their profits. Positions are closed once the exposure reaches zero, then upon a new futures order being processed, a new position is created. To view futures positions, see the GRPC command `getfuturesposition`
+ For futures orders, this package also contains a futures position controller. It is responsible for tracking all futures orders that GoCryptoTrader processes. It keeps a running history of realised and unrealised PNL to allow a trader to track their profits. Positions are closed once the exposure reaches zero, then upon a new futures order being processed, a new position is created. To view futures positions, see the GRPC command `getfuturesposition`

{{template "donations" .}}
{{end}}
10 changes: 5 additions & 5 deletions cmd/documentation/exchanges_templates/validate.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type Critical struct {
}

// define validation and add a variadic param
func (supercritcalinfo *Critical) Validate(opt ...validate.Checker) error {
func (superCriticalInfo *Critical) Validate(opt ...validate.Checker) error {
// define base level validation
if supercritcalinfo != nil {
if superCriticalInfo != nil {
// oh no this is nil, could panic program!
}

Expand All @@ -44,10 +44,10 @@ func (supercritcalinfo *Critical) Validate(opt ...validate.Checker) error {

// define an exchange or package level check that returns a validate.Checker
// interface
func (supercritcalinfo *Critical) PleaseDontSendMoneyToParents() validate.Checker {
func (superCriticalInfo *Critical) PleaseDontSendMoneyToParents() validate.Checker {
return validate.Check(func() error {
if supercritcalinfo.Person == "Mother Dearest" ||
supercritcalinfo.Person == "Father Dearest" {
if superCriticalInfo.Person == "Mother Dearest" ||
superCriticalInfo.Person == "Father Dearest" {
return errors.New("nope")
}
return nil
Expand Down
14 changes: 7 additions & 7 deletions cmd/gctcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,7 @@ var withdrawalRequestCommand = &cli.Command{
Usage: "withdrawal id",
},
},
Action: withdrawlRequestByID,
Action: withdrawalRequestByID,
},
{
Name: "byexchangeid",
Expand All @@ -2765,7 +2765,7 @@ var withdrawalRequestCommand = &cli.Command{
Usage: "withdrawal id",
},
},
Action: withdrawlRequestByExchangeID,
Action: withdrawalRequestByExchangeID,
},
{
Name: "byexchange",
Expand All @@ -2789,7 +2789,7 @@ var withdrawalRequestCommand = &cli.Command{
Usage: "the asset type of the currency pair",
},
},
Action: withdrawlRequestByExchangeID,
Action: withdrawalRequestByExchangeID,
},
{
Name: "bydate",
Expand Down Expand Up @@ -2817,12 +2817,12 @@ var withdrawalRequestCommand = &cli.Command{
Usage: "max number of withdrawals to return",
},
},
Action: withdrawlRequestByDate,
Action: withdrawalRequestByDate,
},
},
}

func withdrawlRequestByID(c *cli.Context) error {
func withdrawalRequestByID(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowSubcommandHelp(c)
}
Expand Down Expand Up @@ -2858,7 +2858,7 @@ func withdrawlRequestByID(c *cli.Context) error {
return nil
}

func withdrawlRequestByExchangeID(c *cli.Context) error {
func withdrawalRequestByExchangeID(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowSubcommandHelp(c)
}
Expand Down Expand Up @@ -2935,7 +2935,7 @@ func withdrawlRequestByExchangeID(c *cli.Context) error {
return nil
}

func withdrawlRequestByDate(c *cli.Context) error {
func withdrawalRequestByDate(c *cli.Context) error {
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowSubcommandHelp(c)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gctcli/websocket_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var websocketManagerCommand = &cli.Command{
},
&cli.StringFlag{
Name: "proxy",
Usage: "proxy address to change to, if proxy string is not set, this will stop the utilization of the prior set proxy.",
Usage: "proxy address to change to, if proxy string is not set, this will stop the utilisation of the prior set proxy.",
},
},
Action: setProxy,
Expand Down
2 changes: 1 addition & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NilGuard(ptrs ...any) (errs error) {
Obviously can't compare to nil, since the types won't match, so we look into the interface
eface is the internal representation of any; e(mpty-inter)face
See: https://cs.opensource.google/go/go/+/refs/tags/go1.24.1:src/runtime/runtime2.go;l=184-187
We optimize here by converting to [2]uintptr and just checking the address, instead of casting to a local eface type
We optimise here by converting to [2]uintptr and just checking the address, instead of casting to a local eface type
*/
if (*[2]uintptr)(unsafe.Pointer(&p))[1] == 0 {
errs = AppendError(errs, fmt.Errorf("%w: %T", ErrNilPointer, p))
Expand Down
64 changes: 64 additions & 0 deletions contrib/spellcheck/codespell_custom_dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
accetable->acceptable
adresstag->addresstag
affilate->affiliate
authentecated->authenticated
behavior->behaviour
bifinex->bitfinex
canceled->cancelled
candlesctick->candlestick
critcalbankingstuff->criticalbankingstuff
crypo->crypto
cummulative->cumulative
curency->currency
customize->customise
customized->customised
customizes->customises
decerialize->deserialise
decerialized->deserialised
decerializing->deserialising
deserialize->deserialise
deserialized->deserialised
deserializes->deserialises
deserializing->deserialising
favor->favour
generalized->generalised
indivudal->individual
lenging->lending
liquidiation->liquidation
minimize->minimise
minimized->minimised
minimizes->minimises
mmethod->method
openinig->opening
optimize->optimise
optimized->optimised
optimization->optimisation
optimizes->optimises
organize->organise
organized->organised
overrided->overridden
recieve->receive
referal->referral
relationl->relational
retrive->retrieve
serialize->serialise
serialized->serialised
serializes->serialises
serializing->serialising
serparated->separated
snapshooooot->snapshot
sream->stream
suabccount->subaccount
subrcribe->subscribe
summarize->summarise
summarized->summarised
supercritcalinfo->superCriticalInfo
susbsytems->subsystems
umarshal->unmarshal
unreaslied->unrealised
utilize->utilise
utilized->utilised
utilization->utilisation
utilizing->utilising
withdaw->withdraw
withdrawl->withdrawal
38 changes: 38 additions & 0 deletions contrib/spellcheck/exclude_lines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,41 @@
currency.SHFT: 84,
TotalIn float64 `json:"totalIn"`
TotalIn int64 `json:"totalIn"`
behavior: default
loanCustomiseMarginCall = "/sapi/v1/loan/customize/margin_call"
assert.ErrorIs(t, b.StartPortfolioWatcher(ctx, 0), context.Canceled, "StartPortfolioWatcher should return context.Canceled")
assert.ErrorIs(t, <-doneCh, context.Canceled, "StartPortfolioWatcher should return a context cancelled error")
{Case: "CANCELED", Result: order.Cancelled},
case "CANCELED":
if algoOrderID == "" && !slices.Contains([]string{"effective", "order_failed", "canceled"}, state) {
// GetCompletedSpreadOrdersLast7Days retrieve the completed order data for the last 7 days, and the incomplete orders (filledSz =0 & state = canceled) that have been cancelled are only reserved for 2 hours. Results are returned in counter chronological order
"70200": errors.New("the RFQ with {0} status cannot be canceled"),
"70400": errors.New("the quote with {0} status cannot be canceled"),
"58220": errors.New("the withdrawal order is already canceled"),
"51401": errors.New("cancellation failed as the order is already canceled"),
"51406": errors.New("canceled - order count exceeds the limit {0}"),
"51509": errors.New("modification failed as the order has been canceled"),
result, err := e.GetCompletedSpreadOrdersLast7Days(contextGenerate(), "", "limit", "canceled", "", "", time.Time{}, time.Time{}, 10)
{Case: "canceled", Result: order.Cancelled},
case "canceled":
states := "partial-canceled,filled,canceled"
require.ErrorIs(t, err, context.Canceled)
case "CANCELED", "CANCELLED":
"status": "canceled",
"reportType": "canceled"
Status string `json:"status"` // new, suspended, partiallyFilled, filled, canceled, expired
case "replaced", "canceled", "new":
o.Status = strings.Replace(o.Status, "canceled", "cancelled", 1)
if resp[i].Status != "canceled" {
"CANCELED": order.Cancelled,
Status: "CANCELED",
case PartiallyCancelled.String(), "PARTIAL-CANCELED", "PARTIALLY CANCELLED", "ORDER_PARTIALLY_TRANSACTED":
case Cancelled.String(), "CANCELED", "ORDER_CANCELLED":
assert.ErrorIs(t, err, context.Canceled, "should return correct error when context is cancelled")
require.ErrorIs(t, err, context.Canceled, "must return error when context is cancelled")
Type string `json:"type"` // Message Type: "open", "match", "filled", "canceled", "update"
case "partial-canceled":
{Case: "partial-canceled", Result: order.PartiallyCancelled},
withdrawal := []byte(`[13293039,"ETH","ETHEREUM",null,null,1574175052000,1574181326000,null,null,"CANCELED",null,null,-0.24,-0.00135,null,null,"DESTINATION_ADDRESS",null,null,null,"TRANSACTION_ID","Purchase of 100 pizzas"]`)
pressXToJSON = `[0,"oc",[34930659963,null,1574955083558,"tETHUSD",1574955083558,1574955354487,0.201104,0.201104,"EXCHANGE LIMIT",null,null,null,0,"CANCELED",null,null,120,0,0,0,null,null,null,0,0,null,null,null,"BFX",null,null,null]]`
"Quotes": `{"arg": {"channel":"quotes"},"data":[{"validUntil":"1608997227854","uTime":"1608267227834","cTime":"1608267227834","legs":[{"px":"0.0023","sz":"25.0","instId":"BTC-USD-220114-25000-C","side":"sell","tgtCcy":""},{"px":"0.0045","sz":"25","instId":"BTC-USD-220114-35000-C","side":"buy","tgtCcy":""}],"quoteId":"25092","rfqId":"18753","traderCode":"SATS","quoteSide":"sell","state":"canceled","clQuoteId":""}]}`,
2 changes: 1 addition & 1 deletion contrib/spellcheck/ignore_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ prevend
flate
zar
insid
totalin
totalin
2 changes: 1 addition & 1 deletion currency/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (c Code) Upper() Code {
return c
}

// UnmarshalJSON conforms type to the umarshaler interface
// UnmarshalJSON conforms type to the unmarshaler interface
func (c *Code) UnmarshalJSON(d []byte) error {
var newcode string
err := json.Unmarshal(d, &newcode)
Expand Down
4 changes: 2 additions & 2 deletions currency/coinmarketcap/coinmarketcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func (c *Coinmarketcap) GetExchangeInfo(exchangeID ...int64) (ExchangeInfo, erro

// GetExchangeMap returns a paginated list of all cryptocurrency exchanges by
// CoinMarketCap ID. Recommend using this convenience endpoint to lookup and
// utilize the unique exchange id across all endpoints as typical exchange
// utilise the unique exchange id across all endpoints as typical exchange
// identifiers may change over time. ie huobi -> hadax -> global -> who knows
// what else
//
Expand Down Expand Up @@ -704,7 +704,7 @@ func (c *Coinmarketcap) SendHTTPRequest(method, endpoint string, v url.Values, r
}

// CheckAccountPlan checks your current account plan to the minimal account
// needed to send http request, this is used to minimize requests for lower
// needed to send http request, this is used to minimise requests for lower
// account privileges
func (c *Coinmarketcap) CheckAccountPlan(minAllowable uint8) error {
if c.Plan < minAllowable {
Expand Down
4 changes: 2 additions & 2 deletions currency/currencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func (c Currencies) Contains(check Code) bool {
return false
}

// Join returns a comma serparated string
// Join returns a comma separated string
func (c Currencies) Join() string {
return strings.Join(c.Strings(), ",")
}

// UnmarshalJSON conforms type to the umarshaler interface
// UnmarshalJSON conforms type to the unmarshaler interface
func (c *Currencies) UnmarshalJSON(d []byte) error {
if d[0] != '[' {
d = []byte(`[` + string(d) + `]`)
Expand Down
4 changes: 2 additions & 2 deletions currency/pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (p Pairs) Format(pairFmt PairFormat) Pairs {
return pairs
}

// UnmarshalJSON conforms type to the umarshaler interface
// UnmarshalJSON conforms type to the unmarshaler interface
func (p *Pairs) UnmarshalJSON(d []byte) error {
var pairs string
err := json.Unmarshal(d, &pairs)
Expand Down Expand Up @@ -292,7 +292,7 @@ func (p Pairs) GetRandomPair() (Pair, error) {
if len(p) == 0 {
return EMPTYPAIR, ErrCurrencyPairsEmpty
}
return p[rand.Intn(len(p))], nil //nolint:gosec // basic number generation required, no need for crypo/rand
return p[rand.Intn(len(p))], nil //nolint:gosec // basic number generation required, no need for crypto/rand
}

// DeriveFrom matches symbol string to the available pairs list when no
Expand Down
2 changes: 1 addition & 1 deletion database/repository/withdraw/withdraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func seedWithdrawData() {
},
},
}
rnd := rand.Intn(2) //nolint:gosec // used for generating test data, no need to import crypo/rand
rnd := rand.Intn(2) //nolint:gosec // used for generating test data, no need to import crypto/rand
if rnd == 0 {
resp.RequestDetails.Currency = currency.AUD
resp.RequestDetails.Type = 1
Expand Down
2 changes: 1 addition & 1 deletion docs/CODING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Use `require` and `assert` appropriately:
- API methods and public types must have comments for GoDoc.
- Comments should explain **why** the code is doing something, not **what** it's doing, which should be self-explanatory.
- Self-explanatory comments must be avoided.
- Only retain comments for complex logic or where external behavior needs clarification.
- Only retain comments for complex logic or where external behaviour needs clarification.

## Formatting

Expand Down
6 changes: 3 additions & 3 deletions docs/WS_ORDER_EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ out of reported trades.
|----------------------|-------------------------------------------------------------------|---------------------------------------------------------|-----------|
| Price | Original price assigned to order | Depends on order type (e.g. limit orders have prices) | Mandatory |
| Amount | Original quantity assigned to order | | Mandatory |
| AverageExecutedPrice | Average price of what's traded thus far | Order is filled, partially filled or partially canceled | Desirable |
| ExecutedAmount | How much of the original order quantity is filled | Order is filled, partially filled or partially canceled | Mandatory |
| AverageExecutedPrice | Average price of what's traded thus far | Order is filled, partially filled or partially cancelled | Desirable |
| ExecutedAmount | How much of the original order quantity is filled | Order is filled, partially filled or partially cancelled | Mandatory |
| RemainingAmount | Amount - ExecutedAmount | | Mandatory |
| Cost | How much is spent thus far (cumulative transacted quote currency) | Order is filled, partially filled or partially canceled | Mandatory |
| Cost | How much is spent thus far (cumulative transacted quote currency) | Order is filled, partially filled or partially cancelled | Mandatory |
| CostAsset | Deprecated, cost currency is always pair.Quote | | - |
| Fee | How much last trade was charged by the exchange | Reported event is a trade | Optional |
| FeeAsset | Asset of the taken fee | | Optional |
Expand Down
Loading
Loading