HollaEx®
⚙️ DashboardStart →
  • HollaEx® — The Crypto Exchange Solution
  • ☁️Cloud Operators
    • Launching the Exchange
    • Setting Domain for Cloud Exchanges
    • Easy SMTP for Cloud Exchanges
    • SEO Settings for Cloud Exchanges
      • SEO Advanced Settings
  • ⚙️Operating Your Exchange
    • Operator Control Panel
      • General
      • Users
      • User Profile
      • Assets
      • Markets
      • Stakes
      • Sessions
      • Plugins Apps
      • Trading Fees & Account Tiers
      • Roles
      • Chat
      • Billing
    • Customize Exchange
      • Browser Tools
        • Enter Edit Mode
        • Operator Controls (Visuals)
        • Console
      • Plugins
      • Forked Repo
    • Fiat Controls
      • Initial Setup
      • Setting Up Fiat On/ Off Ramp
      • Editing Deposit & Withdrawal Fees
      • Users Making Fiat Deposit
      • Users Trading With Fiat
      • User Making Fiat Withdrawal
    • Staking
    • OTC Broker
    • P2P
      • P2P Overview
      • P2P Setup
      • P2P Troubleshooting
      • P2P Vendor Flow
    • Smart Chain Trading
    • Assets & Trading Pairs
      • Add New Assets & Trading Pairs
      • Configure Pair Parameters
    • Set up the SMTP Email
      • Set up SMTP with AWS SES
      • Set up SMTP with Mailgun
      • Set up SMTP with SendGrid
      • Test the SMTP with Gmail
    • Enabling reCAPTCHA
    • Email Customization & Audit
    • DeFi Asset Staking Process
  • 🧩Plugins
    • HollaEx Plugins
      • Announcements
      • Bank
      • AWS SNS (Text Messages - SMS)
      • KYC
      • Automatic KYC
      • Messente
      • Advanced Referral
      • CoinMarketCap
      • Guardarian
    • Install Plugins
    • Developing Plugins
      • Development Walkthrough: Hello-Plugin
        • Initialization
        • Configuration
        • Scripting
        • Web View
        • The Final Product & Installation
      • Advanced
        • Initialization
        • Config
        • Server Script
        • Plugin Libraries
        • Web View
        • Final Plugin Product
        • Advanced Tutorial: Using the user meta field
        • Advanced Tutorial: Adding a new database table column
        • Advanced Tutorial: Creating a new database table
      • Simple Wallet Example
      • Web View Development
        • Overview
        • External dependencies
        • Getting started
        • Basic Tutorial: Hello Exchange Plugin web view
        • Advanced Tutorial: KYC Plugin web views
    • Bank Integration
      • Handling Deposits
      • Handling Withdrawals
  • 👷Developers
    • API Guide
      • API Example Scripts
    • Run Dev Mode
    • Build a New Front-end Interface
  • 🧰On-Premise Operators (Advanced Only)
    • On-Premise Exchange Setup
      • Getting Started — Requirements
      • Installation
      • Server Setup
      • Web Setup
      • Production
    • CLI How-Tos
      • Start Exchange
      • Stop Exchange
      • Upgrade Exchange
        • Build and Apply the Code Changes
      • Get Exchange Logs
      • Get a Backup and Restore
      • Exchange Migration
      • Command List
    • Run Exchange on Kubernetes
    • Troubleshooting Guide
  • 🚀Advanced
    • SEO Optimization
    • Nginx
    • Rate Limits
    • Database
      • Upgrade Database
    • Dependencies
    • Contents Delivery Network
      • Cloudflare CDN for HollaEx
      • CloudFront CDN for HollaEx
    • Load Balancer
      • AWS ELB
      • DigitalOcean LB
    • Customize Kubenretes Ingress
    • Exchange Keys
      • Exchange API Keys Troubleshoot
    • HollaEx on non-Linux
      • HollaEx on Windows
      • HollaEx on macOS
    • The Network Tool Library
      • Accessing the Network Tool Library
      • Functions
        • WebSocket
      • Simple Example: Creating a User and Wallet
      • Getting More Interesting: Orders with the Tools
        • Setup: Using the transferAsset function
        • Creating and Monitoring a Sell Order
        • Settling Fees
      • Private HollaEx Network
    • Docker Content Trust (DCT)
    • Revenue Sharing
  • 📦Releases
    • Release Notes
    • Side Notes
  • ➡️External Links
  • Blogs
  • Forum
  • Videos
  • Twitter X
  • Telegram
  • Interactive Demo
  • Discord Community
  • API Documentation
  • Tools Library Documentation
  • Node Library Documentation
  • Plugins Documentation
Powered by GitBook
On this page
  1. Advanced
  2. The Network Tool Library
  3. Getting More Interesting: Orders with the Tools

Creating and Monitoring a Sell Order

Creating buy and sell orders is, of course, a fairly vital part of the crypto industry and here we will look at how we can interact with this core functionality

PreviousSetup: Using the transferAsset functionNextSettling Fees

Last updated 2 years ago

📺 Watch on YouTube!:

Let's get straight into the script and see how to create a sell order, and then view it.

Account A from before will be creating a market sell order for 10 XHT.

As before, check comments for explanations

//using the index file, get access to the functions we will be using throughout
//Note: make sure the index file is pointed in the correct relative folder to this
//script
const Network = require('./index');

const network = new Network({
    apiUrl: 'https://api.hollaex.network',
    apiKey: '<YOUR_API_KEY>',
    apiSecret: '<YOUR_API__SECRET_KEY>',
    activation_code: '<YOUR_ACTIVATION_CODE>',
});

//main function for adding user and their address
(async () => {
	try {
		//initialise the network
		const init = await network.init();

		//account's IDs
		let idAccountA = 2275;

		//balance before the sell order
		console.log(await network.getUserBalance(idAccountA));

		//fee data (in percentages ie. 0.03 = 0.03% fee)
		let feeData = { fee_structure: { maker: 0.03, taker: 0.03 } };
		//create the order
		await network.createOrder(
			idAccountA, 	//account placing order
			'xht-usdt', 	//symbol of market
			'sell',		//type of order
			10,		//order amount
			'market',	//type of order (limit/ market)
			undefined,	//limit if limit order
			feeData		//feeobject from above
		);

		//balance after the order
		console.log(await network.getUserBalance(idAccountA));

		//see what trades this user has completed
		console.log(await network.getUserTrades(idAccountA));

		//see what active orders this user has
		console.log(await network.getUserOrders(idAccountA));
	} catch (err) {
		console.log(err);
	}
})();

Transfer Assets Script: The Output

As before edited lines for readability, shortened sections noted with '~~':

//Account A before the sell order (line 23)
{ //~~other coin balances~~
  usdt_balance: 14.474006, //initially about 14 XHT
  usdt_available: 14.474006,
  xht_balance: 27.994,     //initially about 28 XHT
  xht_available: 27.994, 
  //~~other coin balances~~
  }
  
  //Here the order is placed, and due to being on the testnet,
  //is instantly snapped up!
  
//Account A after the sell order's completion (line 39)
{ //~~other coin balances~~
  usdt_balance: 16.573376, //about 2 USDT gained 
  usdt_available: 16.573376,
  xht_balance: 17.994,     //sold 10 XHT 
  xht_available: 17.994,
  //~~other coin balances~~
  }
  
//this is all of Account A's trades listed (line 42)
{ count: 13,
  data:
   [ { side: 'buy',
       symbol: 'xht-usdt',
       size: 10,
       price: 0.3,
       timestamp: '2022-06-24T21:58:44.990Z',
       order_id: 'bc6e5053-8453-489e-8804-d2df9069f9c4',
       fee: 0.003,
       fee_coin: 'xht' },
     { //~~ the previous trades done by A ~~
     } ] }
     
//zero open orders as it was fully filled near instantly! (line 45)
{ count: 0, data: [] }

As the amount for my order was fairly small, and it using the shared liquidity system of HollaEx, my list of orders may look empty, but that's just due to how quickly the trade was made. Shows how nifty shared liquidity is, given we only had one user actually doing something on this exchange ain't it?

🚀
Using the Orderbook with the Network Tools