Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add documentation and examples #30

Merged
merged 4 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,48 @@ This Project is under active development. Please feel free to contribute.
go get -u github.com/cksidharthan/go-bybit
```

# Enpoints completed
## Example
```go
func main() {
client := rest.NewRestClient(bybit.BybitTestnetBaseURL, os.Getenv("BYBIT_API_KEY"), os.Getenv("BYBIT_API_SECRET"))

// Get spot market client
spotClient := client.Spot()
// Get linear market client
linearClient := client.Linear()
// Get inverse perpetual market client
inverseClient := client.InversePerpetual()

spotResponse, err := spotClient.Market().GetSymbols(context.Background())
if err != nil {
fmt.Errorf("error: %v", err)
}

linearResponse, err := linearClient.Market().GetSymbolInformation(context.Background(), &linear.GetSymbolInformationParams{
Symbol: "BTCUSDT",
})
if err != nil {
fmt.Errorf("error: %v", err)
}

inverseResponse, err := inverseClient.Market().GetSymbolInformation(context.Background(), &inverseperp.GetSymbolInformationParams{
Symbol: "BTCUSD",
})
if err != nil {
fmt.Errorf("error: %v", err)
}

fmt.Println(spotResponse)
fmt.Println(linearResponse)
fmt.Println(inverseResponse)
}
```

All the tests in this repository interact with the Bybit API directly. Please refer them for examples, when using this library. :)

In the meantime, I'll be adding more examples to `./examples` folder.

# Endpoints completed

| Category | SubCategory | Created | Testcases |
|-------------------|----------------------------------------------------------------------------------------|:------------------:|:------------------:|
Expand Down
45 changes: 45 additions & 0 deletions examples/get-client/get_client_example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"context"
"fmt"
"github.com/cksidharthan/go-bybit/bybit"
"github.com/cksidharthan/go-bybit/rest"
inverseperp "github.com/cksidharthan/go-bybit/rest/domain/inverse_perpetual"
"github.com/cksidharthan/go-bybit/rest/domain/linear"
"os"
)

func main() {
client := rest.NewRestClient(bybit.BybitTestnetBaseURL, os.Getenv("BYBIT_API_KEY"), os.Getenv("BYBIT_API_SECRET"))

// Get spot market client
spotClient := client.Spot()
// Get linear market client
linearClient := client.Linear()
// Get inverse perpetual market client
inverseClient := client.InversePerpetual()

spotResponse, err := spotClient.Market().GetSymbols(context.Background())
if err != nil {
_ = fmt.Errorf("error: %v", err)
}

linearResponse, err := linearClient.Market().GetSymbolInformation(context.Background(), &linear.GetSymbolInformationParams{
Symbol: "BTCUSDT",
})
if err != nil {
_ = fmt.Errorf("error: %v", err)
}

inverseResponse, err := inverseClient.Market().GetSymbolInformation(context.Background(), &inverseperp.GetSymbolInformationParams{
Symbol: "BTCUSD",
})
if err != nil {
_ = fmt.Errorf("error: %v", err)
}

fmt.Println(spotResponse)
fmt.Println(linearResponse)
fmt.Println(inverseResponse)
}