github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/spot/14_HistoricalOrders/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 := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"
    22  	subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
    23  	skip := uint64(0)
    24  	limit := int32(10)
    25  	orderTypes := []string{"buy_po"}
    26  
    27  	req := spotExchangePB.OrdersHistoryRequest{
    28  		SubaccountId: subaccountId,
    29  		MarketId:     marketId,
    30  		Skip:         skip,
    31  		Limit:        limit,
    32  		OrderTypes:   orderTypes,
    33  	}
    34  
    35  	res, err := exchangeClient.GetHistoricalSpotOrders(ctx, &req)
    36  	if err != nil {
    37  		panic(err)
    38  	}
    39  
    40  	str, _ := json.MarshalIndent(res, "", " ")
    41  	fmt.Print(string(str))
    42  }