create account

A Day in the Life of a JavaScript Dev: HIVE.TRADING Tweaks & Bag Randomization in the L1 Marketmaker by hive.trading

View this thread on: hive.blogpeakd.comecency.com
· @hive.trading ·
$3.13
A Day in the Life of a JavaScript Dev: HIVE.TRADING Tweaks & Bag Randomization in the L1 Marketmaker
Hey fellow JS devs! Today we rolled up our sleeves and shipped out two neat updates across our various HIVE and HIVE-ENGINE trading bots which you can find and use on https://hive.trading:


![openart-image_Cjk2YPgi_1751688618875_raw.jpg](https://files.peakd.com/file/peakd-hive/hive.trading/AK7sTVodL7pAAd4nRo6C1zeGscmxGRupyt6Zxv7fkH8vKWQW5yDQEaAd8fpBhxX.jpg)

# 1. Hive-Engine Market-Maker (HEMM) Bot Improvements
What We Added:

Order-Price Filters

do_not_buy_equal_and_above

do_not_sell_equal_and_below

These optional settings let you set hard price ceilings/floors so the bot never accidentally buys too high or sells too low. Blank by default, they’re just safety nets you can toggle on when you want extra control.

Why It Matters:
Without these filters, the bot simply undercuts the best bid or ask by one tick—fine for “pure” market-making, but risky if there’s a flash pump or a sudden dump. Now you can say “never buy at or above 0.12 HIVE” or “never sell at or below 0.09 HIVE,” and rest easy.

# Implementation Highlights:

We extended our storage JSON schema to include the two new keys in each user’s settings block.

In the trade loop, we parse them as floats and bail early if the computed price violates your thresholds.

Everything else remains… well, the same familiar JS async/await pattern you know and love.

# 2. Bag Randomization in the L1 Market-Maker Bot
What We Added:
Rather than iterating through users in a fixed order (which can leave late joiners perpetually at the end of the queue), we now:

Shuffle the user list on each run

Process orders in a new random sequence each interval

Why It Matters:
Imagine 100 users, and you always start with user #1. Over time, #1 racks up prime bid/ask spots while #100 is always last to post orders—less chance to capture the spread! Bag randomization is the classic “fair draw” approach: everyone’s equally likely to trade first.

Implementation Highlights:

<code>// Simple Fisher–Yates shuffle
function shuffle(array) {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
}
…  
let users = jsonData.users.filter(u => !expired(u));
shuffle(users);
for (const user of users) {
  await processTradesForUser(user);
}</code>

Note: We plan on adding this feature to the Hive-Engine Market Maker bot too, and all other bots ASAP!

# Wrapping Up
HEMM Bot got smarter order filters and block-aware timing so you can burn BEED fees without hiccups and enforce price safety rails.

L1 Marketmaker leveled the playing field with bag randomization, so no one is “always last” in the order queue.

All in all, a very productive sprint! ⚙️✌️ Let me know what you think or if you spot any edge cases we should handle next.

Happy coding!
— Follow @hive.trading for more from your friendly neighborhood JS trader bot & maintainer.
👍  , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorhive.trading
permlinka-day-in-the-life-of-a-javascript-dev-hivetrading-tweaks-and-bag-randomization-in-the-l1-marketmaker
categoryarcadecolony
json_metadata"{"app":"peakd/2025.6.4","format":"markdown","description":"Latest updates to hive.trading bots!","tags":["arcadecolony","tribes","hive-engine","pob","hive-trading","bots","alive","leofinance","bbh","pepe"],"users":["hive.trading"],"image":["https://files.peakd.com/file/peakd-hive/hive.trading/AK7sTVodL7pAAd4nRo6C1zeGscmxGRupyt6Zxv7fkH8vKWQW5yDQEaAd8fpBhxX.jpg"]}"
created2025-07-05 04:26:57
last_update2025-07-05 04:26:57
depth0
children2
last_payout2025-07-12 04:26:57
cashout_time1969-12-31 23:59:59
total_payout_value1.568 HBD
curator_payout_value1.566 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,891
author_reputation187,207,084,852
root_title"A Day in the Life of a JavaScript Dev: HIVE.TRADING Tweaks & Bag Randomization in the L1 Marketmaker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id143,760,960
net_rshares9,728,308,104,286
author_curate_reward""
vote details (23)
@hivebuzz ·
Congratulations @hive.trading! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

<table><tr><td><img src="https://images.hive.blog/60x70/https://hivebuzz.me/@hive.trading/upvoted.png?202507051209"></td><td>You received more than 10 upvotes.<br>Your next target is to reach 50 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@hive.trading) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Check out our last posts:**
<table><tr><td><a href="/hive-122221/@hivebuzz/pum-202506-delegations"><img src="https://images.hive.blog/64x128/https://i.imgur.com/fg8QnBc.png"></a></td><td><a href="/hive-122221/@hivebuzz/pum-202506-delegations">Our Hive Power Delegations to the June PUM Winners</a></td></tr><tr><td><a href="/hive-122221/@hivebuzz/pud-202507-feedback"><img src="https://images.hive.blog/64x128/https://i.imgur.com/zHjYI1k.jpg"></a></td><td><a href="/hive-122221/@hivebuzz/pud-202507-feedback">Feedback from the July Hive Power Up Day</a></td></tr><tr><td><a href="/hive-122221/@hivebuzz/pum-202506-result"><img src="https://images.hive.blog/64x128/https://i.imgur.com/mzwqdSL.png"></a></td><td><a href="/hive-122221/@hivebuzz/pum-202506-result">Hive Power Up Month Challenge - June 2025 Winners List</a></td></tr></table>
properties (22)
authorhivebuzz
permlinknotify-1751717703
categoryarcadecolony
json_metadata{"image":["https://hivebuzz.me/notify.t6.png"]}
created2025-07-05 12:15:03
last_update2025-07-05 12:15:03
depth1
children0
last_payout2025-07-12 12:15:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,477
author_reputation369,393,477,946,370
root_title"A Day in the Life of a JavaScript Dev: HIVE.TRADING Tweaks & Bag Randomization in the L1 Marketmaker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id143,765,620
net_rshares0
@theguruasia ·
$WINE
properties (22)
authortheguruasia
permlinkre-hivetrading-sywv0j
categoryarcadecolony
json_metadata{"tags":["arcadecolony"],"app":"peakd/2025.6.4","image":[],"users":[]}
created2025-07-05 05:24:18
last_update2025-07-05 05:24:18
depth1
children0
last_payout2025-07-12 05:24:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5
author_reputation72,544,660,224,638
root_title"A Day in the Life of a JavaScript Dev: HIVE.TRADING Tweaks & Bag Randomization in the L1 Marketmaker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id143,761,429
net_rshares0