<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tiago</title>
    <description>The latest articles on DEV Community by Tiago (@tsts123).</description>
    <link>https://dev.to/tsts123</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F263591%2Fdfbad7c4-ca9e-4f8e-a66e-3dcd03b9d926.png</url>
      <title>DEV Community: Tiago</title>
      <link>https://dev.to/tsts123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tsts123"/>
    <language>en</language>
    <item>
      <title>Hyperliquid JavaScript QuickStart for Node.js &amp; TypeScript</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Thu, 19 Nov 2026 11:55:07 +0000</pubDate>
      <link>https://dev.to/tsts123/hyperliquid-javascript-quickstart-for-nodejs-typescript-3eek</link>
      <guid>https://dev.to/tsts123/hyperliquid-javascript-quickstart-for-nodejs-typescript-3eek</guid>
      <description>&lt;p&gt;At the surface, working with Hyperliquid's interface, REST APIs &amp;amp; WebSockets seems more complicated than it needs to be. Hyperliquid exposes two main HTTP endpoints (Info &amp;amp; Exchange), plus a WebSocket feed. To call these directly in raw JS, you'll need to also manage signing, nonces, asset IDs and everything that comes with WebSocket lifecycle management (to ensure you can actually rely on them staying alive). In reality, why reinvent the wheel, it's so much simpler than that.&lt;/p&gt;

&lt;p&gt;This quickstart guide walks you through &lt;code&gt;@siebly/hyperliquid-api&lt;/code&gt;, an open source SDK for all the leading JavaScript (&amp;amp; TypeScript!) runtimes, from backend runtimes (Node.js, Nest.js, Deno, Bun, even Cloudflare Workers), to frontend frameworks (React, Vite, Next.js) and even mobile development for iOS &amp;amp; Android (via React Native / Expo). What a time to be alive.&lt;/p&gt;

&lt;p&gt;The SDK itself follows the same architecture as our other exchange SDKs, building on almost a decade of extremely heavy use in production, at scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Classes
&lt;/h2&gt;

&lt;p&gt;There are 3 core surfaces to integrate with HyperLiquid with this JavaScript SDK:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;RestClient&lt;/code&gt; class, which wraps around all the available REST API endpoints (public market data, account state, order management, transfers... all the REST endpoints. One fully typed function you can call for any endpoint, and under the hood it will handle authentication &amp;amp; the HTTP request life cycle for you, before handing back a fully typed response object.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;WebsocketClient&lt;/code&gt; class, our abstraction layer that fully manages WebSockets on demand. Subscribe to (or unsubscribe from) any supported topic, and the SDK will handle the full connection life cycle (track state on topics you've subscribed to, open connections, persist &amp;amp; manage connections, detect/recover/replace stale connections), while emitting rich events for any state changes (topic data, connection state transitions (reconnecting/reconnected), etc). &lt;/li&gt;
&lt;li&gt;The &lt;code&gt;WebsocketAPIClient&lt;/code&gt; class that wraps over our powerful &lt;code&gt;WebsocketClient&lt;/code&gt; architecture to provide REST-like capabilities powered by the latency benefits of one or more persistent and fully managed WebSocket connections.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All requests and responses are fully typed (hurray for build-time checks, TypeScript absolutely recommended!). Exchange-specific semantics such as authentication are handled for you, so you can focus on integration with functionality, and not the plumbing between your machine and the exchange APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;The package supports Node.js 22 or newer. You should always try to use Node LTS, unless you have a very good reason not to (most of you won't). The SDK is open source and published to NPM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install @siebly/hyperliquid-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TypeScript is optional, but the type declarations make the request shapes much easier to discover in your editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not DIY?
&lt;/h2&gt;

&lt;p&gt;One of the more common questions from aspiring devs (especially you vibe devs, you know who you are).&lt;/p&gt;

&lt;p&gt;With our SDKs, you’ve got thousands of other users putting that same code through massive stress testing at scale. If there's a bug, they'll find it, and we will fix it quickly. &lt;/p&gt;

&lt;p&gt;A reconnect bug you might hit once in six months can surface much sooner across that many connections (interesting story here with Binance's listenKey workflow for anyone interested in the comments). Once we fix it in the shared WebSocket client, everyone using that code gets the fix when they update. Suddenly a rare issue that might happen is no longer a risk. That’s a big part of why our SDKs hold up so well in production.&lt;/p&gt;

&lt;p&gt;“Can’t I just ask my agent to build this?” Go on, try it. Ask it to stream your order updates and watch what it does. You might get a working feed in a few minutes. You might also find it fetching your entire list of open orders over REST every time the WebSocket tells you one order changed. Not obvious at the surface while you're testing your vibe spaghetti, not without thoroughly auditing what it made, or worse, finding out the hard way...&lt;/p&gt;

&lt;p&gt;Now drop the network halfway through a reconnect and bring it back. Do your order updates start flowing again? One failed connection attempt can leave a reconnecting flag stuck on true. Every retry after that sees a reconnect already in progress and politely does nothing. If the original error got swallowed, you’ve now got a process that looks healthy, a feed that’s gone quiet and an agent saying “you’re absolutely right” before adding a second retry loop around the first one. Try the same with our SDKs. They undergo heavy testing to ensure self-healing resilience to issues. Toggle your wifi, flip around a VPN, see how WebSockets always recover and resubscribe. An event-driven system (which your system should be) needs to rely on the event source to stay alive. The SDKs manage that for you.&lt;/p&gt;

&lt;p&gt;There are a lot of fiddly details like this. Sometimes it’s a flaw in your connection logic. Sometimes you followed a perfectly convincing example from an older version of the docs. Either can get past a quick test and turn up in production the first time the exchange has a rough afternoon. Learn from the experience of our collective user base and save your tokens (&amp;amp; time) for the core of your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Hyperliquid REST APIs
&lt;/h2&gt;

&lt;p&gt;To use the REST API with any of our SDKs, simply make an instance of the exported RestClient (this is a JavaScript class), and call the Promise-returning methods for the endpoint you're interested in. &lt;/p&gt;

&lt;p&gt;Public Info methods need no credentials. Let's start by checking the exchange status, then pull mid prices and an order book:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;RestClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@siebly/hyperliquid-api'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// or use require if preferred&lt;/span&gt;
&lt;span class="c1"&gt;// const { RestClient } require('@siebly/hyperliquid-api');&lt;/span&gt;


&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RestClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getExchangeStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Exchange status:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// AllMidsResponse is Record&amp;lt;string, string&amp;gt;: coin to mid price&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAllMids&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Coins with a mid price:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'BTC mid:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mids&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'BTC'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&gt;'not listed'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getOrderBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'BTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;nSigFigs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Best bid level:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;levels&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Request failed:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The SDK uses readable &lt;code&gt;get...&lt;/code&gt; names rather than Hyperliquid's internal request type names, so &lt;code&gt;getAllMids()&lt;/code&gt; maps to the &lt;code&gt;allMids&lt;/code&gt; Info request and &lt;code&gt;getOrderBook()&lt;/code&gt; to &lt;code&gt;l2Book&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also read any public account by address, without a key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0x1234567890123456789012345678901234567890'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;perpSummary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPerpAccountSummary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;spotBalances&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getSpotBalances&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Convenient, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  REST API Authentication
&lt;/h2&gt;

&lt;p&gt;For this part, caution is advised. API keys and private keys must be protected. While you can use the SDK in frontend environments (websites), private workflows should ideally be in trusted backend environments only. In our examples we'll use environment variables, but consider best practices around secret/credential management (tons of resources on this online).&lt;/p&gt;

&lt;p&gt;API keys should &lt;strong&gt;always&lt;/strong&gt; use the minimum possible access level. For Hyperliquid, use an API wallet, &lt;strong&gt;not your mai nwallet key&lt;/strong&gt;!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;RestClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@siebly/hyperliquid-api'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;privateKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;HYPERLIQUID_PRIVATE_KEY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;privateKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Set HYPERLIQUID_PRIVATE_KEY before starting.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RestClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;privateKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;testnet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;balances&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBalances&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Account:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;balances&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Spot:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;balances&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;balances&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Perpetuals:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;balances&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;perp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assetPositions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openOrders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getOpenOrders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Open orders:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;openOrders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some additional notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use testnet first.&lt;/strong&gt; &lt;code&gt;testnet: true&lt;/code&gt; points the client at Hyperliquid's testnet API, so you can exercise signing and order flows without touching a real account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use an API wallet, not your main wallet key.&lt;/strong&gt; Create a dedicated API (agent) wallet from your Hyperliquid account and give the bot that key. API wallets can place and cancel orders but cannot withdraw funds, so a leaked key cannot drain the account. The SDK resolves an API wallet to its master account automatically, or you can pass &lt;code&gt;accountAddress: masterAddress&lt;/code&gt; to skip that lookup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep keys server-side.&lt;/strong&gt; &lt;strong&gt;Never&lt;/strong&gt; put a private key in frontend code, browser storage or a public environment variable. Especially you clauders out there! Public REST calls and public subscriptions are browser-safe; signed calls are not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Custom signers.&lt;/strong&gt; If you would rather not hand the SDK a raw key, the constructor also accepts a &lt;code&gt;signer&lt;/code&gt; with a portable &lt;code&gt;signTypedData&lt;/code&gt; implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using other signed API calls is as easy as the above. For example, this places a post-only limit order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submitLimitOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'BTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;side&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'buy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.001'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'50000'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;timeInForce&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'GTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The SDK also exposes a convenient submitMarketOrder method, for you takers out there.&lt;/p&gt;

&lt;p&gt;Exchange methods return an &lt;code&gt;ExchangeResponse&lt;/code&gt; wrapper, so check &lt;code&gt;status === 'ok'&lt;/code&gt; before reading &lt;code&gt;response.data&lt;/code&gt;. For the full order surface, including &lt;code&gt;submitOrder()&lt;/code&gt; with raw Hyperliquid order fields and &lt;code&gt;submitMarketOrder()&lt;/code&gt;, see the &lt;a href="https://siebly.io/sdk/hyperliquid/javascript/tutorial" rel="noopener noreferrer"&gt;Hyperliquid API JavaScript tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  WebSockets: Subscribing to Streams
&lt;/h2&gt;

&lt;p&gt;Event-driven systems are wonderful. Subscribe to state changes (account, position, balance, market data), and you'll receive an asynchronous event when something  changes, something you may want to act on. An order fills, a position updates, that's a good time to update local state and upsert any related orders that your system requires (e.g. your passive limit order TP).&lt;/p&gt;

&lt;p&gt;Do this right, and you'll only use the REST API for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fetching state when your local state is dirty (first start or WS reconnected and we to make sure we're still up to date).&lt;/li&gt;
&lt;li&gt;submitting commands (order management, leverage changes, any other write actions on your account)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The WebSocket stream will passively keep us informed on any changes, so we don't need to poll that regularly. If you're interested in learning more about how we do this in our systems, let us know in the comments.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;WebsocketClient&lt;/code&gt; is also a JavaScript class. This abstraction layer is your entry point to request the topics you want to subscribe to. It'll manage the full connection life cycle, including authentication, deduping matching topics, handling heartbeats and persisting connections. If the connection drops, heartbeats will detect this quite quickly (configurable): the SDK will emit a reconnecting event to let your system know there's a gap (aka pause/queue order placement locally), before finally emitting a &lt;code&gt;reconnected&lt;/code&gt; event when the connection is up and running (and resubscribed), which you can use to trigger any post-reconnect checks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;query account state (positions, orders) you may have missed&lt;/li&gt;
&lt;li&gt;reset/amend outdated orders on the exchange&lt;/li&gt;
&lt;li&gt;resume normal workflows (incl executing queued orders if still relevant).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Usage is simple too (simple than raw WebSockets), instance the class (no keys needed for public data), register event listeners (callbacks), and subscribe to topics.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;WebsocketClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@siebly/hyperliquid-api'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WebsocketClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;testnet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'message'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'l2Book'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;levels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'trades'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'response'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Acknowledgement:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'reconnected'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;wsKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Reconnected:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'exception'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'WebSocket exception:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wsKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'l2Book'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'BTC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;nSigFigs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;trades&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'trades'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;coin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ETH'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;book&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;trades&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Later, when the feeds are no longer needed:&lt;/span&gt;
&lt;span class="c1"&gt;// await ws.unsubscribe([book, trades]);&lt;/span&gt;
&lt;span class="c1"&gt;// ws.closeAll();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;subscribe()&lt;/code&gt; resolves once the socket is open and the request has been sent. The server's acknowledgement arrives on the &lt;code&gt;response&lt;/code&gt; event, and data arrives on &lt;code&gt;message&lt;/code&gt; with the upstream envelope intact plus a &lt;code&gt;wsKey&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Coin identifiers such as &lt;code&gt;BTC&lt;/code&gt;, &lt;code&gt;@107&lt;/code&gt; or &lt;code&gt;PURR/USDC&lt;/code&gt; pass straight through. If you want to resolve a readable alias first, there is a helper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;coin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;nameToCoin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'HYPE/USDC'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'trades'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;coin&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reconnect timing, ping interval and pong deadline are all configurable through the constructor options if the defaults do not suit your deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Websocket API: Low Latency Order Placement
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;WebsocketAPIClient&lt;/code&gt; exposes the available REST-like functionality over persisted &amp;amp; managed WebSockets, wrapped around the capabilities of our &lt;code&gt;WebsocketClient&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It will handle the plumbing for you, including mapping your requests (which become upstream WS events) to the received responses (downstream WS events). This unique design in all our SDKs, allows you to benefit from the power of the exchange's WebSocket API, without any of the pains of managing WebSockets. It feels like a REST API.&lt;/p&gt;

&lt;p&gt;Example time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;WebsocketAPIClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@siebly/hyperliquid-api'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WebsocketAPIClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;testnet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAllMids&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fully typed, awaitable WS API commands, in just 4 lines of code. &lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pass a custom logger as the second argument to &lt;code&gt;WebsocketClient&lt;/code&gt; to see pings, subscriptions and messages at trace level.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RestClient&lt;/code&gt; accepts Axios-compatible network options as its second argument, which lets you route requests through a local debugging proxy. Avoid logging signed &lt;code&gt;/exchange&lt;/code&gt; bodies.&lt;/li&gt;
&lt;li&gt;If Hyperliquid ships a new operation before the SDK has a typed wrapper, &lt;code&gt;submitRawInfoRequest()&lt;/code&gt; keeps it usable in the meantime.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Read the &lt;a href="https://siebly.io/sdk/hyperliquid/javascript" rel="noopener noreferrer"&gt;Hyperliquid JavaScript SDK docs&lt;/a&gt; for the overview and feature list.&lt;/li&gt;
&lt;li&gt;Work through the &lt;a href="https://siebly.io/sdk/hyperliquid/javascript/tutorial" rel="noopener noreferrer"&gt;Hyperliquid API JavaScript tutorial for Node.js&lt;/a&gt;, which covers perpetual and Spot orders, account streams, the WebSocket API, testnet and proxies in more depth.&lt;/li&gt;
&lt;li&gt;Follow the &lt;a href="https://github.com/sieblyio/hyperliquid-api/blob/main/docs/HYPERLIQUID_SDK_QUICKSTART_GUIDE.md" rel="noopener noreferrer"&gt;Hyperliquid SDK quickstart guide on GitHub&lt;/a&gt; for complete end-to-end workflows.&lt;/li&gt;
&lt;li&gt;Check &lt;a href="https://siebly.io/releases?sdk=hyperliquid-api" rel="noopener noreferrer"&gt;Hyperliquid SDK release notes&lt;/a&gt; for recent changes.&lt;/li&gt;
&lt;li&gt;Browse the source and examples in the &lt;a href="https://github.com/sieblyio/hyperliquid-api" rel="noopener noreferrer"&gt;sieblyio/hyperliquid-api repository&lt;/a&gt;, or install from &lt;a href="https://www.npmjs.com/package/@siebly/hyperliquid-api" rel="noopener noreferrer"&gt;npm&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who we are
&lt;/h2&gt;

&lt;p&gt;We're &lt;a href="https://github.com/sieblyio" rel="noopener noreferrer"&gt;Siebly&lt;/a&gt;. You might know me, &lt;a href="https://github.com/tiagosiebler" rel="noopener noreferrer"&gt;Tiago&lt;/a&gt;, as the lead dev behind our 10+ massively popular JavaScript SDKs with a decade of usage. Over 4.5 million npm downloads, thousands more every week. &lt;/p&gt;

&lt;p&gt;Questions or bug reports are welcome on the GitHub issues tab. We heavily use our own SDKs in our own systems. We also actively monitor changes to the API surface of every partner exchange that we integrate with. This keeps our SDKs maintained, healthy and reliable. &lt;/p&gt;

&lt;p&gt;What do you want to learn about next? One of our other supported exchanges, or more on algorithmic trading, or more about integrating with Hyperliquid in JavaScript? Let us know in the comments or get in touch!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>hyperliquid</category>
      <category>cryptocurrency</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Tue, 10 Nov 2026 11:47:32 +0000</pubDate>
      <link>https://dev.to/tsts123/-43db</link>
      <guid>https://dev.to/tsts123/-43db</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/favee042/getting-started-with-the-kucoin-api-using-kucoin-api-nodejs-sdk-cfm" class="crayons-story__hidden-navigation-link"&gt;🧪 Getting Started with the KuCoin API Using kucoin-api (Node.js SDK)&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/favee042" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3278988%2F77c94d55-2103-4d5e-bb28-9898cf3ad72d.jpg" alt="favee042 profile" class="crayons-avatar__image" width="400" height="400"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/favee042" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Favour Folorunsho
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Favour Folorunsho
                
                
              
              &lt;div id="story-author-preview-content-2608994" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/favee042" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3278988%2F77c94d55-2103-4d5e-bb28-9898cf3ad72d.jpg" class="crayons-avatar__image" alt="" width="400" height="400"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Favour Folorunsho&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/favee042/getting-started-with-the-kucoin-api-using-kucoin-api-nodejs-sdk-cfm" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 20 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/favee042/getting-started-with-the-kucoin-api-using-kucoin-api-nodejs-sdk-cfm" id="article-link-2608994"&gt;
          🧪 Getting Started with the KuCoin API Using kucoin-api (Node.js SDK)
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/favee042/getting-started-with-the-kucoin-api-using-kucoin-api-nodejs-sdk-cfm" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;3&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/favee042/getting-started-with-the-kucoin-api-using-kucoin-api-nodejs-sdk-cfm#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            2 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Binance APIs made simple in JS</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Mon, 09 Nov 2026 15:00:28 +0000</pubDate>
      <link>https://dev.to/tsts123/binance-apis-made-simple-in-js-1h01</link>
      <guid>https://dev.to/tsts123/binance-apis-made-simple-in-js-1h01</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/siebly/binance-api-javascript-tutorial-for-nodejs-and-typescript-27o0" class="crayons-story__hidden-navigation-link"&gt;Binance API JavaScript Tutorial for Node.js and TypeScript&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/siebly" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" alt="siebly profile" class="crayons-avatar__image" width="400" height="400"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/siebly" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Siebly
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Siebly
                
                
              
              &lt;div id="story-author-preview-content-5004299" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/siebly" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" class="crayons-avatar__image" alt="" width="400" height="400"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Siebly&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/siebly/binance-api-javascript-tutorial-for-nodejs-and-typescript-27o0" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 9&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/siebly/binance-api-javascript-tutorial-for-nodejs-and-typescript-27o0" id="article-link-5004299"&gt;
          Binance API JavaScript Tutorial for Node.js and TypeScript
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/typescript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;typescript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/node"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;node&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/binance"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;binance&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/siebly/binance-api-javascript-tutorial-for-nodejs-and-typescript-27o0" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;4&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/siebly/binance-api-javascript-tutorial-for-nodejs-and-typescript-27o0#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>api</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Wed, 04 Nov 2026 20:30:08 +0000</pubDate>
      <link>https://dev.to/tsts123/-3al9</link>
      <guid>https://dev.to/tsts123/-3al9</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/siebly/gateio-javascript-sdk-quickstart-for-nodejs-and-typescript-474j" class="crayons-story__hidden-navigation-link"&gt;Gate.io JavaScript SDK quickstart for Node.js and TypeScript&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/siebly" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" alt="siebly profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/siebly" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Siebly
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Siebly
                
                
              
              &lt;div id="story-author-preview-content-4976826" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/siebly" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Siebly&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/siebly/gateio-javascript-sdk-quickstart-for-nodejs-and-typescript-474j" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 4&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/siebly/gateio-javascript-sdk-quickstart-for-nodejs-and-typescript-474j" id="article-link-4976826"&gt;
          Gate.io JavaScript SDK quickstart for Node.js and TypeScript
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/typescript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;typescript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/node"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;node&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/siebly/gateio-javascript-sdk-quickstart-for-nodejs-and-typescript-474j" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/siebly/gateio-javascript-sdk-quickstart-for-nodejs-and-typescript-474j#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Wed, 04 Nov 2026 15:33:05 +0000</pubDate>
      <link>https://dev.to/tsts123/-jjo</link>
      <guid>https://dev.to/tsts123/-jjo</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/siebly/hyperliquid-javascript-sdk-quickstart-for-nodejs-and-typescript-31j2" class="crayons-story__hidden-navigation-link"&gt;Hyperliquid JavaScript SDK quickstart for Node.js and TypeScript&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/siebly" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" alt="siebly profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/siebly" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Siebly
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Siebly
                
                
              
              &lt;div id="story-author-preview-content-4976331" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/siebly" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226527%2Fb3889ab9-86c4-4752-8b96-b87dd81238d8.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Siebly&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/siebly/hyperliquid-javascript-sdk-quickstart-for-nodejs-and-typescript-31j2" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 4&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/siebly/hyperliquid-javascript-sdk-quickstart-for-nodejs-and-typescript-31j2" id="article-link-4976331"&gt;
          Hyperliquid JavaScript SDK quickstart for Node.js and TypeScript
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/typescript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;typescript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/hyperliquid"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;hyperliquid&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/node"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;node&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/siebly/hyperliquid-javascript-sdk-quickstart-for-nodejs-and-typescript-31j2" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/siebly/hyperliquid-javascript-sdk-quickstart-for-nodejs-and-typescript-31j2#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Welcome to the world of Algorithmic Trading</title>
      <dc:creator>Tiago</dc:creator>
      <pubDate>Tue, 21 Jul 2026 11:49:24 +0000</pubDate>
      <link>https://dev.to/tsts123/welcome-to-the-world-of-algorithmic-trading-4npo</link>
      <guid>https://dev.to/tsts123/welcome-to-the-world-of-algorithmic-trading-4npo</guid>
      <description>&lt;h1&gt;
  
  
  What is Algorithmic Trading?
&lt;/h1&gt;

&lt;p&gt;Algorithmic trading. It sounds so complicated, so sophisticated, yet comes in so many flavours. Contrary to what your intuition might tell you, it doesn't have to be rocket science. It can be, but it doesn't have to be. The simplest form of algorithmic trading is taking something you can already do manually and automating it.&lt;/p&gt;

&lt;p&gt;That might seem obvious to you, the experienced software developer, but it's such a common assumption for those starting in this space. They think there's a superpower that automatically comes with it. 6 monitors towering over you, sunglasses, standing desk, numbers flying off the screen. Make a bot, buy a bot, instant profit. That's not quite how it works. This isn't Hollywood (sorry). Algorithmic trading in the simplest form is automation. Everything you would do manually can be automated. Some things are easier than others, but there are no exceptions here. Some forms can be complex but they don't have to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where do I start?
&lt;/h2&gt;

&lt;p&gt;Naturally this is the next most common question I see in this space. I know how to code. I'm excited. I'm driven. I don't know what to build. I just know I want to doing what I saw on YouTube. Don't do that. Most of those posting get-rich-quick brags on YouTube don't know what they're doing.&lt;/p&gt;

&lt;p&gt;Start simple. Your first project does not need to be a fully fledged, fully automated, algorithmic trading machine. Often the best ideas happen while you're experimenting with the capabilities. I often recommend to start with partial automation, something that will already help you, improve you, support you, protect you. &lt;/p&gt;

&lt;h2&gt;
  
  
  Partial automation
&lt;/h2&gt;

&lt;p&gt;This is where I would start. The basics. Doesn't sound exciting? Oh it is, and you'd be surprised how powerful this can be. How does it work? Simple: you control entries. See a potential opportunity you want to try? You place the entries, limit orders, or just buy something outright with a market order. Via your favourite exchange's website or app. Doesn't matter.&lt;/p&gt;

&lt;p&gt;Your automation can monitor your account automatically, 24/7, via API keys. As soon as it sees an entry fill (or position update), this is where it wakes up. Fetch necessary details to track position state, for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Market type: spot, futures, etc.&lt;/li&gt;
&lt;li&gt;Position Symbol: BTCUSDT.&lt;/li&gt;
&lt;li&gt;Position Side: Long vs Short (futures only).&lt;/li&gt;
&lt;li&gt;Position Size: 0.001 BTC (always start small).&lt;/li&gt;
&lt;li&gt;Position Cost Average: 60000 USDT (this is the average price your position was built on).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this is &lt;a href="https://siebly.io/examples/Bybit/Websocket/Private/ws-private-v5#L32-L35" rel="noopener noreferrer"&gt;easily tracked&lt;/a&gt; via each exchange's REST APIs &amp;amp; WebSockets. What about authentication etc? That doesn't have to be complicated either, we'll talk about that too. With WebSockets, your system will know within milliseconds that something happened on your account. A fill happened on your account and it's time to wake your system up. Time to act. What do we do from here?&lt;/p&gt;

&lt;h2&gt;
  
  
  Automatic Take Profit
&lt;/h2&gt;

&lt;p&gt;There are so many ways to automating this, from arbitrary math, to using indicators to react to market behaviour (e.g. volatility), but we'll keep it simple. The goal is to make your life as simple as  tapping a button on your phone and letting the system handle the rest. Let's just say when any position is updated, we want to automatically exit any position at 1% profit. We'll also ignore fees to keep it simple.&lt;/p&gt;

&lt;p&gt;Your system already sees position updates as soon as they happen, powered by WebSockets, it already sees position details such as the current position size. You could also track any active (not yet filled) orders, but let's keep it as simple as possible. &lt;/p&gt;

&lt;p&gt;This is the workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Position update arrives&lt;/strong&gt;. New position size is 0.001 BTC long on BTCUSDT at cost average of 60000 USDT. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calculate the exit price&lt;/strong&gt;. Your goal is exit at 1% profit. Your position is long, so you need the price to increase to reach your target. The calculation is simple. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Calculating Take Profit Exit Price
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1% is &lt;code&gt;0.01&lt;/code&gt; in decimal: &lt;code&gt;1% out of 100%&lt;/code&gt; = &lt;code&gt;1/100&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Price needs to increase for profit, so: &lt;code&gt;1 + (1/100)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;= Multiply that by price: (1+(1/100)) x 60000 = 60600. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ignoring fees, we need to exit at 60600 to reach a 1% profit, given our position cost average of 60000. &lt;/p&gt;

&lt;p&gt;Hang on, we're devs, so put that calculator away:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getLongTPTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entryPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;percentTarget&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;decimalTarget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;percentTarget&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;priceTarget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;entryPrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;decimalTarget&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;priceTarget&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;longPositionCostAverageEntryPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;profitTargetPercent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;// 1%&lt;/span&gt;

&lt;span class="c1"&gt;// 60600&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;targetExitPrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getLongTPTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;longPositionCostAverageEntryPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;profitTargetPercent&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your system can easily find the target exit price, given the two simple parameters it already has: target profit in %, current position cost average entry price (at what price you acquired your BTC).&lt;/p&gt;

&lt;h3&gt;
  
  
  Managing Orders
&lt;/h3&gt;

&lt;p&gt;Don't overthink it. Be the lazy dev you were made to be. You don't need to track orders, you don't need complex math, you don't need a complex order management system or state machine.&lt;/p&gt;

&lt;p&gt;The steps in the workflow so far:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebSocket: position update arrived, we know the (new) position cost average entry price, size and symbol.&lt;/li&gt;
&lt;li&gt;Your system: calculated the target price we want to exit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What we don't know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do we have any active orders yet.&lt;/li&gt;
&lt;li&gt;Are we going to hit that price.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We're keeping it simple, so the simplest way to stay in control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cancel all orders for this symbol (you heard that right).&lt;/li&gt;
&lt;li&gt;Set the orders you expect to see.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This way, when your trigger happens (position updated), you always have a clean slate with only the orders that you expect, and you don't need to worry about tracking order state. This makes your system really simple, and a simple system is a resilient one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position update arrives.&lt;/li&gt;
&lt;li&gt;Cancel all orders.&lt;/li&gt;
&lt;li&gt;Set new orders where you expect them. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For your automatic take profit, this is a Limit order. Pseudo code (we'll write real code later):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;longPositionSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.001&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sellOrderResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submitOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'linear'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;symbol&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'BTCUSDT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;side&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Sell'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;orderType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Limit'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`${longPositionSize}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`${targetExitPrice}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;a href="https://siebly.io/examples/Bybit/Rest/rest-v5-private" rel="noopener noreferrer"&gt;example&lt;/a&gt; is inspired by the &lt;a href="https://siebly.io/sdk/bybit/javascript/tutorial" rel="noopener noreferrer"&gt;Siebly JavaScript SDK&lt;/a&gt; for Bybit, one of the leading cryptocurrency exchanges with a rich &amp;amp; reliable API. While the workflow here is minimal, it really can be that simple. With a capable SDK you don't have to worry about connectivity, managing WebSockets, building requests, handling authentication. Focus on the workflow you're looking to automate, let the SDK handle the connectivity for you. WebSockets can be used to easily trigger workflows in your system when a change happens (position updated), while the REST API can commonly be used to execute changes triggered by your workflow (cancel orders, place new orders, etc). This applies to every centralised cryptocurrency exchange's API offering.&lt;/p&gt;

&lt;p&gt;Why use a limit order? This type of order will wait in the order-book for a counter party to fill it. In other words, when the price moves up and crosses your order, it will automatically fill. It's passive, it's simple, and you don't have to worry if your system happens to be offline at that crucial moment. The exchange will track and fill your order for you when the time comes. &lt;/p&gt;

&lt;p&gt;That's it, if you've followed this far, you've seen one of the simplest ways to starting your journey in algorithmic trading. Automate how you exit your positions. Trade as you want, via your exchange's mobile app or website, or even your own automation. Let this workflow manage your exits.&lt;/p&gt;

&lt;h2&gt;
  
  
  How are we?
&lt;/h2&gt;

&lt;p&gt;I'm &lt;a href="https://github.com/tiagosiebler" rel="noopener noreferrer"&gt;Tiago&lt;/a&gt;, lead dev behind &lt;a href="https://siebly.io/" rel="noopener noreferrer"&gt;Siebly&lt;/a&gt;. Nice to e-meet you. My algorithmic systems have executed millions in notional volume across some of the top exchanges. Sounds big, but easier than you think in the algorithmic trading space.  They run 24/7, often months on end, all powered by my own SDKs that I've shared with the world.&lt;/p&gt;

&lt;p&gt;I wanted to build out my own ideas. I wasn't happy with how hard it was to integrate exchange REST APIs &amp;amp; WebSockets. Instead of working on my systems, I lost so much time debugging connectivity issues, dead WebSockets, missed orders. It cost time. It also cost money (liquidations &amp;amp; missed opportunities). That wasn't good enough. The SDKs weren't good enough. So I made my own, how I expect them to be, and I shared them with the world on GitHub &amp;amp; NPM.&lt;/p&gt;

&lt;p&gt;This was almost a decade ago, time flies, and it quickly became clear I wasn't alone. At Siebly we now have &lt;a href="https://siebly.io/#sdks" rel="noopener noreferrer"&gt;9 public SDKs&lt;/a&gt; for 9 cryptocurrency exchanges (so far), quickly approaching 4 million in lifetime downloads with daily users in the thousands! They're here to make APIs &amp;amp; WebSockets easy. Let them handle the plumbing, so you can focus on what's important to you: your system. But enough about me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;What do you want to learn about next? Automating protective orders? Stop loss? Dollar cost averaging into a better position? Dynamic exit pricing? Share your thoughts, we're here for you.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
