From 643f719aee5d2e344990b10c7e32d381d135b74c Mon Sep 17 00:00:00 2001 From: LouisSzeto Date: Wed, 11 Sep 2024 14:07:20 +0800 Subject: [PATCH] merge code boxes --- .../01 Requesting Data/99 Examples.html | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/99 Examples.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/99 Examples.html index 59181dd600..d30d434729 100644 --- a/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/99 Examples.html +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/01 US Equity/01 Requesting Data/99 Examples.html @@ -28,7 +28,7 @@

Example 2: Periodically Request Custom Data

MSFT,0.92,0.96,0.98,1.01,0.98 -

To periodically scrap the data, we need to set up a scheduled event to download the data from DropBox and convert it into trading signals.

+

To periodically scrap the data, we need to set up a scheduled event to download the data from DropBox and convert it into trading signals. Then we download the file from DropBox and convert it into trading signals. You need to use a DropBox query with suffix ?dl=1.

private List<Symbol> _symbols = new();
 
@@ -46,24 +46,9 @@ 

Example 2: Periodically Request Custom Data

TimeRules.At(8, 0), DownloadDataAndPlaceOrder ); -}
-
def initialize(self):
-    self.symbols = []
-    # Subscribe the known tickers from the alternative data
-    for ticker in ["AAPL", "AMZN", "GOOG", "META", "MSFT"]:
-        self.symbols.append(self.add_equity(ticker, Resolution.DAILY).symbol)
-
-    # Set up a weekly scheduled event to download data and place order
-    self.schedule.on(
-        self.date_rules.every(DayOfWeek.SUNDAY),
-        self.time_rules.at(8, 0),
-        self.download_data_and_place_order
-    )
-
+} -

Then we download the file from DropBox and convert it into trading signals. You need to use a DropBox query with suffix ?dl=1.

-
-
private void DownloadDataAndPlaceOrder()
+private void DownloadDataAndPlaceOrder()
 {
     // Download the data from DropBox
     var file = Download("<DropBoxUrlWith?dl=1>");
@@ -89,6 +74,19 @@ 

Example 2: Periodically Request Custom Data

} }
from io import StringIO
+        
+def initialize(self):
+    self.symbols = []
+    # Subscribe the known tickers from the alternative data
+    for ticker in ["AAPL", "AMZN", "GOOG", "META", "MSFT"]:
+        self.symbols.append(self.add_equity(ticker, Resolution.DAILY).symbol)
+
+    # Set up a weekly scheduled event to download data and place order
+    self.schedule.on(
+        self.date_rules.every(DayOfWeek.SUNDAY),
+        self.time_rules.at(8, 0),
+        self.download_data_and_place_order
+    )
 
 def download_data_and_place_order(self):
     # Download the data from DropBox
@@ -103,4 +101,4 @@ 

Example 2: Periodically Request Custom Data

for symbol, signal in signals.items(): weight = 0.2 if signal >= 1 else -0.2 self.set_holdings(symbol, weight)
-
+ \ No newline at end of file