|
14 | 14 | </thead> |
15 | 15 | <tbody> |
16 | 16 | <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> |
18 | 18 | <td><code class="csharp">long</code><code class="python">int</code></td> |
19 | 19 | <td>Private memory allocated to the current process, including managed and unmanaged memory, in megabytes.</td> |
20 | 20 | </tr> |
21 | 21 | <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> |
23 | 23 | <td><code class="csharp">long</code><code class="python">int</code></td> |
24 | 24 | <td>Managed-runtime RAM usage (sampled with <code>GC.GetTotalMemory</code>), in megabytes. LEAN's memory monitor samples this value.</td> |
25 | 25 | </tr> |
26 | 26 | <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> |
28 | 28 | <td><code class="csharp">decimal</code><code class="python">float</code></td> |
29 | 29 | <td>Total CPU usage as a percentage, sampled on a background thread.</td> |
30 | 30 | </tr> |
31 | 31 | <tr> |
32 | 32 | <td><code class="csharp">GetServerStatistics()</code><code class="python">get_server_statistics()</code></td> |
33 | | - <td><code class="csharp">Dictionary<string, string></code><code class="python">dict</code></td> |
| 33 | + <td><code class="csharp">Dictionary<string, string></code><code class="python">Dictionary[str, str]</code></td> |
34 | 34 | <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> |
35 | 35 | </tr> |
36 | 36 | </tbody> |
|
49 | 49 | // Log a full snapshot of the server statistics. |
50 | 50 | foreach (var kvp in OS.GetServerStatistics()) Log($"{kvp.Key}: {kvp.Value}");</pre> |
51 | 51 | <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") |
54 | 54 |
|
55 | 55 | # 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}%") |
57 | 57 |
|
58 | 58 | # 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> |
60 | 61 | </div> |
61 | 62 |
|
62 | 63 | <p> |
|
65 | 66 | </p> |
66 | 67 |
|
67 | 68 | <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. |
69 | 70 | The engine sets <code>emaPeriod = 60</code>, which gives you roughly a 1-hour rolling window. |
70 | 71 | </p> |
71 | 72 |
|
|
74 | 75 | sample = OS.TotalPhysicalMemoryUsed; |
75 | 76 | memoryUsed = Convert.ToInt64((emaPeriod-1)/emaPeriod * memoryUsed + (1/emaPeriod)*sample);</pre> |
76 | 77 | <pre class="python"># Update the smoothed memory reading each minute. |
77 | | -sample = OS.total_physical_memory_used |
| 78 | +sample = OS.TOTAL_PHYSICAL_MEMORY_USED |
78 | 79 | memory_used = int((ema_period - 1) / ema_period * memory_used + (1 / ema_period) * sample)</pre> |
79 | 80 | </div> |
80 | 81 |
|
|
0 commit comments