Nuclear Powered Marshmallows

    proper-order-book

    1.5.3 • Public • Published

    proper-order-book

    An efficient order book which supports market and limit orders with fast insertion and search.

    This order book was designed with decentralized exchanges (DEXs) in mind.

    Usage

    const ProperOrderBook = require('proper-order-book');
    
    let orderBook = new ProperOrderBook();
    
    orderBook.add({
      id: `ask0`,
      type: 'limit',
      price: .5,
      targetChain: 'lsk',
      targetWalletAddress: '22245678912345678222L',
      senderId: '11111111111222222222L',
      side: 'ask',
      size: 100
    });
    
    let result = orderBook.add({
      id: `bid0`,
      type: 'limit',
      price: .5,
      targetChain: 'clsk',
      targetWalletAddress: '22245678912345678222L',
      senderId: '11111111111222222222L',
      side: 'bid',
      value: 10
    });
    
    console.log(result);
    { taker:
       { id: 'bid0',
         type: 'limit',
         price: 0.5,
         targetChain: 'clsk',
         targetWalletAddress: '22245678912345678222L',
         senderId: '11111111111222222222L',
         side: 'bid',
         value: 10,
         valueRemaining: 0,
         lastSizeTaken: 0,
         lastValueTaken: 0 },
      makers:
       [ { id: 'ask0',
           type: 'limit',
           price: 0.5,
           targetChain: 'lsk',
           targetWalletAddress: '22245678912345678222L',
           senderId: '11111111111222222222L',
           side: 'ask',
           size: 100,
           sizeRemaining: 80,
           lastSizeTaken: 20,
           lastValueTaken: 10 } ],
      takeSize: 20,
      takeValue: 10 }

    Testing

    npm test
    

    License

    Licensed under GPLv3: http://www.gnu.org/licenses/gpl-3.0.html

    Install

    npm i proper-order-book

    DownloadsWeekly Downloads

    0

    Version

    1.5.3

    License

    GPL-3.0

    Unpacked Size

    92.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • topcloudsystems