Skip to content

Commit

Permalink
feat(pair): include support for exclusive pairs fom Binance Futures
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-brito committed Mar 26, 2023
1 parent cde8286 commit 0e9f73a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions exchange/pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"

"github.com/adshao/go-binance/v2"
"github.com/adshao/go-binance/v2/futures"
)

type AssetQuote struct {
Expand Down Expand Up @@ -35,18 +36,33 @@ func SplitAssetQuote(pair string) (asset string, quote string) {

func updateParisFile() error {
client := binance.NewClient("", "")
info, err := client.NewExchangeInfoService().Do(context.Background())
sportInfo, err := client.NewExchangeInfoService().Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get exchange info: %v", err)
}

for _, info := range info.Symbols {
futureClient := futures.NewClient("", "")
futureInfo, err := futureClient.NewExchangeInfoService().Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get exchange info: %v", err)
}

for _, info := range sportInfo.Symbols {
pairAssetQuoteMap[info.Symbol] = AssetQuote{
Quote: info.QuoteAsset,
Asset: info.BaseAsset,
}
}

for _, info := range futureInfo.Symbols {
pairAssetQuoteMap[info.Symbol] = AssetQuote{
Quote: info.QuoteAsset,
Asset: info.BaseAsset,
}
}

fmt.Printf("Total pairs: %d\n", len(pairAssetQuoteMap))

content, err := json.Marshal(pairAssetQuoteMap)
if err != nil {
return fmt.Errorf("failed to marshal pairs: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion exchange/pairs.json

Large diffs are not rendered by default.

0 comments on commit 0e9f73a

Please sign in to comment.