# 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 clr import AddReference AddReference("System") AddReference("NodaTime") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") from System import * from NodaTime import DateTimeZone from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Brokerages import * from QuantConnect.Securities import * from QuantConnect.Data.Market import * from QuantConnect.Data.Consolidators import * from datetime import timedelta from math import floor
from scipy.optimize import minimize, LinearConstraint import numpy as np import pandas as pd from clr import AddReference AddReference("QuantConnect.Research") from QuantConnect import * from QuantConnect.Research import QuantBook from factors import * class AlphaStreamOptimizer: """ Provides an implementation of a portfolio optimizer that maximizes the Sortino ratio. """ def Optimize(self, equity_curves): """ Use SciPy to optimize the portfolio weights of the alphas included in the `equity_curves` DataFrame. Input: - equity_curves DataFrame of trailing equity curves for n alphas Array of doubles, representing the optimized portfolio weights for the alphas """ size = equity_curves.columns.size x0 = np.array(size * [1. / size]) # initial guess is equal-weighting # Σw <= 1 constraints = [{
from pathlib import Path from clr import AddReference from FFxivPythonTrigger.memory import PROCESS_FILENAME from FFxivPythonTrigger.Logger import Logger _logger = Logger("Lumina") res = Path(__file__).parent / 'res' / 'Lumina' AddReference(str(res)) from Lumina import Lumina from Lumina.Data import Language lumina = Lumina(str(Path(PROCESS_FILENAME).parent / "sqpack")) lumina.Options.DefaultExcelLanguage = Language.ChineseSimplified _logger.info("lumina initialized")
# 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 clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Algorithm.Framework") AddReference("QuantConnect.Common") AddReference("QuantConnect.Indicators") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Data.Consolidators import * from QuantConnect.Orders.Fees import ConstantFeeModel from QuantConnect.Algorithm.Framework import QCAlgorithmFramework from QuantConnect.Algorithm.Framework.Alphas import * from QuantConnect.Algorithm.Framework.Selection import ManualUniverseSelectionModel from QuantConnect.Algorithm.Framework.Portfolio import EqualWeightingPortfolioConstructionModel from datetime import datetime, timedelta, time
# 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 clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Data.Custom.TradingEconomics import * ### <summary> ### This example algorithm shows how to import and use Trading Economics data. ### </summary> ### <meta name="tag" content="strategy example" /> ### <meta name="tag" content="using data" /> ### <meta name="tag" content="custom data" /> ### <meta name="tag" content="tradingeconomics" />
''' this alpha generates a positive insight based on how early a stock's ticker is in the alphabet.''' from clr import AddReference AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Algorithm.Framework") from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Algorithm.Framework import * from QuantConnect.Algorithm.Framework.Alphas import AlphaModel, Insight, InsightType, InsightDirection class ExampleAlphaModel(AlphaModel): ''' Provides an implementation of AlphaModel that returns insight based on the alphabetic value of the security symbols''' def __init__(self, **kwargs): '''Initializes a new instance of the ConstantAlphaModel class''' self.insightsTimeBySymbol = {} self.securities = [] def Update(self, algorithm, changes): ''' Creates an insight for each security based on the alphabetical value of its symbol Returns: The new insights generated''' algorithm.Debug('update: ' + str(changes)) insights = []
Prob. default (on principal B at maturity T) = Prob(VT < B) = 1 - N(d2) = N(-d2) where -d2(µ) = -{ln(V/B) + [(µ - D) - ½σ2]τ}/ σ √τ. N(d) = (univariate) cumulative standard normal distribution function (from -inf to d) B = face value (principal) of the debt D = dividend + interest payout V = value of firm’s assets σ (sigma) = standard deviation of firm value changes (returns in V) τ (tau) = time to debt’s maturity µ (mu) = interest rate This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open sourced so the community and client funds can see an example of an alpha. ''' from clr import AddReference AddReference("QuantConnect.Algorithm") import scipy.stats as sp import pandas as pd import numpy as np from datetime import datetime, timedelta from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Algorithm.Framework.Selection import * from Risk.NullRiskManagementModel import NullRiskManagementModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel from Execution.ImmediateExecutionModel import ImmediateExecutionModel class ContingentClaimsAnalysisDefaultPredictionAlpha(QCAlgorithm):
from clr import AddReference # .NET Common Language Runtime (CLR) <- http://pythonnet.github.io/ AddReference("System") AddReference("QuantConnect.Algorithm") # to load an assembly use AddReference AddReference("QuantConnect.Common") from System import * # CLR namespaces to be treatedas Python packages from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Python import PythonQuandl from QuantConnect.Data.Custom import * from QuantConnect.Data.Custom.CBOE import CBOE import numpy as np import pandas as pd from datetime import datetime, timedelta, date from scipy.optimize import minimize import decimal from io import StringIO import bisect class VIXTermStructure(QCAlgorithm): def Initialize(self): self.SetStartDate(2011, 1, 1) # Set Start Date self.SetEndDate(2014, 12, 31) # Set End Date self.SetCash(100000000) # Set Strategy Cash # if the weight of a futures contract is lower than this, we will not trade
# 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 clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") AddReference("QuantConnect.Logging") AddReference("QuantConnect.Indicators") from System import * from QuantConnect import * from QuantConnect.Indicators import * from QuantConnect.Logging import Log from QuantConnect.Algorithm import * from QuantConnect.Algorithm.Framework import * from QuantConnect.Algorithm.Framework.Alphas import InsightCollection, InsightDirection from QuantConnect.Algorithm.Framework.Portfolio import PortfolioConstructionModel, PortfolioTarget from Portfolio.MaximumSharpeRatioPortfolioOptimizer import MaximumSharpeRatioPortfolioOptimizer from datetime import datetime, timedelta from itertools import groupby
# 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 clr import AddReference import pandas AddReference("System") AddReference("QuantConnect.Research") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Research import * from datetime import datetime, timedelta from custom_data import QuandlFuture, Nifty import pandas as pd class SecurityHistoryTest(): def __init__(self, start_date, security_type, symbol): self.qb = QuantBook()
- GUI for TitleBlock Selection - Restrict textfield to integers only _____________________________________________________________________ """ #______________________________ IMPORTS import sys from Autodesk.Revit.DB import (FilteredElementCollector, BuiltInParameter, BuiltInCategory, ViewSheet, Transaction) from pyrevit.forms import SelectFromList from pyrevit import forms # .NET IMPORTS import clr from clr import AddReference AddReference("System") from System.Diagnostics.Process import Start from System.Windows.Window import DragMove from System.Windows.Input import MouseButtonState # VARIABLES doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument app = __revit__.Application # FUNCTIONS from Snippets._selection import select_title_block def create_sheets(n_copies, prefix, start_count): """Function to create sheets"""
""" Adds the custom directive. """ copy_missing_md_docs(docs) copy_missing_dll() app.add_directive('mlcmd', MlCmdDirective) app.connect("env-before-read-docs", write_components_pages) app.add_directive('runcsharpml', RunCSharpMLDirective) return {'version': sphinx.__display_version__, 'parallel_read_safe': True} if __name__ == "__main__": copy_missing_md_docs(docs) copy_missing_dll() from clr import AddReference AddReference('Scikit.ML.DocHelperMlExt') from Scikit.ML.DocHelperMlExt import MamlHelper class dummy: pass deps, uss = get_mlnet_assemblies() app = dummy() app.config = dummy() app.config.epkg_dictionary = {"OPTICS": "http://OPTICS"} app.env = dummy() app.env.srcdir = os.path.dirname(__file__) write_components_pages(app, app.env, None) # Test 1 maml_test()
ghenv.Component.Name = "DF Import LANDSAT Image" ghenv.Component.NickName = 'ImportLANDSATImg' ghenv.Component.Message = 'VER 0.0.03\nJUL_08_2018' ghenv.Component.Category = "Dragonfly" ghenv.Component.SubCategory = "2 | Alternative Climate Data" #compatibleLBVersion = VER 0.0.59\nFEB_01_2015 #compatibleDFVersion = VER 0.0.02\nMAY_12_2018 try: ghenv.Component.AdditionalHelpFromDocStrings = "1" except: pass import os from clr import AddReference AddReference('Grasshopper') AddReference('System.Drawing') from System.Drawing import Image import Rhino as rc import Grasshopper.Kernel as gh import math import scriptcontext as sc def checkTheInputs(): #Set defaults in case we don't find what we need. checkData1 = True checkData2 = True checkData3 = True metaDataFilePath = None
# # http://zetcode.com/tutorials/ironpythontutorial/ # https://msdn.microsoft.com/fr-fr/library/system.windows.forms.form(v=vs.110).aspx # from clr import AddReference from inspect import getargspec AddReference("System.Windows.Forms") AddReference("System.Drawing") from Autodesk.Revit.UI import TaskDialog from System.Windows.Forms import Application, Form, HorizontalAlignment from System.Windows.Forms import Label, TextBox, Button, Panel from System.Windows.Forms import ComboBox, ComboBoxStyle from System.Windows.Forms import ToolTip, RadioButton, MonthCalendar from System.Windows.Forms import DockStyle, AnchorStyles from System.Drawing import Size, Point, Color, SystemFonts from System.Drawing import Font, FontStyle, ContentAlignment from System import DateTime, Convert, Object from System.Collections.Generic import List class Fconfig: modeDebug = False width = 400 margin = 15 smwidth = 370 # width - 2*margin lblwidth = 125 # labels size unitline = 40 # basic element panel height basefont = 'Tahoma'
Value : "C:\USERNAME\AppData\Roaming\RevitPythonShell2016\IconsPanel" (default directory) 1. Gather all your input-type functions (declared here or imported from a reachable module) (2. Modify panel config if you choosed another global variable name) 3. Modify list_options to target your own functions : - add/remove ComboMember lines as you want (be careful with comas) - replace titles and functions names : check twice the list of 'parameters types' - update the tooltips and placeholders(tip or example) - launch Revit ! More details here : https://github.com/PMoureu/samples-Python-RPS """ from os import path from clr import AddReference from inspect import getargspec AddReference('PresentationCore') from System.Windows.Media.Imaging import BitmapImage from System import Uri from Autodesk.Revit.UI import TextBoxData from Autodesk.Revit.UI import ComboBoxData from Autodesk.Revit.UI import ComboBoxMemberData from Autodesk.Revit.UI import TaskDialog ########## Configuration ########## ### Functions from Autodesk.Revit.DB import FilteredElementCollector, ElementId, Element, Transaction from Autodesk.Revit.DB.Architecture import RoomFilter from System.Collections.Generic import List from init import lookup # look at the cheated init.py to allow this import
def vocal_synthesis(text, lang="fr-FR", voice="", filename=""): """ Utilise la synthèse vocale de Windows @param text text à lire @param lang langue @param voice nom de la voix (vide si voix par défaut) @param filename nom de fichier pour sauver le résultat au format wav (vide sinon) @example(techniques___Utiliser une DLL implémentée en C#) .. index:: C#,DLL Le code de la DLL est le suivant. Il a été compilé sous forme de DLL. @code namespace ENSAE.Voice { public static class Speech { public static void VocalSynthesis(string text, string culture, string filename, string voice) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SelectVoiceByHints(VoiceGender.Neutral, VoiceAge.NotSet, 1, new CultureInfo(culture)); if (!string.IsNullOrEmpty(filename)) synth.SetOutputToWaveFile(filename); if (!string.IsNullOrEmpty(voice)) synth.SelectVoice(voice); synth.Speak(text); } } } @endcode Pour l'utiliser, il faut utiliser l'instruction : @code from ensae_teaching_cs.pythonnet import clr from clr import AddReference AddReference("ENSAE.Voice") @endcode Si le programme répond qu'il ne trouve pas le fichier, il suffit d'inclure de la répertoire où se trouve la DLL dans la liste ``sys.path``. Ensuite on écrit simplement : @code from ENSAE.Voice import Speech Speech.VocalSynthesis(text, lang, voice, filename) @endcode Il faut voir le notebook :ref:`pythoncsharprst`. @endexample """ if "ENSAE.Voice" not in sys.modules: if not sys.platform.startswith("win"): raise NotImplementedError("only available on Windows") path = os.path.abspath(os.path.split(__file__)[0]) path = os.path.join(path, "csdll") from clr import AddReference try: AddReference("ENSAE.Voice") except Exception as e: path = os.path.abspath(os.path.split(__file__)[0]) path = os.path.join(path, "csdll") if path not in sys.path: sys.path.append(path) AddReference("ENSAE.Voice") from ENSAE.Voice import Speech Speech.VocalSynthesis(text, lang, voice, filename)
# 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 clr import AddReference AddReference("QuantConnect.Research") AddReference("QuantConnect.Indicators") from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Research import * from QuantConnect.Indicators import * class IndicatorTest(): def __init__(self, start_date, security_type, symbol): self.qb = QuantBook() self.qb.SetStartDate(start_date) self.symbol = self.qb.AddSecurity(security_type, symbol).Symbol def __str__(self):
# 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. import os import sys # The runtimeconfig.json is stored alongside start.py, but start.py may be a # symlink and the directory start.py is stored in is not necessarily the # current working directory. We therefore construct the absolute path to the # start.py file, and find the runtimeconfig.json relative to that. path = os.path.dirname(os.path.realpath(__file__)) from clr import AddReference AddReference("System") #Load assemblies for file in os.listdir(path): if file.endswith(".dll") and file.startswith("QuantConnect."): AddReference(file.replace(".dll", "")) from System import * from QuantConnect import * from QuantConnect.Api import * from QuantConnect.Util import * from QuantConnect.Data import * from QuantConnect.Orders import * from QuantConnect.Python import * from QuantConnect.Storage import * from QuantConnect.Research import *
# 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 clr import AddReference AddReference("QuantConnect.Algorithm.Framework") from QuantConnect.Algorithm.Framework.Portfolio import PortfolioConstructionModel, PortfolioTarget class EqualWeightingPortfolioConstructionModel(PortfolioConstructionModel): '''Provides an implementation of IPortfolioConstructionModel that gives equal weighting to all securities. The target percent holdings of each security is 1/N where N is the number of securities. For insights of direction InsightDirection.Up, long targets are returned and for insights of direction InsightDirection.Down, short targets are returned.''' def __init__(self): self.securities = [] self.removedSymbols = [] def CreateTargets(self, algorithm, insights): '''Create portfolio targets from the specified insights Args: algorithm: The algorithm instance
# 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 clr import AddReference AddReference("QuantConnect.Jupyter") AddReference("QuantConnect.Indicators") from QuantConnect.Jupyter import * from QuantConnect.Indicators import * class IndicatorTest(): def __init__(self, start_date, security_type, symbol): self.qb = QuantBook() self.qb.SetStartDate(start_date) self.symbol = self.qb.AddSecurity(security_type, symbol).Symbol def __str__(self): return "{} on {}".format(self.symbol.ID, self.qb.StartDate) def test_bollinger_bands(self, symbol, start, end, resolution): ind = BollingerBands(10, 2)
dlldir = "../../bin/Debug" dlldir = os.path.join(fileDirectory, dlldir) # Move us to dll directory and add it to path os.chdir(dlldir) sys.path.append(dlldir) # Tell PythonNet to use .dotnet 5 from pythonnet import set_runtime import clr_loader set_runtime(clr_loader.get_coreclr(os.path.join(dlldir, "QuantConnect.Lean.Launcher.runtimeconfig.json"))) ''' from clr import AddReference AddReference("QuantConnect.Common") AddReference("QuantConnect.Tests") from QuantConnect import * from QuantConnect.Python import PandasConverter from QuantConnect.Tests import Symbols from QuantConnect.Tests.Python import PythonTestingUtils # Import our mapper which wraps core pandas functions (included in build dir) import PandasMapper import pandas as pd # Get some dataframes from Lean to test on spy = Symbols.SPY aapl = Symbols.AAPL SymbolCache.Set("SPY", spy)
# 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 clr import AddReference AddReference("System.Core") AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Configuration") AddReference("QuantConnect.Lean.Engine") from System import * from QuantConnect import * from QuantConnect.Algorithm import QCAlgorithm from QuantConnect.Data.Auxiliary import * from QuantConnect.Data.UniverseSelection import * from QuantConnect.Orders import OrderStatus from QuantConnect.Orders.Fees import ConstantFeeModel from QuantConnect.Configuration import Config from QuantConnect.Util import Composer from QuantConnect.Interfaces import IDataProvider from QuantConnect.Lean.Engine.DataFeeds import DefaultDataProvider
# 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 clr import AddReference AddReference("System.Core") AddReference("System.Collections") AddReference("QuantConnect.Common") AddReference("QuantConnect.Algorithm") from System import * from System.Collections.Generic import List from QuantConnect import * from QuantConnect.Algorithm import QCAlgorithm from QuantConnect.Data.UniverseSelection import * import numpy as np ### <summary> ### Regression algorithm to test universe additions and removals with open positions ### </summary> ### <meta name="tag" content="regression test" />
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") AddReference("RabbitMQ.Client") from RabbitMQ.Client import * from RabbitMQ.Client.Events import * from System import * from System import String, Object from System.Text import * from System.Collections.Generic import Dictionary from QuantConnect import * from QuantConnect.Data.Custom import * from AlphaStream.Models import Insight as AlphaStreamInsight import json from datetime import datetime import sys class AlphaStreamsSocket: ''' Class to create and run threads for each Alpha being subscribed to. It creates threads, opens connections to the streaming Insights, and passes them on to the Alpha Model for each Alpha ID. ''' def __init__(self, algorithm, client, streamClientInformation, alphaIds): '''
ghenv.Component.Name = "Ladybug_CDD_HDD" ghenv.Component.NickName = "CDD_HDD" ghenv.Component.Message = 'VER 0.0.64\nFEB_05_2017' ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.application ghenv.Component.Category = "Ladybug" ghenv.Component.SubCategory = "1 | AnalyzeWeatherData" #compatibleLBVersion = VER 0.0.59\nFEB_01_2015 try: ghenv.Component.AdditionalHelpFromDocStrings = "2" except: pass import scriptcontext as sc from clr import AddReference AddReference('Grasshopper') import Grasshopper.Kernel as gh # provide inputs try: coolingSetPoint = float(_coolingBaseTemperature_) except: coolingSetPoint = 23.3 print 'Cooling setpoint is: ' + ` coolingSetPoint ` + ' C.' try: heatingSetPoint = float(_heatingBaseTemperature_) except: heatingSetPoint = 18.3 print 'Heating setpoint is: ' + ` heatingSetPoint ` + ' C.'
# 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 clr import AddReference import pandas AddReference("System") AddReference("QuantConnect.Jupyter") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Data import * from QuantConnect.Jupyter import * from datetime import datetime, timedelta from custom_data import QuandlFuture, Nifty import pandas as pd class SecurityHistoryTest(): def __init__(self, start_date, security_type, symbol): self.qb = QuantBook() self.qb.SetStartDate(start_date)