chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:02:50 +08:00
commit 0fc60fdcb1
5008 changed files with 910633 additions and 0 deletions
@@ -0,0 +1,22 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from AlgorithmImports import *
class Test_AlgorithmPythonWrapper(QCAlgorithm):
def initialize(self):
pass
def on_data(self, slice):
pass
@@ -0,0 +1,54 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from AlgorithmImports import *
from custom_data import *
class Test_CustomDataAlgorithm(QCAlgorithm):
def initialize(self):
self.add_data(Nifty, "NIFTY")
self.add_data(CustomPythonData, "IBM", Resolution.DAILY)
class Nifty(PythonData):
'''NIFTY Custom Data Class'''
def get_source(self, config, date, is_live_mode):
return SubscriptionDataSource("https://www.dropbox.com/s/rsmg44jr6wexn2h/CNXNIFTY.csv?dl=1", SubscriptionTransportMedium.REMOTE_FILE)
def reader(self, config, line, date, is_live_mode):
if not (line.strip() and line[0].isdigit()): return None
# New Nifty object
index = Nifty()
index.symbol = config.symbol
try:
# Example File Format:
# Date, Open High Low Close Volume Turnover
# 2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78
data = line.split(',')
index.time = datetime.strptime(data[0], "%Y-%m-%d")
index.value = decimal.decimal(data[4])
index["Open"] = float(data[1])
index["High"] = float(data[2])
index["Low"] = float(data[3])
index["Close"] = float(data[4])
except ValueError:
# Do nothing
return None
return index
@@ -0,0 +1,50 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from AlgorithmImports import *
class Test_MethodOverload(QCAlgorithm):
def initialize(self):
self.add_equity("SPY", Resolution.SECOND)
self.sma = self.sma('SPY', 20)
self.std = self.std('SPY', 20)
self.a = A()
def on_data(self, data):
pass
def call_plot_std_test(self):
self.plot('STD', self.std)
def call_plot_sma_test(self):
self.plot('SMA', self.sma)
def call_plot_number_test(self):
self.plot('NUMBER', 0.1)
def call_plot_throw_test(self):
self.plot("ERROR", self.name)
def call_plot_throw_managed_test(self):
self.plot("ERROR", self.portfolio)
def call_plot_throw_pyobject_test(self):
self.plot("ERROR", self.a)
def no_method_match(self):
self.log(1)
class A(object):
def __init__(self):
pass
@@ -0,0 +1,39 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from AlgorithmImports import *
class Test_PythonExceptionInterpreter(QCAlgorithm):
def initialize(self):
pass
def key_error(self):
x = dict()['SPY']
def no_method_match(self):
self.set_cash('SPY')
def no_method_match_rsi(self):
symbol = Symbol.create('SPY', SecurityType.EQUITY, Market.USA)
# The third positional argument should be a MovingAverageType, not a Resolution,
# so no RSI overload matches the given arguments.
self._indicator = self.rsi(symbol, 15, Resolution.DAILY)
def unsupported_operand(self):
x = None + "Pepe Grillo"
def zero_division_error(self):
x = 1 / 0
def dotnet_error(self):
self.market_order(None, 1);