<?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: Grid Bot Wars</title>
    <description>The latest articles on DEV Community by Grid Bot Wars (gridbotwars).</description>
    <link>https://dev.to/gridbotwars</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%2Forganization%2Fprofile_image%2F15666%2F6ab1b938-4a4d-4576-bb39-a379d25d27f3.png</url>
      <title>DEV Community: Grid Bot Wars</title>
      <link>https://dev.to/gridbotwars</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gridbotwars"/>
    <language>en</language>
    <item>
      <title>Why Positive Grid Profit Can Coexist With Negative Total P&amp;L</title>
      <dc:creator>Johnny Turkey</dc:creator>
      <pubDate>Wed, 28 Oct 2026 06:21:55 +0000</pubDate>
      <link>https://dev.to/gridbotwars/why-positive-grid-profit-can-coexist-with-negative-total-pl-1p58</link>
      <guid>https://dev.to/gridbotwars/why-positive-grid-profit-can-coexist-with-negative-total-pl-1p58</guid>
      <description>&lt;p&gt;A grid-bot dashboard can show profitable completed cycles while the overall account is losing money. These figures describe different parts of the strategy. For anyone building a trading dashboard, preserving that distinction is an accounting requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate completed cycles from open exposure
&lt;/h2&gt;

&lt;p&gt;Grid profit summarizes completed buy/sell cycles according to the platform's reporting rules. Total P&amp;amp;L also depends on open positions and the costs assigned to the account. Read the venue's definitions before combining its fields: a fee already included in a reported profit must not be subtracted again.&lt;/p&gt;

&lt;p&gt;Consider an explicitly hypothetical example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Illustrative units&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Completed-cycle profit&lt;/td&gt;
&lt;td&gt;+20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Open-position P&amp;amp;L&lt;/td&gt;
&lt;td&gt;-35&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Additional costs not yet counted above&lt;/td&gt;
&lt;td&gt;-3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total&lt;/td&gt;
&lt;td&gt;-18&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The positive cycle result does not cover the open loss and remaining costs. This is an accounting illustration, not a backtest or a claim about a real bot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the accounting boundary explicit in code
&lt;/h2&gt;

&lt;p&gt;A small pure function can express the example, provided every input uses the same currency, time window and accounting boundary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decimal&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Decimal&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;illustrative_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cycle_profit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;open_pnl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extra_costs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# extra_costs is positive for costs, and excludes costs
&lt;/span&gt;    &lt;span class="c1"&gt;# already included in either of the first two inputs.
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cycle_profit&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;open_pnl&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;extra_costs&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;illustrative_total&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;20&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-35&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="sh"&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;# result == Decimal('-18')
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not a universal exchange reconciliation function. Real adapters must separately handle deposits, withdrawals, realized position P&amp;amp;L, funding and the exact definition of each venue field. Decimal arithmetic avoids binary floating-point surprises, but it cannot fix incorrectly classified inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four questions for a dashboard
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Is the result live, backtested or simulated?&lt;/li&gt;
&lt;li&gt;What time window and starting capital does it cover?&lt;/li&gt;
&lt;li&gt;Which fees, funding and capital flows are included?&lt;/li&gt;
&lt;li&gt;Can another reader reproduce the inputs and assumptions?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a platform-specific example of the distinction, see &lt;a href="https://www.bybit.com/en/help-center/article/FAQ-Spot-Grid-Bot" rel="noopener noreferrer"&gt;Bybit's Spot Grid Bot FAQ&lt;/a&gt;. Spot and futures accounting should not be treated as interchangeable.&lt;/p&gt;

&lt;p&gt;Published by the &lt;a href="https://gridbotwars.com/" rel="noopener noreferrer"&gt;Grid Bot Wars project&lt;/a&gt;, which explores grid mechanics, costs and risk. Educational material; no verified return or universal optimal strategy is claimed.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
