Skip to content

双向持仓模式下 获取合约单个仓位信息报错 #49

@DevaloperHH

Description

@DevaloperHH

报错信息:
"json: cannot unmarshal array into Go value of type gateapi.Position"
代码:

func (base *GateService) FuturesPosition(currencyPair string) (gateapi.Position, error) {
	client := gateapi.NewAPIClient(gateapi.NewConfiguration())
	ctx := context.WithValue(context.Background(),
		gateapi.ContextGateAPIV4,
		gateapi.GateAPIV4{
			Key:    base.Config.ApiKey,
			Secret: base.Config.ApiSecret,
		},
	)
	settle := "usdt" // string - Settle currency
	// currencyPair = ""

	result, _, err := client.FuturesApi.GetPosition(ctx, settle, currencyPair)
	if err != nil {
		if e, ok := err.(gateapi.GateAPIError); ok {
			return result, errors.New(e.Message)
		} else {
			return result, err
		}
	}

	return result, nil
}

合约:ARB_USDT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions