<?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: Alexey Polyakov</title>
    <description>The latest articles on DEV Community by Alexey Polyakov (@alexey_polyakov_cfe2095e3).</description>
    <link>https://dev.to/alexey_polyakov_cfe2095e3</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3977419%2F4ba77741-d2f9-4ae7-be8e-4683889ce5fc.jpg</url>
      <title>DEV Community: Alexey Polyakov</title>
      <link>https://dev.to/alexey_polyakov_cfe2095e3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexey_polyakov_cfe2095e3"/>
    <language>en</language>
    <item>
      <title>I Built an AI-Native Trading Engine in Python. Here's How It Works</title>
      <dc:creator>Alexey Polyakov</dc:creator>
      <pubDate>Wed, 10 Jun 2026 10:04:06 +0000</pubDate>
      <link>https://dev.to/alexey_polyakov_cfe2095e3/i-built-an-ai-native-trading-engine-in-python-heres-how-it-works-54p0</link>
      <guid>https://dev.to/alexey_polyakov_cfe2095e3/i-built-an-ai-native-trading-engine-in-python-heres-how-it-works-54p0</guid>
      <description>&lt;h1&gt;
  
  
  I Built an AI-Native Trading Engine in Python. Here's How It Works
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;9 strategies, 24/7 WebSocket monitoring, AI scoring, and full agent-based orchestration. Open source, MIT.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Why I Built This
&lt;/h2&gt;

&lt;p&gt;Trading bots are either black-box subscriptions at $50/month, or DIY scripts that break at 3 AM. I wanted a system that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Runs unattended&lt;/strong&gt; — fire and forget&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understands context&lt;/strong&gt; — not just "RSI &amp;lt; 30 = buy", but scoring across 9 metrics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responds to voice/text&lt;/strong&gt; — "go AVAX x10" and the AI agent executes everything&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is open source&lt;/strong&gt; — so anyone can fork and customize&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's how &lt;strong&gt;bybit-ws&lt;/strong&gt; was born — an AI-native trading engine for Bybit.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture at a Glance
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────┐
│                  Hermes Agent                     │
│  (AI orchestrator: voice, text, auto-entry)      │
└──────────────┬──────────────────────────────────┘
               │ MCP / REST
┌──────────────▼──────────────────────────────────┐
│              bybit-ws (systemd)                   │
│  main.py → 30s cycle                             │
│  ├── auto_entry.py   (LONG via scoring)           │
│  ├── auto_short.py   (SHORT Tier A/B + junk)      │
│  ├── auto_sl.py      (BB-based stop-loss)         │
│  ├── auto_tp.py      (auto take-profit)           │
│  ├── bb_scalp.py     (⚡ x10 M5 scalping)         │
│  ├── mean_revert.py  (⚡ x10 extreme reversals)    │
│  ├── funding_entry.py(⚡ x10 funding momentum)     │
│  ├── dca.py          (ladder entries)              │
│  ├── rpc.py          (HTTP-RPC on port 8766)      │
│  └── dashboard.py    (SVG dashboard)              │
└──────────────┬──────────────────────────────────┘
               │ WebSocket
┌──────────────▼──────────────────────────────────┐
│               Bybit API v5                        │
└─────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Core principle: &lt;strong&gt;one module = one file&lt;/strong&gt;. Not a 5,000-line monolith, but 30+ files with clear responsibilities.&lt;/p&gt;




&lt;h2&gt;
  
  
  9 Strategies — From Conservative to Extreme
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Leverage&lt;/th&gt;
&lt;th&gt;Timeframe&lt;/th&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bollinger Grid LONG&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;Lower BB −3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bollinger Grid SHORT&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;BB &amp;gt;85%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Junk Short&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;Pump ≥80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SL Re-entry&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;Lower BB after stop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DCA Ladder&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;−5/−10/−15% from entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ BB Scalping&lt;/td&gt;
&lt;td&gt;10x&lt;/td&gt;
&lt;td&gt;M5&lt;/td&gt;
&lt;td&gt;Band touch + RSI filter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ Mean Reversion&lt;/td&gt;
&lt;td&gt;10x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;BB% &amp;lt;5% or &amp;gt;95%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ Funding Momentum&lt;/td&gt;
&lt;td&gt;10x&lt;/td&gt;
&lt;td&gt;Daily&lt;/td&gt;
&lt;td&gt;Extreme funding rate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ ATR Risk Sizing&lt;/td&gt;
&lt;td&gt;layer&lt;/td&gt;
&lt;td&gt;15m&lt;/td&gt;
&lt;td&gt;Validation: SL = 1.5×ATR&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The golden rule:&lt;/strong&gt; the system doesn't guess. Every entry passes through &lt;strong&gt;scoring across 8+ metrics&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tier bonus (S/A/B/C/D token)&lt;/li&gt;
&lt;li&gt;BB% position (0–100%)&lt;/li&gt;
&lt;li&gt;24h volume&lt;/li&gt;
&lt;li&gt;RSI(14)&lt;/li&gt;
&lt;li&gt;Funding rate&lt;/li&gt;
&lt;li&gt;BB Squeeze (band compression)&lt;/li&gt;
&lt;li&gt;Consecutive down days&lt;/li&gt;
&lt;li&gt;Weekly/monthly BB%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Minimum threshold: &lt;strong&gt;5.5/10&lt;/strong&gt;. Anything below — the system silently skips.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Integration: More Than Buttons
&lt;/h2&gt;

&lt;p&gt;The interesting part is the AI layer. I use &lt;strong&gt;Hermes Agent&lt;/strong&gt; (by Nous Research) as the orchestrator:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP Server&lt;/strong&gt;: the agent sees positions, orders, and metrics through a standardized protocol&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;REST API&lt;/strong&gt;: port 8766, CORS, rate-limiting, RPC token&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-entry&lt;/strong&gt;: the agent decides on entries based on scoring&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GridSignal Bot&lt;/strong&gt; (@GridSignalBot on Telegram): real-time scanner, LONG/SHORT/x10 buttons&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Me: "go AVAX x10 at market"
Agent: checks BB%, RSI, funding, correlations
       → scoring 7.2/10 → OK
       → calculates: margin=$5, qty=15.1, SL=−5%
       → order placed: 53e99c39
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All via voice or text. While driving, on shift, in the shower — doesn't matter.&lt;/p&gt;




&lt;h2&gt;
  
  
  Numbers &amp;amp; Hardware
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python 3.11&lt;/strong&gt;, systemd service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebSocket&lt;/strong&gt; — real-time data from Bybit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;30-second light cycle&lt;/strong&gt; — positions, orders, health&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;7-minute heavy cycle&lt;/strong&gt; — scoring, BB, RSI, squeeze, auto-entry&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory&lt;/strong&gt;: ~200 MB at runtime&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uptime&lt;/strong&gt;: weeks without restart&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🔜 &lt;strong&gt;Telegram Mini App&lt;/strong&gt; — dashboard right in Telegram&lt;/li&gt;
&lt;li&gt;🔜 &lt;strong&gt;Paper trading mode&lt;/strong&gt; — risk-free testing&lt;/li&gt;
&lt;li&gt;🔜 &lt;strong&gt;Docker one-liner&lt;/strong&gt; — &lt;code&gt;docker run&lt;/code&gt; and done&lt;/li&gt;
&lt;li&gt;🔮 &lt;strong&gt;OKX/Binance support&lt;/strong&gt; — multi-exchange&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/poliakarmai/bybit-ws
&lt;span class="nb"&gt;cd &lt;/span&gt;bybit-ws
&lt;span class="nb"&gt;cp &lt;/span&gt;config.example.yaml config.yaml
&lt;span class="c"&gt;# insert your Bybit API keys&lt;/span&gt;
systemctl &lt;span class="nt"&gt;--user&lt;/span&gt; &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; bybit-ws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/poliakarmai/bybit-ws" rel="noopener noreferrer"&gt;poliakarmai/bybit-ws&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Bot:&lt;/strong&gt; &lt;a href="https://t.me/GridSignalBot" rel="noopener noreferrer"&gt;@GridSignalBot&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Questions? Open an issue, message the Telegram bot, or fork and customize. The code is alive, trades real money, and improves every day.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>cryptocurrency</category>
      <category>trading</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
