mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +00:00
futures: add GetFuturesContractDetails wrapper function (#1274)
* all in a days work * cleanup * cleanup for real, also stop it binance.json * minor coverage * adds gateio to the slurry * cleanup of types * verbose verbose verbose verbose verbose verbose * fixes huobi parsing issue * fix bybit contract identification * cleanup * merge fixes * addresses many big problems raised by SHAZ * tracking errors and fixes * funding rate if avail, fixes currency formatting * Addresses nits and sneaks in extra fixes * lint * minor fixes after rebase * better contract splitter for currencies like T-USDT * forgot to add the exchange name like a fool * merge fixes x1 * kucoin, direction, contract size * rn direction, fix kucoin time * WHOOPS * Update exchanges/kucoin/kucoin_wrapper.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * misdirection --------- Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/collateral"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/currencystate"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/margin"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
@@ -59,9 +60,9 @@ type fExchange struct {
|
||||
exchange.IBotExchange
|
||||
}
|
||||
|
||||
func (f fExchange) GetFuturesPositionSummary(context.Context, *order.PositionSummaryRequest) (*order.PositionSummary, error) {
|
||||
func (f fExchange) GetFuturesPositionSummary(context.Context, *futures.PositionSummaryRequest) (*futures.PositionSummary, error) {
|
||||
leet := decimal.NewFromInt(1337)
|
||||
return &order.PositionSummary{
|
||||
return &futures.PositionSummary{
|
||||
MaintenanceMarginRequirement: leet,
|
||||
InitialMarginRequirement: leet,
|
||||
EstimatedLiquidationPrice: leet,
|
||||
@@ -106,15 +107,15 @@ func (f fExchange) GetCollateralMode(_ context.Context, _ asset.Item) (collatera
|
||||
return collateral.SingleMode, nil
|
||||
}
|
||||
|
||||
func (f fExchange) GetFuturesPositionOrders(_ context.Context, req *order.PositionsRequest) ([]order.PositionResponse, error) {
|
||||
func (f fExchange) GetFuturesPositionOrders(_ context.Context, req *futures.PositionsRequest) ([]futures.PositionResponse, error) {
|
||||
id, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := make([]order.PositionResponse, len(req.Pairs))
|
||||
resp := make([]futures.PositionResponse, len(req.Pairs))
|
||||
tt := time.Now()
|
||||
for i := range req.Pairs {
|
||||
resp[i] = order.PositionResponse{
|
||||
resp[i] = futures.PositionResponse{
|
||||
Asset: req.Asset,
|
||||
Pair: req.Pairs[i],
|
||||
Orders: []order.Detail{
|
||||
@@ -312,8 +313,8 @@ func (f fExchange) FetchAccountInfo(_ context.Context, a asset.Item) (account.Ho
|
||||
}
|
||||
|
||||
// CalculateTotalCollateral overrides testExchange's CalculateTotalCollateral function
|
||||
func (f fExchange) CalculateTotalCollateral(context.Context, *order.TotalCollateralCalculator) (*order.TotalCollateralResponse, error) {
|
||||
return &order.TotalCollateralResponse{
|
||||
func (f fExchange) CalculateTotalCollateral(context.Context, *futures.TotalCollateralCalculator) (*futures.TotalCollateralResponse, error) {
|
||||
return &futures.TotalCollateralResponse{
|
||||
CollateralCurrency: currency.USD,
|
||||
AvailableMaintenanceCollateral: decimal.NewFromInt(1338),
|
||||
AvailableCollateral: decimal.NewFromInt(1337),
|
||||
@@ -2364,8 +2365,8 @@ func TestGetFuturesPositionsOrders(t *testing.T) {
|
||||
Quote: cp.Quote.String(),
|
||||
},
|
||||
})
|
||||
if !errors.Is(err, order.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, order.ErrNotFuturesAsset)
|
||||
if !errors.Is(err, futures.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, futures.ErrNotFuturesAsset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2457,8 +2458,8 @@ func TestGetCollateral(t *testing.T) {
|
||||
Asset: asset.Spot.String(),
|
||||
IncludeBreakdown: true,
|
||||
})
|
||||
if !errors.Is(err, order.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, order.ErrNotFuturesAsset)
|
||||
if !errors.Is(err, futures.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, futures.ErrNotFuturesAsset)
|
||||
}
|
||||
|
||||
_, err = s.GetCollateral(ctx, &gctrpc.GetCollateralRequest{
|
||||
@@ -2990,8 +2991,8 @@ func TestGetFundingRates(t *testing.T) {
|
||||
|
||||
request.Asset = asset.Spot.String()
|
||||
_, err = s.GetFundingRates(context.Background(), request)
|
||||
if !errors.Is(err, order.ErrNotFuturesAsset) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", err, order.ErrNotFuturesAsset)
|
||||
if !errors.Is(err, futures.ErrNotFuturesAsset) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", err, futures.ErrNotFuturesAsset)
|
||||
}
|
||||
|
||||
request.Asset = asset.Futures.String()
|
||||
@@ -3087,8 +3088,8 @@ func TestGetLatestFundingRate(t *testing.T) {
|
||||
|
||||
request.Asset = asset.Spot.String()
|
||||
_, err = s.GetLatestFundingRate(context.Background(), request)
|
||||
if !errors.Is(err, order.ErrNotFuturesAsset) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", err, order.ErrNotFuturesAsset)
|
||||
if !errors.Is(err, futures.ErrNotFuturesAsset) {
|
||||
t.Errorf("received: '%v' but expected: '%v'", err, futures.ErrNotFuturesAsset)
|
||||
}
|
||||
|
||||
request.Asset = asset.Futures.String()
|
||||
@@ -3193,8 +3194,8 @@ func TestGetManagedPosition(t *testing.T) {
|
||||
|
||||
request.Asset = asset.Spot.String()
|
||||
_, err = s.GetManagedPosition(context.Background(), request)
|
||||
if !errors.Is(err, order.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, order.ErrNotFuturesAsset)
|
||||
if !errors.Is(err, futures.ErrNotFuturesAsset) {
|
||||
t.Errorf("received '%v', expected '%v'", err, futures.ErrNotFuturesAsset)
|
||||
}
|
||||
|
||||
request.Asset = asset.Futures.String()
|
||||
@@ -3205,8 +3206,8 @@ func TestGetManagedPosition(t *testing.T) {
|
||||
s.OrderManager.started = 1
|
||||
s.OrderManager.activelyTrackFuturesPositions = true
|
||||
_, err = s.GetManagedPosition(context.Background(), request)
|
||||
if !errors.Is(err, order.ErrPositionNotFound) {
|
||||
t.Errorf("received '%v', expected '%v'", err, order.ErrPositionNotFound)
|
||||
if !errors.Is(err, futures.ErrPositionNotFound) {
|
||||
t.Errorf("received '%v', expected '%v'", err, futures.ErrPositionNotFound)
|
||||
}
|
||||
|
||||
err = s.OrderManager.orderStore.futuresPositionController.TrackNewOrder(&order.Detail{
|
||||
@@ -3318,8 +3319,8 @@ func TestGetAllManagedPositions(t *testing.T) {
|
||||
}
|
||||
s.OrderManager.started = 1
|
||||
_, err = s.GetAllManagedPositions(context.Background(), request)
|
||||
if !errors.Is(err, order.ErrNoPositionsFound) {
|
||||
t.Errorf("received '%v', expected '%v'", err, order.ErrNoPositionsFound)
|
||||
if !errors.Is(err, futures.ErrNoPositionsFound) {
|
||||
t.Errorf("received '%v', expected '%v'", err, futures.ErrNoPositionsFound)
|
||||
}
|
||||
|
||||
err = s.OrderManager.orderStore.futuresPositionController.TrackNewOrder(&order.Detail{
|
||||
|
||||
Reference in New Issue
Block a user