Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/testingaccmar/ccxt_beyang_binance

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/testingaccmar/ccxt_beyang_binance

  • v0.1.2
  • Source
  • Go
  • Socket score

Version published
Created
Source

CCXT BeYANG Binance

This is a package for beYANG CCXT library to work with Binance API

Translations:

Installation

go get github.com/beyang-crypto/CCXT_beYANG_Binance 

Functionality

  • Spot/Margin

    • Wallet:

      • NameBinance_APICCXT_BeYANGDescription
        User AssetBinanceCCXT_BeYANGGet user assets, just for positive data.
    • Market Data:

      • NameBinance_APICCXT_BeYANGDescription
        Check Server TimeBinanceCCXT_BeYANGTest connectivity to the Rest API and get the current server time.
        Exchange InformationBinanceCCXT_BeYANGCurrent exchange trading rules and symbol information
        Order BookBinanceCCXT_BeYANG
        24hr Ticker Price Change StatisticsBinanceCCXT_BeYANG24 hour rolling window price change statistics. Careful when accessing this with no symbol.
    • Spot Account:

      • NameBinance_APICCXT_BeYANGDescription
        Account InformationBinanceCCXT_BeYANGGet current account information
        Account Trade ListBinanceCCXT_BeYANGGet trades for a specific account and symbol
        New OrderBinanceCCXT_BeYANGSend in a new order.
        Test New OrderBinanceCCXT_BeYANGTest new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
        Query Open OCOBinanceCCXT_BeYANG
        Query OrderBinanceCCXT_BeYANGCheck an order's status
    • Margin account

    • Websocket Market Streams

      • NameBinance_APICCXT_BeYANGDescription
        Kline/Candlestick StreamsBinanceCCXT_BeYANG ClientThe Kline/Candlestick Stream push updates to the current klines/candlestick every second.
        Individual Symbol Book Ticker StreamsBinanceCCXT_BeYANG ClientPushes any update to the best bid or ask's price or quantity in real-time for a specified symbol
  • Futures

    • Market Data Endpoints
      • NameBinance_APICCXT_BeYANGDescription
        Get Funding Rate HistoryBinanceCCXT_BeYANG
    • Websocket Market Streams
      • NameBinance_APICCXT_BeYANGDescription
        Mark Price StreamBinanceCCXT_BeYANG ClientMark price and funding rate for a single symbol pushed every 3 seconds or every second
        Mark Price Stream for All marketBinanceCCXT_BeYANG ClientMark price and funding rate for all symbols pushed every 3 seconds or every second
        Kline/Candlestick StreamsBinanceCCXT_BeYANG ClientThe Kline/Candlestick Stream push updates to the current klines/candlestick every 250 milliseconds (if existing).
        Individual Symbol Book Ticker StreamsBinanceCCXT_BeYANG ClientPushes any update to the best bid or ask's price or quantity in real-time for a specified symbol.
    • Account/Trades Endpoints
      • NameBinance_APICCXT_BeYANGDescription
        New OrderBinanceCCXT_BeYANGSend in a new order.
        Query OrderBinanceCCXT_BeYANGCheck an order's status.

|

Usage

REST API
  1. Create configuration object. More in README

     package main
     import (
         "github.com/beyang-crypto/CCXT_beYANG/config"
         . "github.com/beyang-crypto/CCXT_beYANG_Binance/binance/spotAndMargin/rest/enums"
     )
    
    func main() {
         path := "config-prod.yaml" // путpath to configuration file
     
         cfg := config.NewAuth(path, 0, MainnetEndpoint, true)
         // <...>
    }
    
  2. Create configuration object by passing config object and relative path to logger file for logging purposes.

    b := New(cfg, "binanceRespLog.log")

  3. Create a structure with parameters necessary for the function. In this example we use Test New Order function. Test New Order in library Test New Order in Binance API

    path := "config-prod.yaml" // path to configuration file
    
    cfg := config.NewAuth(path, 0, TestnetEndpoint, true)
    
    connRest := client.New(cfg, "binanceRespLog.log")
    symbol, _ := connRest.GetPair("btc", "usdt")
    
    parm := spotRest.TestNewOrderParam{
        Symbol:           symbol,
        Side:             OrderSideBUY,
        Type:             OrderTypeLimit,
        TimeInForce:      TimeInForceGTC,
        Quantity:         0.01,
        NewClientOrderId: "my_order_id_1",
        Price:            9000.0,
    }
    
    
  4. Launch

     ans, err := spotRest.TestNewOrder(connRest, parm)
     if err != nil {
         log.Fatalln(err)
     }
     log.Printf("MAIN response %v", ans)
    

Full example

WebSocket connection
  1. Create configuration object. More in README CCXT_BeYANG

    cfg := NewConfiguration(binanceWs.HostBaseUrl_1, true)
    
  2. Create a structure with parameters necessary for the function. In this example we use Test New Order function.

    connWs := binanceWs.New(ws.FuturesTrading, cfg, "binanceTestLog.log")
    connWs.Start()
    
  3. Create pair(s) and subscribe to the channels we need. We create an array of currency pairs to which we will subscribe, inside one connection.

     symbols1 := []string{
     	"btc",   // btcusdt
     	"eth",   // ethusdt
     	"xrp",   // xrpusdt
     	"ada",   // adausdt
     	"sol",   // solusdt
     	"doge",  // dogeusdt
     	"matic", // maticusdt
     	"shib",  // shibusdt
     	"trx",   // trxusdt
     	"uni",   // uniusdt
     	"avax",  // avaxusdt
     	"ltc",   // ltcusdt
     	"etc",   // etcusdt
     	"link",  // linkusdt
     	"atom",  // atomusdt
     }
     symbol2 := "usdt"
     var pairs []string
     for _, symbol1 := range symbols1 {
     	pairs = append(pairs, connWs.GetPair(symbol1, symbol2))
     }
    
     ws.Subscribe(connWs, binanceWs.ChannelTicker, pairs)
    
  4. Connect to the stream with the channel to which we just subscribed, pass the callback as an argument. Callback-function example:

     func handleBookTicker(name string, symbol string, data binanceWs.BookTicker) {
       log.Printf("%s Ticker  %s: %v", name, symbol, data)
     } 
    

    Connection:

    connWs.GetEmitter().On(binanceWs.ChannelTicker, handleBookTicker)
    
  5. Create a channel so that the function doesn't end. This is necessary to keep the app alive.

    forever := make(chan struct{})
      <-forever
    

Full example


FAQs

Package last updated on 10 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc