Skip to content

Commit 28d976a

Browse files
committed
Tagged first python algorithms
1 parent fb7d199 commit 28d976a

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

Algorithm.Python/AddRemoveSecurityRegressionAlgorithm.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
22
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7-
#
7+
#
88
# Unless required by applicable law or agreed to in writing, software
99
# distributed under the License is distributed on an "AS IS" BASIS,
1010
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,18 +21,25 @@
2121
from QuantConnect.Orders import OrderStatus
2222
from QuantConnect.Algorithm import QCAlgorithm
2323

24+
### <summary>
25+
### This algorithm demonstrates the runtime addition and removal of securities from your algorithm.
26+
### With LEAN it is possible to add and remove securities after the initialization.
27+
### </summary>
28+
### <meta name="tag" content="using data" />
29+
### <meta name="tag" content="assets" />
30+
### <meta name="tag" content="regression test" />
2431
class AddRemoveSecurityRegressionAlgorithm(QCAlgorithm):
2532
'''Basic template algorithm simply initializes the date range and cash'''
2633

2734
def Initialize(self):
2835
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
29-
36+
3037
self.SetStartDate(2013,10,07) #Set Start Date
3138
self.SetEndDate(2013,10,11) #Set End Date
3239
self.SetCash(100000) #Set Strategy Cash
3340
# Find more symbols here: http://quantconnect.com/data
3441
self.AddEquity("SPY")
35-
42+
3643
self._lastAction = None
3744

3845

Algorithm.Python/BasicTemplateAlgorithm.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
22
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7-
#
7+
#
88
# Unless required by applicable law or agreed to in writing, software
99
# distributed under the License is distributed on an "AS IS" BASIS,
1010
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,13 +21,19 @@
2121
from QuantConnect.Algorithm import *
2222
import numpy as np
2323

24-
24+
### <summary>
25+
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
26+
### framework you can use for designing an algorithm.
27+
### </summary>
28+
### <meta name="tag" content="using data" />
29+
### <meta name="tag" content="using quantconnect" />
30+
### <meta name="tag" content="trading and orders" />
2531
class BasicTemplateAlgorithm(QCAlgorithm):
2632
'''Basic template algorithm simply initializes the date range and cash'''
2733

2834
def Initialize(self):
2935
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
30-
36+
3137
self.SetStartDate(2013,10,07) #Set Start Date
3238
self.SetEndDate(2013,10,11) #Set End Date
3339
self.SetCash(100000) #Set Strategy Cash
@@ -37,7 +43,7 @@ def Initialize(self):
3743

3844
def OnData(self, data):
3945
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
40-
46+
4147
Arguments:
4248
data: Slice object keyed by symbol containing the stock data
4349
'''

Algorithm.Python/BasicTemplateDailyAlgorithm.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
22
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
66
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7-
#
7+
#
88
# Unless required by applicable law or agreed to in writing, software
99
# distributed under the License is distributed on an "AS IS" BASIS,
1010
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,22 +24,27 @@
2424
from QuantConnect.Indicators import *
2525
import numpy as np
2626

27+
### <summary>
28+
### Demonstration of requesting daily resolution data for US Equities.
29+
### This is a simple regression test algorithm using a skeleton algorithm and requesting daily data.
30+
### </summary>
31+
### <meta name="tag" content="using data" />
2732
class BasicTemplateDailyAlgorithm(QCAlgorithm):
2833
'''Basic template algorithm simply initializes the date range and cash'''
2934

3035
def Initialize(self):
3136
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
32-
37+
3338
self.SetStartDate(2013,10,07) #Set Start Date
3439
self.SetEndDate(2013,10,18) #Set End Date
3540
self.SetCash(100000) #Set Strategy Cash
3641
# Find more symbols here: http://quantconnect.com/data
3742
self.AddEquity("SPY", Resolution.Daily)
38-
43+
3944

4045
def OnData(self, data):
4146
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
42-
47+
4348
Arguments:
4449
data: Slice object keyed by symbol containing the stock data
4550
'''

0 commit comments

Comments
 (0)