github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/spot/16_TradesV2/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	"github.com/InjectiveLabs/sdk-go/client/common"
     9  	exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
    10  	spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb"
    11  )
    12  
    13  func main() {
    14  	network := common.LoadNetwork("testnet", "lb")
    15  	exchangeClient, err := exchangeclient.NewExchangeClient(network)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	ctx := context.Background()
    21  	marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"
    22  	subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
    23  
    24  	req := spotExchangePB.TradesV2Request{
    25  		MarketId:     marketId,
    26  		SubaccountId: subaccountId,
    27  	}
    28  
    29  	res, err := exchangeClient.GetSpotTradesV2(ctx, &req)
    30  	if err != nil {
    31  		panic(err)
    32  	}
    33  
    34  	str, _ := json.MarshalIndent(res, "", " ")
    35  	fmt.Print(string(str))
    36  }