Types: Switch convert.StringToFloat64 to types.Number (#1415)

* Types: Add Number type

* Types: Switch StringToFloat64 for Number

This change mostly just renames the type.
convert package and StringToFloat64 represent actions, not types,
and make it misleading to use outside of the API context,
especially when using it for a Float64ToString operation.

* Common: Remove StringToFloat64

Replaced by types.Number

* fixup! Types: Switch StringToFloat64 for Number

Second pass at Okx

* Spellcheck: Fix whitespace handling for okx line
This commit is contained in:
Gareth Kirwan
2023-12-20 03:01:27 +01:00
committed by GitHub
parent 5042bf9790
commit f05f24da8b
21 changed files with 3158 additions and 3140 deletions

View File

@@ -3407,7 +3407,7 @@ func TestForceFileStandard(t *testing.T) {
t.Error(err)
}
if t.Failed() {
t.Fatal("Please use convert.StringToFloat64 type instead of `float64` and remove `,string` as strings can be empty in unmarshal process. Then call the Float64() method.")
t.Fatal("Please use types.Number type instead of `float64` and remove `,string` as strings can be empty in unmarshal process. Then call the Float64() method.")
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,6 @@ import (
"github.com/shopspring/decimal"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/convert"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
@@ -32,6 +31,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/trade"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
"github.com/thrasher-corp/gocryptotrader/types"
)
// GetDefaultConfig returns a default exchange config
@@ -1048,8 +1048,8 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi
Side: orderTypeFormat,
Type: s.Type.Lower(),
Account: g.assetTypeToString(s.AssetType),
Amount: convert.StringToFloat64(s.Amount),
Price: convert.StringToFloat64(s.Price),
Amount: types.Number(s.Amount),
Price: types.Number(s.Price),
CurrencyPair: s.Pair,
Text: s.ClientOrderID,
})
@@ -1091,7 +1091,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi
fOrder, err := g.PlaceFuturesOrder(ctx, &OrderCreateParams{
Contract: s.Pair,
Size: s.Amount,
Price: convert.StringToFloat64(s.Price),
Price: types.Number(s.Price),
Settle: settle,
ReduceOnly: s.ReduceOnly,
TimeInForce: "gtc",
@@ -1128,7 +1128,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi
newOrder, err := g.PlaceDeliveryOrder(ctx, &OrderCreateParams{
Contract: s.Pair,
Size: s.Amount,
Price: convert.StringToFloat64(s.Price),
Price: types.Number(s.Price),
Settle: settle,
ReduceOnly: s.ReduceOnly,
TimeInForce: "gtc",
@@ -1156,7 +1156,7 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi
optionOrder, err := g.PlaceOptionOrder(ctx, OptionOrderParam{
Contract: s.Pair.String(),
OrderSize: s.Amount,
Price: convert.StringToFloat64(s.Price),
Price: types.Number(s.Price),
ReduceOnly: s.ReduceOnly,
Text: s.ClientOrderID,
})
@@ -1544,7 +1544,7 @@ func (g *Gateio) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawReques
}
response, err := g.WithdrawCurrency(ctx,
WithdrawalRequestParam{
Amount: convert.StringToFloat64(withdrawRequest.Amount),
Amount: types.Number(withdrawRequest.Amount),
Currency: withdrawRequest.Currency,
Address: withdrawRequest.Crypto.Address,
Chain: withdrawRequest.Crypto.Chain,