Skip to content

Commit

Permalink
add example from resource plugin to framework universe settings
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisSzeto committed Jan 22, 2025
1 parent 8689a23 commit 036a168
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>The following examples demonstrate some common practices for universe settings.</p>

<?
$number = 1;
$framework = false;
include(DOCS_RESOURCES."/examples/universe-settings.php");
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>The following examples demonstrate some common practices for universe settings.</p>

<?
$number = 1;
$framework = false;
include(DOCS_RESOURCES."/examples/universe-settings.php");
?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<p>The following examples demonstrate some common practices for universe settings.</p>

<h4>Example 1: Weekly-Updating Liquid Universe</h4>
<p>The following algorithm demonstrates daily EMA cross, trading on the top 10 most liquid stocks. The universe is set to be updated weekly. Various universe settings have been set to simulate the brokerage environment best and for trading needs.</p>
<h4>Example <?=$number?>: Weekly-Updating Liquid Universe</h4>
<p>The following algorithm demonstrates daily EMA cross, trading on the most liquid stocks. The universe is set to be updated weekly. Various universe settings have been set to simulate the brokerage environment best and for trading needs.</p>
<div class="section-example-container">
<pre class="csharp">public class UniverseSettingsAlgorithm : QCAlgorithm
{
Expand All @@ -22,8 +20,13 @@ <h4>Example 1: Weekly-Updating Liquid Universe</h4>
// We want to trade the EMA with raw price but not altered by splits.
UniverseSettings.DataNormalizationMode = DataNormalizationMode.SplitAdjusted;

<? if ($framework) { ?>
// Select and trade the top liquid universe.
AddUniverseSelection(new QC500UniverseSelectionModel());
<? } else { ?>
// Only trade on the top 10 most traded stocks since they have the most popularity to drive trends.
AddUniverse(Universe.DollarVolume.Top(10));
<? } ?>
}

public override void OnData(Slice slice)
Expand Down Expand Up @@ -80,8 +83,13 @@ <h4>Example 1: Weekly-Updating Liquid Universe</h4>
# We want to trade the EMA with raw price but not altered by splits.
self.universe_settings.data_normalization_mode = DataNormalizationMode.SPLIT_ADJUSTED

<? if ($framework) { ?>
# Select and trade the top liquid universe.
self.add_universe_selection(QC500UniverseSelectionModel())
<? } else { ?>
# Only trade on the top 10 most traded stocks since they have the most popularity to drive trends.
self.add_universe(self.universe.dollar_volume.top(10))
<? } ?>

def on_data(self, slice: Slice) -&gt; None:
for symbol, bar in slice.bars.items():
Expand Down

0 comments on commit 036a168

Please sign in to comment.