GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixes BasicTemplateForexAlgorithm · nuswgg/Lean@52d0baa

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Algorithm.CSharp
    • BasicTemplateForexAlgorithm.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Algorithm.CSharp/BasicTemplateForexAlgorithm.cs‎

Copy file name to clipboardExpand all lines: Algorithm.CSharp/BasicTemplateForexAlgorithm.cs
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
using QuantConnect.Data;
17-
using System.Linq;
17+
using System;
1818

1919
namespace QuantConnect.Algorithm.CSharp
2020
{
@@ -28,21 +28,20 @@ public class BasicTemplateForexAlgorithm : QCAlgorithm
2828
/// </summary>
2929
public override void Initialize()
3030
{
31-
SetStartDate(2013, 10, 07); //Set Start Date
32-
SetEndDate(2013, 10, 11); //Set End Date
31+
SetStartDate(2014, 5, 7); //Set Start Date
32+
SetEndDate(2014, 5, 15); //Set End Date
3333
SetCash(100000); //Set Strategy Cash
3434
// Find more symbols here: http://quantconnect.com/data
35-
AddForex("EURUSD", Resolution.Minute);
36-
AddForex("GBPUSD", Resolution.Minute);
37-
AddForex("EURGBP", Resolution.Minute);
35+
AddForex("EURUSD");
36+
AddForex("NZDUSD");
3837

39-
History(5, Resolution.Daily);
40-
History(5, Resolution.Hour);
41-
History(5, Resolution.Minute);
38+
var dailyHistory = History(5, Resolution.Daily);
39+
var hourHistory = History(5, Resolution.Hour);
40+
var minuteHistory = History(5, Resolution.Minute);
41+
var secondHistory = History(5, Resolution.Second);
4242

43-
var history = History(System.TimeSpan.FromSeconds(5), Resolution.Second);
44-
45-
foreach (var data in history.OrderBy(x => x.Time))
43+
// Log values from history request of second-resolution data
44+
foreach (var data in secondHistory)
4645
{
4746
foreach (var key in data.Keys)
4847
{
@@ -57,10 +56,11 @@ public override void Initialize()
5756
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
5857
public override void OnData(Slice data)
5958
{
60-
// Print to console to verify that data is coming in
61-
foreach (var key in data.Keys)
59+
if (!Portfolio.Invested)
6260
{
63-
Log(key.Value + ": " + data[key].Time + " > " + data[key].Value);
61+
SetHoldings("EURUSD", .5);
62+
SetHoldings("NZDUSD", .5);
63+
Log(string.Join(", ", data.Values));
6464
}
6565
}
6666
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.