Merge pull request #19 from wuhewuhe/master
fix users endpoints and add examples
This commit is contained in:
commit
78765b21b0
|
@ -288,6 +288,12 @@ func (c *Client) NewUserService(params map[string]interface{}) *UserServiceClien
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Client) NewUserServiceNoParams() *UserServiceClient {
|
||||
return &UserServiceClient{
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) NewBrokerService(params map[string]interface{}) *BrokerServiceClient {
|
||||
return &BrokerServiceClient{
|
||||
c: c,
|
||||
|
|
|
@ -12,7 +12,16 @@ func main() {
|
|||
|
||||
func PlaceTrade() {
|
||||
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
|
||||
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT", "side": "Buy", "positionIdx": 0, "orderType": "Limit", "qty": "0.001", "price": "10000", "timeInForce": "GTC"}
|
||||
params := map[string]interface{}{
|
||||
"category": "linear",
|
||||
"symbol": "BTCUSDT",
|
||||
"side": "Buy",
|
||||
"positionIdx": 0,
|
||||
"orderType": "Limit",
|
||||
"qty": "0.001",
|
||||
"price": "10000",
|
||||
"timeInForce": "GTC",
|
||||
}
|
||||
orderResult, err := client.NewTradeService(params).PlaceOrder(context.Background())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
bybit "github.com/wuhewuhe/bybit.go.api"
|
||||
)
|
||||
|
||||
func main() {
|
||||
CreateSubApiKey()
|
||||
}
|
||||
|
||||
func CreateSubApiKey() {
|
||||
client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
|
||||
params := map[string]interface{}{"subuid": "100366706", "readOnly": 0,
|
||||
"permissions": []map[string]interface{}{
|
||||
{
|
||||
"Wallet": []string{"AccountTransfer", "SubMemberTransferList"},
|
||||
},
|
||||
},
|
||||
}
|
||||
userResult, err := client.NewUserService(params).CreateSubApiKey(context.Background())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(bybit.PrettyPrint(userResult))
|
||||
}
|
|
@ -7,10 +7,10 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
PlaceTrade()
|
||||
CreateNewSubUser()
|
||||
}
|
||||
|
||||
func PlaceTrade() {
|
||||
func CreateNewSubUser() {
|
||||
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
|
||||
params := map[string]interface{}{"username": "06112023Victor", "memberType": 1}
|
||||
userResult, err := client.NewUserService(params).CreateSubMember(context.Background())
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
bybit "github.com/wuhewuhe/bybit.go.api"
|
||||
)
|
||||
|
||||
func main() {
|
||||
GetApiKeyInfo()
|
||||
}
|
||||
|
||||
func GetApiKeyInfo() {
|
||||
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
|
||||
userResult, err := client.NewUserServiceNoParams().GetAPIKeyInfo(context.Background())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
fmt.Println(bybit.PrettyPrint(userResult))
|
||||
}
|
12
user.go
12
user.go
|
@ -193,7 +193,7 @@ func (s *UserServiceClient) GetSubUidList(ctx context.Context, opts ...RequestOp
|
|||
return nil, err
|
||||
}
|
||||
r := &request{
|
||||
method: http.MethodPost,
|
||||
method: http.MethodGet,
|
||||
endpoint: "/v5/user/query-sub-members",
|
||||
secType: secTypeSigned,
|
||||
}
|
||||
|
@ -211,15 +211,11 @@ func (s *UserServiceClient) GetSubUidList(ctx context.Context, opts ...RequestOp
|
|||
}
|
||||
|
||||
func (s *UserServiceClient) GetAPIKeyInfo(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
|
||||
if err = handlers.ValidateParams(s.params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r := &request{
|
||||
method: http.MethodPost,
|
||||
method: http.MethodGet,
|
||||
endpoint: "/v5/user/query-api",
|
||||
secType: secTypeSigned,
|
||||
}
|
||||
r.setParams(s.params)
|
||||
data, err := s.c.callAPI(ctx, r, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -237,7 +233,7 @@ func (s *UserServiceClient) GetUidWalletType(ctx context.Context, opts ...Reques
|
|||
return nil, err
|
||||
}
|
||||
r := &request{
|
||||
method: http.MethodPost,
|
||||
method: http.MethodGet,
|
||||
endpoint: "/v5/user/get-member-type",
|
||||
secType: secTypeSigned,
|
||||
}
|
||||
|
@ -259,7 +255,7 @@ func (s *UserServiceClient) GetAffiliateUserInfo(ctx context.Context, opts ...Re
|
|||
return nil, err
|
||||
}
|
||||
r := &request{
|
||||
method: http.MethodPost,
|
||||
method: http.MethodGet,
|
||||
endpoint: "/v5/user/aff-customer-info",
|
||||
secType: secTypeSigned,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue