Optimization Strategies
This commit is contained in:
@@ -1,148 +1,269 @@
|
||||
About gdptools-feedstock
|
||||
========================
|
||||
# Polymarket Reverse Arbitrage Bot
|
||||
|
||||
Feedstock license: [BSD-3-Clause](https://github.com/conda-forge/gdptools-feedstock/blob/main/LICENSE.txt)
|
||||
TypeScript automation for my Polymarket reverse strategy on **15-minute BTC/ETH Up or Down** markets.
|
||||
|
||||
Home: https://code.usgs.gov/wma/nhgf/toolsteam/gdptools
|
||||
---
|
||||
|
||||
Package license: Unlicense
|
||||
|
||||
Summary: Gdptools
|
||||
|
||||
Current build status
|
||||
====================
|
||||
## My Polymarket account
|
||||
<img width="815" height="291" alt="image" src="https://github.com/user-attachments/assets/0971eb6d-de7e-4f9a-82a1-14a2163db209" />
|
||||
|
||||
|
||||
<table><tr><td>All platforms:</td>
|
||||
<td>
|
||||
<a href="https://dev.azure.com/conda-forge/feedstock-builds/_build/latest?definitionId=17168&branchName=main">
|
||||
<img src="https://dev.azure.com/conda-forge/feedstock-builds/_apis/build/status/gdptools-feedstock?branchName=main">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
| | |
|
||||
|---|---|
|
||||
| **Profile** | [@odahoa](https://polymarket.com/@odahoa?tab=activity) |
|
||||
| **Username** | `odahoa` |
|
||||
| **Proxy wallet** | `0xe2511c9e41c5e762887e538b1d6e7221807aa237` |
|
||||
| **Markets** | `btc-updown-15m`, `eth-updown-15m` |
|
||||
|
||||
Current release info
|
||||
====================
|
||||
All activity, positions, and PnL live on my profile:
|
||||
**https://polymarket.com/@odahoa?tab=activity**
|
||||
|
||||
| Name | Downloads | Version | Platforms |
|
||||
| --- | --- | --- | --- |
|
||||
| [](https://anaconda.org/conda-forge/gdptools) | [](https://anaconda.org/conda-forge/gdptools) | [](https://anaconda.org/conda-forge/gdptools) | [](https://anaconda.org/conda-forge/gdptools) |
|
||||
This bot trades **from that account** — it automates what I already do manually. It is not copy trading and does not watch any other wallet.
|
||||
|
||||
Installing gdptools
|
||||
===================
|
||||
---
|
||||
|
||||
Installing `gdptools` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with:
|
||||
## Overview
|
||||
|
||||
Polymarket runs 15-minute windows like:
|
||||
|
||||
> **Bitcoin Up or Down — 1:45PM–2:00PM ET**
|
||||
|
||||
Each window has two tokens:
|
||||
|
||||
| Token | Wins when |
|
||||
|-------|-----------|
|
||||
| **Up** | Price at end ≥ price at start |
|
||||
| **Down** | Price at end < price at start |
|
||||
|
||||
Winning tokens pay **$1.00**. Losing tokens pay **$0.00**.
|
||||
|
||||
My strategy — the **reverse bot** — posts limit **BUY** orders on **both sides** every window:
|
||||
|
||||
1. **Cheap reversal side (7–10¢)** on the underdog outcome
|
||||
2. **Expensive hedge side (90–95¢)** on the favorite outcome
|
||||
|
||||
That is the same pattern visible on my [activity tab](https://polymarket.com/@odahoa?tab=activity): round limit prices (7¢, 8¢, 10¢ … 95¢), 20–90 shares per fill, no sells — hold to resolution.
|
||||
|
||||
---
|
||||
|
||||
## Why "reverse"?
|
||||
|
||||
Early in a window, price often trends one way:
|
||||
|
||||
```
|
||||
conda config --add channels conda-forge
|
||||
conda config --set channel_priority strict
|
||||
BTC pumps in first 10 minutes
|
||||
→ Up token ~90–97¢ (favorite)
|
||||
→ Down token ~3–10¢ (underdog)
|
||||
```
|
||||
|
||||
Once the `conda-forge` channel has been enabled, `gdptools` can be installed with `conda`:
|
||||
The crowd prices the underdog as nearly dead. The **reverse bet** is: *it flips before the window closes*.
|
||||
|
||||
| Leg | Outcome | Entry | If it wins |
|
||||
|-----|---------|-------|------------|
|
||||
| **Reverse** | Underdog | 7–10¢ | ~10–14× |
|
||||
| **Hedge** | Favorite | 90–95¢ | ~5–11% |
|
||||
|
||||
Only one side pays $1 per window. I run both legs because:
|
||||
|
||||
- Cheap fills are rare but pay huge when they hit.
|
||||
- Hedge fills are smaller profit but hit more often.
|
||||
- Over hundreds of windows, a few reversals cover many losses.
|
||||
|
||||
---
|
||||
|
||||
## How I trade (manual → bot)
|
||||
|
||||
From my account history:
|
||||
|
||||
| Pattern | Detail |
|
||||
|---------|--------|
|
||||
| Markets | BTC & ETH 15m Up/Down only |
|
||||
| Order type | Limit BUY only — never sell |
|
||||
| Cheap leg | Fills at 7–10¢ (sometimes 5–25¢) on underdog |
|
||||
| Hedge leg | Fills at 90–95¢ on favorite |
|
||||
| Both sides | Same window — e.g. Down @ 95¢ and Up @ 15¢ |
|
||||
| Size | 20–90 shares per order |
|
||||
|
||||
The bot replaces hand-placing every limit order each window.
|
||||
|
||||
---
|
||||
|
||||
## Bot logic
|
||||
|
||||
Every **5 seconds** (configurable):
|
||||
|
||||
```
|
||||
conda install gdptools
|
||||
1. Scan active btc-updown-15m / eth-updown-15m markets
|
||||
2. Load Up & Down order books (CLOB API)
|
||||
3. Underdog = outcome with lower best ask
|
||||
4. Favorite = the other outcome
|
||||
5. Post limit BUYs on underdog @ 7¢, 8¢, 9¢, 10¢
|
||||
6. Post limit BUYs on favorite @ 90¢–95¢ (if hedge enabled)
|
||||
7. Skip price levels already posted this session
|
||||
```
|
||||
|
||||
or with `mamba`:
|
||||
### Cheap leg — underdog @ 7–10¢
|
||||
|
||||
```
|
||||
mamba install gdptools
|
||||
Down best ask = 4¢ → bot bids 7¢, 8¢, 9¢, 10¢ on Down
|
||||
```
|
||||
|
||||
It is possible to list all of the versions of `gdptools` available on your platform with `conda`:
|
||||
If Down reverses and wins:
|
||||
|
||||
```
|
||||
conda search gdptools --channel conda-forge
|
||||
90 shares × 8¢ = $7.20 in
|
||||
90 shares × $1 = $90.00 out → +$82.80 (~1,150%)
|
||||
```
|
||||
|
||||
or with `mamba`:
|
||||
### Hedge leg — favorite @ 90–95¢
|
||||
|
||||
```
|
||||
mamba search gdptools --channel conda-forge
|
||||
Up best ask = 97¢ → bot bids 90¢–95¢ on Up
|
||||
```
|
||||
|
||||
Alternatively, `mamba repoquery` may provide more information:
|
||||
If Up holds and wins:
|
||||
|
||||
```
|
||||
# Search all versions available on your platform:
|
||||
mamba repoquery search gdptools --channel conda-forge
|
||||
|
||||
# List packages depending on `gdptools`:
|
||||
mamba repoquery whoneeds gdptools --channel conda-forge
|
||||
|
||||
# List dependencies of `gdptools`:
|
||||
mamba repoquery depends gdptools --channel conda-forge
|
||||
52 shares × 95¢ = $49.40 in
|
||||
52 shares × $1 = $52.00 out → +$2.60 (~5%)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
About conda-forge
|
||||
=================
|
||||
## Example window
|
||||
|
||||
[](https://numfocus.org)
|
||||
**Market:** Bitcoin Up or Down — 1:45–2:00 PM ET
|
||||
**BTC pumped early** → Up favored, Down cheap
|
||||
|
||||
conda-forge is a community-led conda channel of installable packages.
|
||||
In order to provide high-quality builds, the process has been automated into the
|
||||
conda-forge GitHub organization. The conda-forge organization contains one repository
|
||||
for each of the installable packages. Such a repository is known as a *feedstock*.
|
||||
| Token | Book | Bot posts |
|
||||
|-------|------|-----------|
|
||||
| Up (favorite) | ask 97¢ | BUY limits @ 90–95¢ |
|
||||
| Down (underdog) | ask 4¢ | BUY limits @ 7–10¢ |
|
||||
|
||||
A feedstock is made up of a conda recipe (the instructions on what and how to build
|
||||
the package) and the necessary configurations for automatic building using freely
|
||||
available continuous integration services. Thanks to the awesome service provided by
|
||||
[Azure](https://azure.microsoft.com/en-us/services/devops/), [GitHub](https://github.com/),
|
||||
[CircleCI](https://circleci.com/), [AppVeyor](https://www.appveyor.com/),
|
||||
[Drone](https://cloud.drone.io/welcome), and [TravisCI](https://travis-ci.com/)
|
||||
it is possible to build and upload installable packages to the
|
||||
[conda-forge](https://anaconda.org/conda-forge) [anaconda.org](https://anaconda.org/)
|
||||
channel for Linux, Windows and OSX respectively.
|
||||
| Result | Cheap leg | Hedge leg |
|
||||
|--------|-----------|-----------|
|
||||
| Up wins | Down → $0 | Up → small profit |
|
||||
| Down reverses | Down → big profit | Up → $0 |
|
||||
|
||||
To manage the continuous integration and simplify feedstock maintenance
|
||||
[conda-smithy](https://github.com/conda-forge/conda-smithy) has been developed.
|
||||
Using the ``conda-forge.yml`` within this repository, it is possible to re-render all of
|
||||
this feedstock's supporting files (e.g. the CI configuration files) with ``conda smithy rerender``.
|
||||
---
|
||||
|
||||
For more information please check the [conda-forge documentation](https://conda-forge.org/docs/).
|
||||
## Return table
|
||||
|
||||
Terminology
|
||||
===========
|
||||
| Buy price | Payout | Return if win |
|
||||
|-----------|--------|---------------|
|
||||
| 7¢ | $1.00 | +1,329% |
|
||||
| 8¢ | $1.00 | +1,150% |
|
||||
| 9¢ | $1.00 | +1,011% |
|
||||
| 10¢ | $1.00 | +900% |
|
||||
| 95¢ | $1.00 | +5% |
|
||||
|
||||
**feedstock** - the conda recipe (raw material), supporting scripts and CI configuration.
|
||||
Most 7–10¢ bets go to zero. Edge comes from occasional reversals at high multiples.
|
||||
|
||||
**conda-smithy** - the tool which helps orchestrate the feedstock.
|
||||
Its primary use is in the construction of the CI ``.yml`` files
|
||||
and simplify the management of *many* feedstocks.
|
||||
---
|
||||
|
||||
**conda-forge** - the place where the feedstock and smithy live and work to
|
||||
produce the finished article (built conda distributions)
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
git clone https://github.com/abwhaoms502/polymarket-reverse-arbitrage-bot
|
||||
cd reverse-bot
|
||||
npm install
|
||||
cp .env.example .env
|
||||
npm start # dry-run: logs orders, no submission
|
||||
```
|
||||
|
||||
Updating gdptools-feedstock
|
||||
===========================
|
||||
### Go live on @odahoa
|
||||
|
||||
If you would like to improve the gdptools recipe or build a new
|
||||
package version, please fork this repository and submit a PR. Upon submission,
|
||||
your changes will be run on the appropriate platforms to give the reviewer an
|
||||
opportunity to confirm that the changes result in a successful build. Once
|
||||
merged, the recipe will be re-built and uploaded automatically to the
|
||||
`conda-forge` channel, whereupon the built conda packages will be available for
|
||||
everybody to install and use from the `conda-forge` channel.
|
||||
Note that all branches in the conda-forge/gdptools-feedstock are
|
||||
immediately built and any created packages are uploaded, so PRs should be based
|
||||
on branches in forks and branches in the main repository should only be used to
|
||||
build distinct package versions.
|
||||
```env
|
||||
DRY_RUN=false
|
||||
PRIVATE_KEY=0x... # account signing key
|
||||
FUNDER_ADDRESS=0xe2511c9e41c5e762887e538b1d6e7221807aa237 # @odahoa proxy wallet
|
||||
SIGNATURE_TYPE=2
|
||||
```
|
||||
|
||||
In order to produce a uniquely identifiable distribution:
|
||||
* If the version of a package **is not** being increased, please add or increase
|
||||
the [``build/number``](https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#build-number-and-string).
|
||||
* If the version of a package **is** being increased, please remember to return
|
||||
the [``build/number``](https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#build-number-and-string)
|
||||
back to 0.
|
||||
| `SIGNATURE_TYPE` | Use for |
|
||||
|------------------|---------|
|
||||
| `0` | EOA / MetaMask |
|
||||
| `2` | Gnosis Safe proxy *(typical Polymarket account)* |
|
||||
| `3` | POLY_1271 deposit wallet |
|
||||
|
||||
Feedstock Maintainers
|
||||
=====================
|
||||
---
|
||||
|
||||
* [@ocefpaf](https://github.com/ocefpaf/)
|
||||
* [@rmcd-mscb](https://github.com/rmcd-mscb/)
|
||||
## Config
|
||||
|
||||
### Strategy
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `CHEAP_BUY_MIN` | `0.07` | Low end of reversal bids |
|
||||
| `CHEAP_BUY_MAX` | `0.10` | High end of reversal bids |
|
||||
| `CHEAP_ORDER_USDC` | `10` | USDC per cheap limit order |
|
||||
| `ENABLE_EXPENSIVE_HEDGE` | `true` | Post 90–95¢ favorite bids |
|
||||
| `EXPENSIVE_BUY_MIN` | `0.90` | Low end of hedge bids |
|
||||
| `EXPENSIVE_BUY_MAX` | `0.95` | High end of hedge bids |
|
||||
| `EXPENSIVE_ORDER_USDC` | `50` | USDC per hedge limit order |
|
||||
| `MAX_SHARES_PER_ORDER` | `90` | Max shares per order |
|
||||
|
||||
### Markets & timing
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `MARKET_SLUG_PREFIXES` | `btc-updown-15m,eth-updown-15m` | Markets to scan |
|
||||
| `POLL_INTERVAL_MS` | `5000` | Scan interval |
|
||||
| `MINUTES_BEFORE_CLOSE_MIN` | `0` | Start trading N min into window |
|
||||
| `MINUTES_BEFORE_CLOSE_MAX` | `15` | Stop trading N min before close |
|
||||
|
||||
Trade only late window (when cheap tokens show up):
|
||||
|
||||
```env
|
||||
MINUTES_BEFORE_CLOSE_MIN=3
|
||||
MINUTES_BEFORE_CLOSE_MAX=12
|
||||
```
|
||||
|
||||
### Safety
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `DRY_RUN` | `true` | Log only — no real orders |
|
||||
|
||||
---
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
reverse-bot/
|
||||
├── src/
|
||||
│ ├── index.ts # main loop
|
||||
│ ├── market-scanner.ts # active 15m markets + books
|
||||
│ ├── strategy.ts # underdog/favorite + limit prices
|
||||
│ ├── trader.ts # CLOB order submission
|
||||
│ └── config.ts
|
||||
├── .env.example
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
npm start # run bot
|
||||
npm run dev # run with hot reload
|
||||
npm run build # compile TypeScript
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Risks
|
||||
|
||||
- **Most cheap bids lose.** 7–10¢ tokens frequently expire worthless.
|
||||
- **Limits may not fill.** Bidding 7¢ when ask is 4¢ waits for sellers.
|
||||
- **Both legs can't both win.** One side always goes to $0.
|
||||
- **Real money.** Test with `DRY_RUN=true` first.
|
||||
|
||||
---
|
||||
|
||||
## Links
|
||||
|
||||
- My profile: https://polymarket.com/@odahoa
|
||||
- My activity: https://polymarket.com/@odahoa?tab=activity
|
||||
- Polymarket settings: https://polymarket.com/settings
|
||||
|
||||
Reference in New Issue
Block a user