Giter Club home page Giter Club logo

bingx-api's People

Contributors

aliraza556 avatar dependabot[bot] avatar singlesly avatar

Stargazers

 avatar

Watchers

 avatar

bingx-api's Issues

Global Service instance proposal

Cases
1. Create global service instance

import { ApiAccount } from "./api-account";

const account = new ApiAccount('xxx', 'xxx');

const bingxApiClient = new BingxApiClient();

const listenKey = await bingxApiClient
                      .getListenKeyService()
                      .generateListenKey(account);

bingxApiClient
  .getListenKeyService()
  .extendListenKeyValidityPeriod(listenKey, account);

bingxApiClient
  .getListenKeyService()
  .deleteListenKey(listenKey, account);
  1. Override internal bingx request class

Implement custom request class

class RmqCustomRequest<T> implements BingxRequestInterface<T> {
  constructor(
    private readonly endpoint: EndpointInterface<T>,
    private readonly rmqClient: RmqClient,
    private readonly storage: AsyncStorage,
  ) {}

  async getEndpoint(): Promise<Readonly<EndpointInterface<T>>> {
    return this.endpoint;
  }

  getResponse(): Promise<Readonly<BingxResponseInterface<T>>> {
    // logic
  }
}

override request

import { EndpointInterface } from "./endpoint.interface";

const account = new ApiAccount('xxx', 'xxx');

const bingxApiClient = new BingxApiClient()
  .overrideRequestExecutor((endpoint: EndpointInterface) => {
    return new RmqCustomRequest(
      endpoint,
      app.get(RmqClient),
      app.get(AsyncStorage),
    );
  });

// request will sent into rmq
const listenKey = await bingxApiClient
  .getListenKeyService()
  .generateListenKey(account);
  1. Using nestjs modules API

common usages

@Module({
  imports: [BingXModule]
})
export class AppModule {}

Configurable usage

@Module({
  imports: [
    BingXModule.configure({
      imports: [RequestContext, RmqModule],
      overrideRequestExecutor: {
        provider: RmqCustomRequest,
        inject: [RmqClient, AsyncStorage],
      },
    })
  ]
})
export class AppModule {}

Export socket functionallity

now can use websocket only ugly import

import { BingxAccountSocketStreamPool } from "bingx-api/dist/bingx-socket/bingx-account-socket-stream-pool";

Implement websocket account data stream

Select feature account data stream from proposal #2

Requirements:

  • heartbeat
  • listenKeyExpired
  • accountUpdate
  • orderTradeUpdate
  • accountConfigUpdate
  • Automatically refresh/extend live for listen key

Account stream

  • think about how to support exchange listen key with custom requests
const account = new ApiAccount('x', 'x')
const accountStream = new BingxWebSocketAccountStream(account);

accountStream.hearbeat$.subscribe();

// Listen key expired
accountStream.listenKeyExpired$.subscribe();

// Account balance and position update push
accountStream.accountUpdate$.subscribe();

// Order update push
accountStream.orderTradeUpdate$.subscribe();

// Configuration updates
accountStream.accountConfigUpdate$.subscribe();

Implement websocket account stream pool

request from #2

Account stream pool

Supports multiple account stream

const accountStreamPool = new BingxWebSocketAccountStreamPool(accounts);

//
accountStreamPool.hearbeat$.subscribe(account => {});

// Add user
accountStreamPool.addAccount(account);

// Remove user
accountStreamPoll.removeAccount(account);

// Listen key expired
accountStreamPool.listenKeyExpired$.subscribe((data, account) => {});

// Account balance and position update push
accountStreamPool.accountUpdate$.subscribe((data, account) => {});

// Order update push
accountStreamPool.orderTradeUpdate$.subscribe((data, account) => {});

// Configuration updates
accountStreamPool.accountConfigUpdate$.subscribe((data, account) => {});

fix bigint order id problem

Notice:in nodeJS when you converts original resp(string) to json, order id is a big-int in some response
            it may have big-int issue, will be transformed automatically
            for example:  order id: 172998235239792314304 -be transformed automatically to-->172998235239792314300
            if you find something wrong with order id like 'order not exist' or found the order id suffix with 00 or more 0, chould be the reason 
            then can print the original response like below to check the origianl order id 

https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order%20test

relates problem to nodejs

Create issues for implementation endpoint

PAID Ticket rules

Price: 10$

Requirements

  • Created all tickets for endpoints with unchecked status in README
  • Created tickets does not have "paid" labels
  • Each ticket on 1st line has ref to wiki paid tickets page

Description: create issues for implement endpoints which has unchecked status in README.md
You can use this issue as reference

Each issue must be has price 10$

Websocket proposal

Supports websocket functionality

Market data

const marketStream = new BingxWebSocketMarketStream();

// Heartbeat
marketStream.hearbeat$.subscribe();

// Market Depth data
marketStream.subscribeMarketDepthData({
  symbol: 'BTC-USDT',
  level: 5,
});

marketStream.marketDepthData$.subscribe((data) => {
  console.log(data);
});

// Latest Trade Detail
marketStream.subscribeLatestTradeDetail({
  symbol: 'BTC-USDT'
});

marketStream.latestTradeDetail$.subscribe((data) => {
  console.log(data);
});

// Subscribe K-Line Data
marketStream.subscribeKLineData({
  symbol: 'BTC-USDT',
  interval: '1m'
});

marketStream.kLineData$.subscribe(data => {
  console.log(data);
});

Account stream

  • think about how to support exchange listen key with custom requests
const account = new ApiAccount('x', 'x')
const accountStream = new BingxWebSocketAccountStream(account);

accountStream.hearbeat$.subscribe();

// Listen key expired
accountStream.listenKeyExpired$.subscribe();

// Account balance and position update push
accountStream.accountUpdate$.subscribe();

// Order update push
accountStream.orderTradeUpdate$.subscribe();

// Configuration updates
accountStream.accountConfigUpdate$.subscribe();

Account stream pool

Supports multiple account stream

const accountStreamPool = new BingxWebSocketAccountStreamPool(accounts);

//
accountStreamPool.hearbeat$.subscribe(account => {});

// Add user
accountStreamPool.addAccount(account);

// Remove user
accountStreamPoll.removeAccount(account);

// Listen key expired
accountStreamPool.listenKeyExpired$.subscribe((data, account) => {});

// Account balance and position update push
accountStreamPool.accountUpdate$.subscribe((data, account) => {});

// Order update push
accountStreamPool.orderTradeUpdate$.subscribe((data, account) => {});

// Configuration updates
accountStreamPool.accountConfigUpdate$.subscribe((data, account) => {});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.