Unique Title: I constructed a Polymarket bot and examined a number of parameter setups, listed here are the outcomes.Unique Creator: @the_smart_ape, Cryptocurrency ResearcherOriginal Compilation: Bitpush Information
A number of weeks in the past, I made a decision to construct my very own Polymarket bot. The complete model took me a number of weeks to finish.
I used to be keen to speculate this effort as a result of there are certainly inefficiencies on Polymarket that may be exploited. Though some bots are already capitalizing on these inefficiencies, it’s removed from enough. The market nonetheless presents much more alternatives than the variety of bots out there.
The logic behind this bot relies on a technique I beforehand executed manually. To enhance effectivity, I automated the method. The bot operates within the ‘BTC 15-minute UP/DOWN’ market.
The bot runs a real-time monitoring program that robotically switches to the present BTC 15-minute spherical, streams the very best bid/ask costs through WebSocket, shows a set terminal UI, and permits full management by textual content instructions.

In handbook mode, you possibly can place orders straight.
purchase up / purchase down: Purchase a particular greenback quantity.
Buyshares up / buyshares down: Buy an actual variety of shares utilizing a user-friendly LIMIT + GTC (Good-Til-Canceled) order, executed on the present finest ask worth.
The automated mode runs a repetitive two-leg loop.
In step one, it solely observes worth fluctuations inside the windowMin minutes after the beginning of every spherical. If both facet falls quickly sufficient (a decline of at the very least movePct inside roughly 3 seconds), it triggers ‘Leg 1,’ buying the facet that has plummeted.
After finishing Leg 1, the bot won’t ever buy the identical facet once more. It waits for ‘Leg 2’ (i.e., hedging) and triggers it solely when the next situation is met: leg1EntryPrice + oppositeAsk <= sumTarget.
When this situation is glad, it purchases the alternative facet. After finishing Leg 2, the loop ends, and the bot returns to commentary mode, ready for the subsequent plunge sign with the identical parameters.
If the spherical adjustments through the loop, the bot abandons the open loop and restarts with the identical settings within the subsequent spherical.
The parameter settings for automated mode are as follows: auto on (sum=0.95) (transfer=0.15) (windowMin=2).
· Shares: The place measurement used for the 2 legs of buying and selling.
· Sum: The brink permitting for hedging.
· Transfer (movePct): The plunge threshold (e.g., 0.15 = 15%).
· windowMin: The period allowed for executing Leg 1, ranging from every spherical.
The logic of the bot is straightforward: anticipate a violent sell-off, purchase the facet that has simply completed falling, then anticipate the worth to stabilize and hedge by buying the alternative facet, whereas making certain: priceUP + priceDOWN < 1.
Nonetheless, this logic must be examined. Does it actually work in the long run? Extra importantly, the bot has many parameters (variety of shares, whole quantity, proportion motion, window minutes, and so on.). Which parameter set is perfect and might maximize income?
My first thought was to let the bot run stay for every week and observe the outcomes. The difficulty is that it takes too lengthy and might solely check one set of parameters, whereas I want to check many units.
My second thought was to carry out backtesting utilizing on-line historic knowledge from the Polymarket CLOB API. Sadly, for the BTC 15-minute up/down market, the historic knowledge endpoint persistently returns an empty dataset. With out historic worth ticks, backtesting can’t detect ‘a pointy drop inside roughly 3 seconds,’ failing to set off Leg 1, leading to 0 cycles and 0% return on funding (ROI) whatever the parameters.

After additional investigation, I discovered that different customers have encountered the identical problem when retrieving historic knowledge for sure markets. I examined different markets that did return historic knowledge and concluded that, for this particular market, historic knowledge merely has not been retained.
As a consequence of this limitation, the one dependable strategy to backtest this technique is to create my very own historic dataset by recording real-time best-ask costs whereas the bot is operating.

The recorder writes snapshots to disk, containing the next:
· Timestamp
· Spherical slug
· Remaining seconds
· UP/DOWN token ID
· UP/DOWN finest ask worth
Subsequently, the “recorded backtest” replays these snapshots and applies the identical automated logic deterministically. This ensures entry to high-frequency knowledge required for detecting crashes and hedging situations.
I collected a complete of 6 GB of information over 4 days. I might have recorded extra, however I imagine that is enough to check totally different parameter units.

I started testing the next set of parameters:
· Preliminary stability: $1,000
· 20 shares per commerce
· sumTarget = 0.95
· Crash threshold = 15%
· windowMin = 2 minutes
I additionally utilized a relentless charge price of 0.5% and a diffusion of two% to stay inside a conservative situation.
The backtest confirmed an ROI of 86%, with $1,000 turning into $1,869 in only a few days.

I then examined a extra aggressive set of parameters:
· Preliminary stability: $1,000
· 20 shares per commerce
· sumTarget = 0.6
· Crash threshold = 1%
· windowMin = quarter-hour
Outcome: The return on funding was -50% after two days.

This clearly demonstrates that parameter choice is essentially the most crucial issue. It may possibly both generate vital income or result in substantial losses.
Even when charges and spreads are included, backtesting nonetheless has its limitations.
· Firstly, it solely makes use of just a few days of information, which will not be enough to realize a complete view of the market.
· It depends on snapshots of the very best recorded ask costs; in actuality, orders could be partially stuffed or executed at various costs. Moreover, the depth of the order guide and out there buying and selling volumes are usually not modeled.
· Micro-fluctuations beneath the second degree are usually not captured (knowledge sampled as soon as per second). Though backtesting consists of timestamps at one-second intervals, many occasions can happen between every second.
· Slippage is handled as fixed in backtesting, with out simulating variable delays (e.g., 200–1500 milliseconds) or community spikes.
· Every commerce phase is assumed to execute “instantaneously” (with out order queuing or pending orders).
· Charges are utilized uniformly, whereas in actuality, they could rely upon components corresponding to market/token, maker/taker roles, charge tiers, or situations.
To stay pessimistic (prudent), I utilized a rule: if Leg 2 fails to execute earlier than the market closes, Leg 1 can be thought of a complete loss.
That is intentionally conservative however doesn’t at all times mirror actuality:
· Generally Leg 1 will be closed early,
· Generally it finally ends up in-the-money (ITM) and wins,
· Generally the loss will be partial moderately than whole.
Though the loss could also be overstated, this gives a sensible ‘worst-case’ situation.
Most significantly, backtesting can’t simulate the affect of your giant orders on the order guide or entice different merchants to prey in your actions. In actuality, your orders can:
· Disturb the order guide,
· Entice or repel different merchants,
· Trigger non-linear slippage.
Backtesting assumes you’re a pure liquidity taker with no affect in anyway.
Lastly, it doesn’t simulate price limits, API errors, rejected orders, suspensions, timeouts, reconnections, or conditions the place the bot misses alerts attributable to being busy.
Backtesting is extraordinarily helpful for figuring out good parameter ranges, however it isn’t a 100% assure, as some real-world results can’t be modeled.
I plan to run the bot on a Raspberry Pi to keep away from consuming assets on my essential machine and to keep up 24/7 operation.
Nonetheless, there’s nonetheless vital room for enchancment:
· Utilizing Rust as an alternative of JavaScript would offer far superior efficiency and processing time.
· Working a devoted Polygon RPC node would additional scale back latency.
· Deploying on a VPS near Polymarket’s servers would additionally considerably scale back latency.
There are actually different optimization strategies that I’ve but to find. At present, I’m studying Rust, as it’s changing into an indispensable language in Web3 improvement.
https://weblog.passive-income4u.com/create-your-very-own-auto-publish-news-blog-site-and-earn-passive-income-in-just-4-easy-steps/


