mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 23:16:49 +00:00
GCT: fix spelling (#1164)
* kodespull * fix my spelling * silly sausage, rm sneaky pointer
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user