Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Alphas Merge pull request #3055 from QuantConnect/feature-3041-merge-framewo… Apr 5, 2019
Benchmarks Updating the ScheduledEventBenchmark Feb 22, 2019
Properties
AddAlphaModelAlgorithm.py
AddRemoveSecurityRegressionAlgorithm.py
AddRiskManagementAlgorithm.py
AddUniverseSelectionModelAlgorithm.py
BasicSetAccountCurrencyAlgorithm.py
BasicTemplateAlgorithm.py
BasicTemplateCryptoAlgorithm.py
BasicTemplateDailyAlgorithm.py
BasicTemplateFillForwardAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
BasicTemplateForexAlgorithm.py
BasicTemplateFrameworkAlgorithm.py
BasicTemplateFuturesAlgorithm.py Remove order event logging in BasicTemplateFuturesAlgorithm Mar 14, 2019
BasicTemplateFuturesConsolidationAlgorithm.py
BasicTemplateFuturesFrameworkAlgorithm.py
BasicTemplateFuturesHistoryAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
BasicTemplateIntrinioEconomicData.py
BasicTemplateLibrary.py
BasicTemplateOptionStrategyAlgorithm.py
BasicTemplateOptionTradesAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
BasicTemplateOptionsAlgorithm.py
BasicTemplateOptionsConsolidationAlgorithm.py
BasicTemplateOptionsFilterUniverseAlgorithm.py
BasicTemplateOptionsFrameworkAlgorithm.py
BasicTemplateOptionsHistoryAlgorithm.py
BlackLittermanPortfolioOptimizationFrameworkAlgorithm.py Address review: readd Framework project Apr 4, 2019
BrokerageModelAlgorithm.py
BubbleAlgorithm.py
CapmAlphaRankingFrameworkAlgorithm.py
CoarseFineFundamentalComboAlgorithm.py
CoarseFineFundamentalRegressionAlgorithm.py
CoarseFundamentalTop3Algorithm.py
CompositeAlphaModelFrameworkAlgorithm.py Address review: readd Framework project Apr 4, 2019
CompositeRiskManagementModelFrameworkAlgorithm.py
ConstituentsQC500GeneratorAlgorithm.py
ConvertToFrameworkAlgorithm.py
CustomBenchmarkAlgorithm.py
CustomChartingAlgorithm.py
CustomDataBitcoinAlgorithm.py
CustomDataIndicatorExtensionsAlgorithm.py
CustomDataNIFTYAlgorithm.py
CustomDataRegressionAlgorithm.py Small cosmetic changes Mar 1, 2019
CustomDataUniverseAlgorithm.py
CustomIndicatorAlgorithm.py
CustomModelsAlgorithm.py
CustomSecurityInitializerAlgorithm.py
CustomVolatilityModelAlgorithm.py
DailyAlgorithm.py
DailyFxAlgorithm.py
DataConsolidationAlgorithm.py Replaces Enum CalendarType for Static Class with the Same Name Apr 8, 2019
DelistingEventsAlgorithm.py
DisplacedMovingAverageRibbon.py
DividendAlgorithm.py Implements indexer in DataDictionary derived classes Jan 9, 2019
DropboxBaseDataUniverseSelectionAlgorithm.py
DropboxUniverseSelectionAlgorithm.py
ETFGlobalRotationAlgorithm.py
EmaCrossUniverseSelectionAlgorithm.py
EmaCrossUniverseSelectionFrameworkAlgorithm.py Address review: readd Framework project Apr 4, 2019
ExpiryHelperAlphaModelFrameworkAlgorithm.py
FilteredIdentityAlgorithm.py
FinancialAdvisorDemoAlgorithm.py
FractionalQuantityRegressionAlgorithm.py
FuturesMomentumAlgorithm.py Changed Quanld source to correctly retrieve csv data, along with simp… Mar 4, 2019
G10CurrencySelectionModelFrameworkAlgorithm.py Required Changes after Classic/Framework Merge Apr 8, 2019
HistoryAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
HourReverseSplitRegressionAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
HourSplitRegressionAlgorithm.py
IndicatorSuiteAlgorithm.py
IndicatorWarmupAlgorithm.py
LimitFillRegressionAlgorithm.py
LiveFeaturesAlgorithm.py
MACDTrendAlgorithm.py
MarginCallEventsAlgorithm.py
MarketOnOpenOnCloseAlgorithm.py
MaximumPortfolioDrawdownFrameworkAlgorithm.py
MeanVarianceOptimizationFrameworkAlgorithm.py
MovingAverageCrossAlgorithm.py
MultipleSymbolConsolidationAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
OptionChainConsistencyRegressionAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
OptionChainProviderAlgorithm.py
OptionDataNullReferenceRegressionAlgorithm.py
OptionExerciseAssignRegressionAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
OptionOpenInterestRegressionAlgorithm.py
OptionRenameRegressionAlgorithm.py
OptionSplitRegressionAlgorithm.py
OrderTicketDemoAlgorithm.py
ParameterizedAlgorithm.py Changed Quanld source to correctly retrieve csv data, along with simp… Mar 4, 2019
PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.py
PythonAlgorithm.cs
PythonPackageTestAlgorithm.py
QCUWeatherBasedRebalancing.py Changed Quanld source to correctly retrieve csv data, along with simp… Mar 4, 2019
QuandlFuturesDataAlgorithm.py
QuandlImporterAlgorithm.py Revert Qaundl class subscription data source, edit quandl tickers for… Mar 9, 2019
QuantConnect.Algorithm.Python.csproj
QuantConnect.Algorithm.PythonTools.pyproj
RawPricesCoarseUniverseAlgorithm.py
RawPricesUniverseRegressionAlgorithm.py
RegressionAlgorithm.py
RegressionChannelAlgorithm.py Del. decimal import Mar 4, 2019
RenkoConsolidatorAlgorithm.py
RollingWindowAlgorithm.py Assorted changes to address import statements and Rolling Window code… Mar 4, 2019
ScheduledEventsAlgorithm.py
ScheduledUniverseSelectionModelRegressionAlgorithm.py Merge Framework and Classic Algorithms Apr 4, 2019
SectorExposureRiskFrameworkAlgorithm.py
StandardDeviationExecutionModelRegressionAlgorithm.py
TiingoDailyDataAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
TimeInForceAlgorithm.py
TrailingStopRiskFrameworkAlgorithm.py
UncorrelatedUniverseSelectionFrameworkAlgorithm.py
UniverseSelectionDefinitionsAlgorithm.py
UniverseSelectionRegressionAlgorithm.py
UpdateOrderRegressionAlgorithm.py
UserDefinedUniverseAlgorithm.py
VolumeWeightedAveragePriceExecutionModelRegressionAlgorithm.py
WarmupAlgorithm.py Reverting 'Merge pull request #2483 python-history-provider' Sep 18, 2018
WarmupHistoryAlgorithm.py
WeeklyUniverseSelectionRegressionAlgorithm.py
app.config Upgrade all projects to target .NET Framework 4.5.2 Jul 7, 2017
build.bat
build.sh
main.py
packages.config
readme.md Updating documentation Jan 23, 2019

readme.md

QuantConnect Python Algorithm Project:

Before we enable python support, follow the installation instructions to get LEAN running C# algorithms in your machine.

Install Python 3.6:

Windows

  1. Use the Windows x86-64 MSI installer from python.org or Anaconda for Windows installer
  2. When asked to select the features to be installed, make sure you select "Add python.exe to Path"
  3. [Optional] Create PYTHONHOME system variables which value must be the location of your python installation (e.g. C:\Python36amd64 or C:\Anaconda3):
    1. Right mouse button on My Computer. Click Properties.
    2. Click Advanced System Settings -> Environment Variables -> System Variables
    3. Click New.
      • Name of the variable: PYTHONHOME.
      • Value of the variable: python installation path.
  4. Install pandas and its dependencies.

macOS

  1. Use the macOS x86-64 package installer from Anaconda and follow "Installing on macOS" instructions from Anaconda documentation page.
  2. Install pandas and its dependencies.

Linux

By default, miniconda is installed in the users home directory ($HOME):

export PATH="$HOME/miniconda3/bin:$PATH"
wget https://cdn.quantconnect.com/miniconda/Miniconda3-4.3.31-Linux-x86_64.sh
bash Miniconda3-4.3.31-Linux-x86_64.sh -b
rm -rf Miniconda3-4.3.31-Linux-x86_64.sh
sudo ln -s $HOME/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6m.so
conda update -y python conda pip
conda install -y cython pandas

Note: There is a known issue with python 3.6.5 that prevents pythonnet installation, please upgrade python to version 3.6.6:

conda install -y python=3.6.6

Run python algorithm

  1. Update the config to run the python algorithm:
"algorithm-type-name": "BasicTemplateAlgorithm",
"algorithm-language": "Python",
"algorithm-location": "../../../Algorithm.Python/BasicTemplateAlgorithm.py",
  1. Rebuild LEAN.
  2. Run LEAN. You should see the same result of the C# algorithm you tested earlier.

Python.Runtime.dll compilation

LEAN users do not need to compile Python.Runtime.dll. The information below is targeted to developers who wish to improve it.

Download QuantConnect/pythonnet github clone or downloading the zip. If downloading the zip - unzip to a local pathway.

Note: QuantConnect's version of pythonnet is an enhanced version of pythonnet with added support for System.Decimal and System.DateTime.

Below we can find the compilation flags that create a suitable Python.Runtime.dll for each operating system.

Windows

msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36.cs" /p:Configuration=ReleaseWin /p:DefineConstants="PYTHON36,PYTHON3,UCS2"

macOS

msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36m.cs" /p:Configuration=ReleaseMono /p:DefineConstants="PYTHON36,PYTHON3,UCS4,MONO_OSX,PYTHON_WITH_PYMALLOC"

Linux

msbuild pythonnet.sln /nologo /v:quiet /t:Clean;Rebuild /p:Platform=x64 /p:PythonInteropFile="interop36m.cs" /p:Configuration=ReleaseMono /p:DefineConstants="PYTHON36,PYTHON3,UCS4,MONO_LINUX,PYTHON_WITH_PYMALLOC"
You can’t perform that action at this time.