Binance TypeScript SDK example: rest-portfoliomargin-private.ts

Binance TypeScript SDK REST Portfolio Margin example for Binance/Rest/Portfolio Margin/rest-portfoliomargin-private.ts. Source code reference for exchange REST, WebSocket, and API integration patterns with links to matching Siebly SDK documentation.

Example Path

Binance/Rest/Portfolio Margin/rest-portfoliomargin-private.ts

Source Link

Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/Rest/Portfolio Margin/rest-portfoliomargin-private.ts

Related SDK Docs

Example Source

import { PortfolioClient } from 'binance';

const key = process.env.API_KEY_COM || 'APIKEY';
const secret = process.env.API_SECRET_COM || 'APISECRET';

const client = new PortfolioClient({
  api_key: key,
  api_secret: secret,
  beautifyResponses: true,
});

(async () => {
  try {
    const res = await client.getBalance();
    console.log('res', res);

    const listenKey = await client.getPMUserDataListenKey();
    console.log('listen key res: ', listenKey);

    // const newOrderRes = await client.submitNewUMOrder({
    //   symbol: 'BTCUSDT',
    //   side: 'BUY',
    //   type: 'MARKET',
    //   quantity: '10',
    // });

    // console.log('new order res: ', newOrderRes);
  } catch (e) {
    console.error('request failed: ', e);
  }
})();