Skip to content

Commit d4e78d7

Browse files
AlexCatarinoclaude
andcommitted
Fix Python property names and dict type on Memory Metrics page (#2316)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 092b254 commit d4e78d7

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

03 Writing Algorithms/01 Key Concepts/14 Debugging Tools/07 Memory Metrics.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
</thead>
1515
<tbody>
1616
<tr>
17-
<td><code class="csharp">ApplicationMemoryUsed</code><code class="python">application_memory_used</code></td>
17+
<td><code class="csharp">ApplicationMemoryUsed</code><code class="python">APPLICATION_MEMORY_USED</code></td>
1818
<td><code class="csharp">long</code><code class="python">int</code></td>
1919
<td>Private memory allocated to the current process, including managed and unmanaged memory, in megabytes.</td>
2020
</tr>
2121
<tr>
22-
<td><code class="csharp">TotalPhysicalMemoryUsed</code><code class="python">total_physical_memory_used</code></td>
22+
<td><code class="csharp">TotalPhysicalMemoryUsed</code><code class="python">TOTAL_PHYSICAL_MEMORY_USED</code></td>
2323
<td><code class="csharp">long</code><code class="python">int</code></td>
2424
<td>Managed-runtime RAM usage (sampled with <code>GC.GetTotalMemory</code>), in megabytes. LEAN's memory monitor samples this value.</td>
2525
</tr>
2626
<tr>
27-
<td><code class="csharp">CpuUsage</code><code class="python">cpu_usage</code></td>
27+
<td><code class="csharp">CpuUsage</code><code class="python">CPU_USAGE</code></td>
2828
<td><code class="csharp">decimal</code><code class="python">float</code></td>
2929
<td>Total CPU usage as a percentage, sampled on a background thread.</td>
3030
</tr>
3131
<tr>
3232
<td><code class="csharp">GetServerStatistics()</code><code class="python">get_server_statistics()</code></td>
33-
<td><code class="csharp">Dictionary&lt;string, string&gt;</code><code class="python">dict</code></td>
33+
<td><code class="csharp">Dictionary&lt;string, string&gt;</code><code class="python">Dictionary[str, str]</code></td>
3434
<td>Snapshot dictionary with <code>CPU Usage</code>, <code>Used RAM</code>, <code>Total RAM</code>, <code>Hostname</code>, and <code>LEAN Version</code> entries.</td>
3535
</tr>
3636
</tbody>
@@ -49,14 +49,15 @@
4949
// Log a full snapshot of the server statistics.
5050
foreach (var kvp in OS.GetServerStatistics()) Log($"{kvp.Key}: {kvp.Value}");</pre>
5151
<pre class="python"># Log the current memory usage of the algorithm process.
52-
self.log(f"Total physical memory used: {OS.total_physical_memory_used} MB")
53-
self.log(f"Application memory used: {OS.application_memory_used} MB")
52+
self.log(f"Total physical memory used: {OS.TOTAL_PHYSICAL_MEMORY_USED} MB")
53+
self.log(f"Application memory used: {OS.APPLICATION_MEMORY_USED} MB")
5454

5555
# Log the current CPU usage as a percentage.
56-
self.log(f"CPU usage: {OS.cpu_usage}%")
56+
self.log(f"CPU usage: {OS.CPU_USAGE}%")
5757

5858
# Log a full snapshot of the server statistics.
59-
for key, value in OS.get_server_statistics().items(): self.log(f"{key}: {value}")</pre>
59+
for kvp in OS.get_server_statistics():
60+
self.log(f"{kvp.key}: {kvp.value}")</pre>
6061
</div>
6162

6263
<p>
@@ -65,7 +66,7 @@
6566
</p>
6667

6768
<p>
68-
LEAN samples <code class="csharp">OS.TotalPhysicalMemoryUsed</code><code class="python">OS.total_physical_memory_used</code> once per minute and feeds each sample into an exponential moving average.
69+
LEAN samples <code class="csharp">OS.TotalPhysicalMemoryUsed</code><code class="python">OS.TOTAL_PHYSICAL_MEMORY_USED</code> once per minute and feeds each sample into an exponential moving average.
6970
The engine sets <code>emaPeriod = 60</code>, which gives you roughly a 1-hour rolling window.
7071
</p>
7172

@@ -74,7 +75,7 @@
7475
sample = OS.TotalPhysicalMemoryUsed;
7576
memoryUsed = Convert.ToInt64((emaPeriod-1)/emaPeriod * memoryUsed + (1/emaPeriod)*sample);</pre>
7677
<pre class="python"># Update the smoothed memory reading each minute.
77-
sample = OS.total_physical_memory_used
78+
sample = OS.TOTAL_PHYSICAL_MEMORY_USED
7879
memory_used = int((ema_period - 1) / ema_period * memory_used + (1 / ema_period) * sample)</pre>
7980
</div>
8081

0 commit comments

Comments
 (0)