Lean  $LEAN_TAG$
QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper Class Reference

Creates and wraps the algorithm written in python. More...

Inheritance diagram for QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper:
[legend]

Public Member Functions

 AlgorithmPythonWrapper (string moduleName)
 AlgorithmPythonWrapper constructor. Creates and wraps the algorithm written in python. More...
 
void SetStatus (AlgorithmStatus status)
 Set the state of a live deployment More...
 
void SetAvailableDataTypes (Dictionary< SecurityType, List< TickType >> availableDataTypes)
 Set the available TickType supported by each SecurityType in SecurityManager More...
 
void SetOptionChainProvider (IOptionChainProvider optionChainProvider)
 Sets the option chain provider, used to get the list of option contracts for an underlying symbol More...
 
void SetFutureChainProvider (IFutureChainProvider futureChainProvider)
 Sets the future chain provider, used to get the list of future contracts for an underlying symbol More...
 
void SetStatisticsService (IStatisticsService statisticsService)
 Sets the statistics service instance to be used by the algorithm More...
 
Security AddSecurity (SecurityType securityType, string symbol, Resolution? resolution, string market, bool fillForward, decimal leverage, bool extendedMarketHours, DataMappingMode? dataMappingMode=null, DataNormalizationMode? dataNormalizationMode=null)
 Set a required SecurityType-symbol and resolution for algorithm More...
 
Security AddSecurity (Symbol symbol, Resolution? resolution=null, bool fillForward=true, decimal leverage=Security.NullLeverage, bool extendedMarketHours=false, DataMappingMode? dataMappingMode=null, DataNormalizationMode? dataNormalizationMode=null, int contractDepthOffset=0)
 Set a required SecurityType-symbol and resolution for algorithm More...
 
Future AddFutureContract (Symbol symbol, Resolution? resolution=null, bool fillForward=true, decimal leverage=0m, bool extendedMarketHours=false)
 Creates and adds a new single Future contract to the algorithm More...
 
Option AddOptionContract (Symbol symbol, Resolution? resolution=null, bool fillForward=true, decimal leverage=0m, bool extendedMarketHours=false)
 Creates and adds a new single Option contract to the algorithm More...
 
void OnEndOfTimeStep ()
 Invoked at the end of every time step. This allows the algorithm to process events before advancing to the next time step. More...
 
void Debug (string message)
 Send debug message More...
 
void Error (string message)
 Send an error message for the algorithm More...
 
void AddChart (Chart chart)
 Add a Chart object to algorithm collection More...
 
IEnumerable< ChartGetChartUpdates (bool clearChartData=false)
 Get the chart updates since the last request: More...
 
bool GetLocked ()
 Gets whether or not this algorithm has been locked and fully initialized More...
 
IReadOnlyDictionary< string, string > GetParameters ()
 Gets a read-only dictionary with all current parameters More...
 
string GetParameter (string name, string defaultValue=null)
 Gets the parameter with the specified name. If a parameter with the specified name does not exist, the given default value is returned if any, else null More...
 
int GetParameter (string name, int defaultValue)
 Gets the parameter with the specified name parsed as an integer. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned More...
 
double GetParameter (string name, double defaultValue)
 Gets the parameter with the specified name parsed as a double. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned More...
 
decimal GetParameter (string name, decimal defaultValue)
 Gets the parameter with the specified name parsed as a decimal. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned More...
 
void Initialize ()
 Initialise the Algorithm and Prepare Required Data: More...
 
List< int > Liquidate (Symbol symbolToLiquidate=null, string tag="Liquidated")
 Liquidate your portfolio holdings: More...
 
void Log (string message)
 Save entry to the Log More...
 
void OnBrokerageDisconnect ()
 Brokerage disconnected event handler. This method is called when the brokerage connection is lost. More...
 
void OnBrokerageMessage (BrokerageMessageEvent messageEvent)
 Brokerage message event handler. This method is called for all types of brokerage messages. More...
 
void OnBrokerageReconnect ()
 Brokerage reconnected event handler. This method is called when the brokerage connection is restored after a disconnection. More...
 
void OnData (Slice slice)
 v3.0 Handler for all data types More...
 
void OnFrameworkData (Slice slice)
 Used to send data updates to algorithm framework models More...
 
void OnSplits (Splits splits)
 Event handler to be called when there's been a split event More...
 
void OnDividends (Dividends dividends)
 Event handler to be called when there's been a dividend event More...
 
void OnDelistings (Delistings delistings)
 Event handler to be called when there's been a delistings event More...
 
void OnSymbolChangedEvents (SymbolChangedEvents symbolsChanged)
 Event handler to be called when there's been a symbol changed event More...
 
void OnEndOfAlgorithm ()
 Call this event at the end of the algorithm running. More...
 
void OnEndOfDay ()
 End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets). More...
 
void OnEndOfDay (Symbol symbol)
 End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets). More...
 
void OnMarginCall (List< SubmitOrderRequest > requests)
 Margin call event handler. This method is called right before the margin call orders are placed in the market. More...
 
void OnMarginCallWarning ()
 Margin call warning event handler. This method is called when Portfolio.MarginRemaining is under 5% of your Portfolio.TotalPortfolioValue More...
 
void OnOrderEvent (OrderEvent newEvent)
 EXPERTS ONLY:: [-!-Async Code-!-] New order event handler: on order status changes (filled, partially filled, cancelled etc). More...
 
OrderTicket SubmitOrderRequest (SubmitOrderRequest request)
 Will submit an order request to the algorithm More...
 
void OnAssignmentOrderEvent (OrderEvent assignmentEvent)
 Option assignment event handler. On an option assignment event for short legs the resulting information is passed to this method. More...
 
void OnSecuritiesChanged (SecurityChanges changes)
 Event fired each time the we add/remove securities from the data feed More...
 
void OnFrameworkSecuritiesChanged (SecurityChanges changes)
 Used to send security changes to algorithm framework models More...
 
void PostInitialize ()
 Called by setup handlers after Initialize and allows the algorithm a chance to organize the data gather in the Initialize method More...
 
void OnWarmupFinished ()
 Called when the algorithm has completed initialization and warm up. More...
 
bool RemoveSecurity (Symbol symbol)
 Removes the security with the specified symbol. This will cancel all open orders and then liquidate any existing holdings More...
 
void SetAlgorithmId (string algorithmId)
 Set the algorithm Id for this backtest or live run. This can be used to identify the order and equity records. More...
 
void SetBrokerageMessageHandler (IBrokerageMessageHandler handler)
 Sets the implementation used to handle messages from the brokerage. The default implementation will forward messages to debug or error and when a BrokerageMessageType.Error occurs, the algorithm is stopped. More...
 
void SetBrokerageModel (IBrokerageModel brokerageModel)
 Sets the brokerage model used to resolve transaction models, settlement models, and brokerage specified ordering behaviors. More...
 
void SetAccountCurrency (string accountCurrency, decimal? startingCash=null)
 Sets the account currency cash symbol this algorithm is to manage, as well as the starting cash in this currency if given More...
 
void SetCash (decimal startingCash)
 Set the starting capital for the strategy More...
 
void SetCash (string symbol, decimal startingCash, decimal conversionRate=0)
 Set the cash for the specified symbol More...
 
void SetDateTime (DateTime time)
 Set the DateTime Frontier: This is the master time and is More...
 
void SetStartDate (DateTime start)
 Set the start date for the backtest More...
 
void SetEndDate (DateTime end)
 Set the end date for a backtest. More...
 
BaseData GetLastKnownPrice (Security security)
 Get the last known price using the history provider. Useful for seeding securities with the correct price More...
 
void SetRunTimeError (Exception exception)
 Set the runtime error More...
 
void SetFinishedWarmingUp ()
 Sets IsWarmingUp to false to indicate this algorithm has finished its warm up More...
 
void SetHistoryProvider (IHistoryProvider historyProvider)
 Set the historical data provider More...
 
void SetLiveMode (bool live)
 Set live mode state of the algorithm run: Public setter for the algorithm property LiveMode. More...
 
void SetAlgorithmMode (AlgorithmMode algorithmMode)
 Sets the algorithm running mode More...
 
void SetDeploymentTarget (DeploymentTarget deploymentTarget)
 Sets the algorithm deployment target More...
 
void SetLocked ()
 Set the algorithm as initialized and locked. No more cash or security changes. More...
 
void SetMaximumOrders (int max)
 Set the maximum number of orders the algorithm is allowed to process. More...
 
void SetParameters (Dictionary< string, string > parameters)
 Sets the parameters from the dictionary More...
 
override string ToString ()
 Returns a string that represents the current AlgorithmPythonWrapper object. More...
 
void SetCurrentSlice (Slice slice)
 Sets the current slice More...
 
void SetApi (IApi api)
 Provide the API for the algorithm. More...
 
void SetObjectStore (IObjectStore objectStore)
 Sets the object store More...
 
bool Shortable (Symbol symbol, decimal shortQuantity, int? updateOrderId=null)
 Determines if the Symbol is shortable at the brokerage More...
 
long ShortableQuantity (Symbol symbol)
 Gets the quantity shortable for the given asset More...
 
Symbol Symbol (string ticker)
 Converts the string 'ticker' symbol into a full Symbol object This requires that the string 'ticker' has been added to the algorithm More...
 
string Ticker (Symbol symbol)
 For the given symbol will resolve the ticker it used at the current algorithm date More...
 
void SetName (string name)
 Sets name to the currently running backtest More...
 
void AddTag (string tag)
 Adds a tag to the algorithm More...
 
void SetTags (HashSet< string > tags)
 Sets the tags for the algorithm More...
 
- Public Member Functions inherited from QuantConnect.Python.BasePythonWrapper< IAlgorithm >
 BasePythonWrapper (bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class More...
 
 BasePythonWrapper (PyObject instance, bool validateInterface=true)
 Creates a new instance of the BasePythonWrapper<TInterface> class with the specified instance More...
 
void SetPythonInstance (PyObject instance)
 Sets the python instance More...
 
GetProperty< T > (string propertyName)
 Gets the Python instance property with the specified name More...
 
PyObject GetProperty (string propertyName)
 Gets the Python instance property with the specified name More...
 
void SetProperty (string propertyName, object value)
 Sets the Python instance property with the specified name More...
 
dynamic GetEvent (string name)
 Gets the Python instance event with the specified name More...
 
bool HasAttr (string name)
 Determines whether the Python instance has the specified attribute More...
 
PyObject GetMethod (string methodName)
 Gets the Python instances method with the specified name and caches it More...
 
InvokeMethod< T > (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 
PyObject InvokeMethod (string methodName, params object[] args)
 Invokes the specified method with the specified arguments More...
 

Public Attributes

string AlgorithmId => _baseAlgorithm.AlgorithmId
 AlgorithmId for the backtest More...
 
IBenchmark Benchmark => _baseAlgorithm.Benchmark
 Gets the function used to define the benchmark. This function will return the value of the benchmark at a requested date/time More...
 
IBrokerageModel BrokerageModel => _baseAlgorithm.BrokerageModel
 Gets the brokerage model used to emulate a real brokerage More...
 
BrokerageName BrokerageName => _baseAlgorithm.BrokerageName
 Gets the brokerage name. More...
 
IRiskFreeInterestRateModel RiskFreeInterestRateModel => _baseAlgorithm.RiskFreeInterestRateModel
 Gets the risk free interest rate model used to get the interest rates More...
 
ConcurrentQueue< string > DebugMessages => _baseAlgorithm.DebugMessages
 Debug messages from the strategy: More...
 
DateTime EndDate => _baseAlgorithm.EndDate
 Get Requested Backtest End Date More...
 
ConcurrentQueue< string > ErrorMessages => _baseAlgorithm.ErrorMessages
 Error messages from the strategy: More...
 
bool IsWarmingUp => _baseAlgorithm.IsWarmingUp
 Gets whether or not this algorithm is still warming up More...
 
bool LiveMode => _baseAlgorithm.LiveMode
 Algorithm is running on a live server. More...
 
AlgorithmMode AlgorithmMode => _baseAlgorithm.AlgorithmMode
 Algorithm running mode. More...
 
DeploymentTarget DeploymentTarget => _baseAlgorithm.DeploymentTarget
 Deployment target, either local or cloud. More...
 
ConcurrentQueue< string > LogMessages => _baseAlgorithm.LogMessages
 Log messages from the strategy: More...
 
NotificationManager Notify => _baseAlgorithm.Notify
 Notification manager for storing and processing live event messages More...
 
SecurityPortfolioManager Portfolio => _baseAlgorithm.Portfolio
 Security portfolio management class provides wrapper and helper methods for the Security.Holdings class such as IsLong, IsShort, TotalProfit More...
 
ConcurrentDictionary< string, string > RuntimeStatistics => _baseAlgorithm.RuntimeStatistics
 Customizable dynamic statistics displayed during live trading: More...
 
ScheduleManager Schedule => _baseAlgorithm.Schedule
 Gets schedule manager for adding/removing scheduled events More...
 
SecurityManager Securities => _baseAlgorithm.Securities
 Security object collection class stores an array of objects representing representing each security/asset we have a subscription for. More...
 
ISecurityInitializer SecurityInitializer => _baseAlgorithm.SecurityInitializer
 Gets an instance that is to be used to initialize newly created securities. More...
 
ITradeBuilder TradeBuilder => _baseAlgorithm.TradeBuilder
 Gets the Trade Builder to generate trades from executions More...
 
IAlgorithmSettings Settings => _baseAlgorithm.Settings
 Gets the user settings for the algorithm More...
 
IOptionChainProvider OptionChainProvider => _baseAlgorithm.OptionChainProvider
 Gets the option chain provider, used to get the list of option contracts for an underlying symbol More...
 
IFutureChainProvider FutureChainProvider => _baseAlgorithm.FutureChainProvider
 Gets the future chain provider, used to get the list of future contracts for an underlying symbol More...
 
ObjectStore ObjectStore => _baseAlgorithm.ObjectStore
 Gets the object store, used for persistence More...
 
Slice CurrentSlice => _baseAlgorithm.CurrentSlice
 Returns the current Slice object More...
 
DateTime StartDate => _baseAlgorithm.StartDate
 Algorithm start date for backtesting, set by the SetStartDate methods. More...
 
ITimeKeeper TimeKeeper => _baseAlgorithm.TimeKeeper
 Gets the time keeper instance More...
 
SubscriptionManager SubscriptionManager => _baseAlgorithm.SubscriptionManager
 Data subscription manager controls the information and subscriptions the algorithms recieves. Subscription configurations can be added through the Subscription Manager. More...
 
DateTime Time => _baseAlgorithm.Time
 Current date/time in the algorithm's local time zone More...
 
DateTimeZone TimeZone => _baseAlgorithm.TimeZone
 Gets the time zone of the algorithm More...
 
SecurityTransactionManager Transactions => _baseAlgorithm.Transactions
 Security transaction manager class controls the store and processing of orders. More...
 
UniverseManager UniverseManager => _baseAlgorithm.UniverseManager
 Gets the collection of universes for the algorithm More...
 
UniverseSettings UniverseSettings => _baseAlgorithm.UniverseSettings
 Gets the subscription settings to be used when adding securities via universe selection More...
 
DateTime UtcTime => _baseAlgorithm.UtcTime
 Current date/time in UTC. More...
 
string AccountCurrency => _baseAlgorithm.AccountCurrency
 Gets the account currency More...
 
InsightManager Insights => _baseAlgorithm.Insights
 Gets the insight manager More...
 
StatisticsResults Statistics => _baseAlgorithm.Statistics
 The current statistics for the running algorithm. More...
 

Properties

bool IsOnEndOfDayImplemented [get]
 True if the underlying python algorithm implements "OnEndOfDay" More...
 
bool IsOnEndOfDaySymbolImplemented [get]
 True if the underlying python algorithm implements "OnEndOfDay(symbol)" More...
 
IBrokerageMessageHandler BrokerageMessageHandler [get, set]
 Gets the brokerage message handler used to decide what to do with each message sent from the brokerage More...
 
IHistoryProvider HistoryProvider [get, set]
 Gets or sets the history provider for the algorithm More...
 
string Name [get, set]
 Public name for the algorithm. More...
 
HashSet< string > Tags [get, set]
 A list of tags associated with the algorithm or the backtest, useful for categorization More...
 
AlgorithmEvent< string > NameUpdated
 Event fired algorithm's name is changed More...
 
AlgorithmEvent< HashSet< string > > TagsUpdated
 Event fired when the tag collection is updated More...
 
Exception RunTimeError [get, set]
 Gets the run time error from the algorithm, or null if none was encountered. More...
 
AlgorithmStatus Status [get, set]
 Gets or sets the current status of the algorithm More...
 
AlgorithmEvent< GeneratedInsightsCollectionInsightsGenerated
 Event fired when an algorithm generates a insight More...
 
int ProjectId [get, set]
 The project id associated with this algorithm if any More...
 
- Properties inherited from QuantConnect.Interfaces.IAlgorithm
ITimeKeeper TimeKeeper [get]
 Gets the time keeper instance More...
 
SubscriptionManager SubscriptionManager [get]
 Data subscription manager controls the information and subscriptions the algorithms recieves. Subscription configurations can be added through the Subscription Manager. More...
 
int ProjectId [get, set]
 The project id associated with this algorithm if any More...
 
SecurityManager Securities [get]
 Security object collection class stores an array of objects representing representing each security/asset we have a subscription for. More...
 
UniverseManager UniverseManager [get]
 Gets the collection of universes for the algorithm More...
 
SecurityPortfolioManager Portfolio [get]
 Security portfolio management class provides wrapper and helper methods for the Security.Holdings class such as IsLong, IsShort, TotalProfit More...
 
SecurityTransactionManager Transactions [get]
 Security transaction manager class controls the store and processing of orders. More...
 
IBrokerageModel BrokerageModel [get]
 Gets the brokerage model used to emulate a real brokerage More...
 
BrokerageName BrokerageName [get]
 Gets the brokerage name. More...
 
IRiskFreeInterestRateModel RiskFreeInterestRateModel [get]
 Gets the risk free interest rate model used to get the interest rates More...
 
IBrokerageMessageHandler BrokerageMessageHandler [get, set]
 Gets the brokerage message handler used to decide what to do with each message sent from the brokerage More...
 
NotificationManager Notify [get]
 Notification manager for storing and processing live event messages More...
 
ScheduleManager Schedule [get]
 Gets schedule manager for adding/removing scheduled events More...
 
IHistoryProvider HistoryProvider [get, set]
 Gets or sets the history provider for the algorithm More...
 
AlgorithmStatus Status [get, set]
 Gets or sets the current status of the algorithm More...
 
bool IsWarmingUp [get]
 Gets whether or not this algorithm is still warming up More...
 
string Name [get, set]
 Public name for the algorithm. More...
 
HashSet< string > Tags [get, set]
 A list of tags associated with the algorithm or the backtest, useful for categorization More...
 
DateTime Time [get]
 Current date/time in the algorithm's local time zone More...
 
DateTimeZone TimeZone [get]
 Gets the time zone of the algorithm More...
 
DateTime UtcTime [get]
 Current date/time in UTC. More...
 
DateTime StartDate [get]
 Algorithm start date for backtesting, set by the SetStartDate methods. More...
 
DateTime EndDate [get]
 Get Requested Backtest End Date More...
 
string AlgorithmId [get]
 AlgorithmId for the backtest More...
 
bool LiveMode [get]
 Algorithm is running on a live server. More...
 
AlgorithmMode AlgorithmMode [get]
 Algorithm running mode. More...
 
DeploymentTarget DeploymentTarget [get]
 Deployment target, either local or cloud. More...
 
UniverseSettings UniverseSettings [get]
 Gets the subscription settings to be used when adding securities via universe selection More...
 
ConcurrentQueue< string > DebugMessages [get]
 Debug messages from the strategy: More...
 
ConcurrentQueue< string > ErrorMessages [get]
 Error messages from the strategy: More...
 
ConcurrentQueue< string > LogMessages [get]
 Log messages from the strategy: More...
 
Exception RunTimeError [get, set]
 Gets the run time error from the algorithm, or null if none was encountered. More...
 
ConcurrentDictionary< string, string > RuntimeStatistics [get]
 Customizable dynamic statistics displayed during live trading: More...
 
StatisticsResults Statistics [get]
 The current algorithm statistics for the running algorithm. More...
 
IBenchmark Benchmark [get]
 Gets the function used to define the benchmark. This function will return the value of the benchmark at a requested date/time More...
 
ITradeBuilder TradeBuilder [get]
 Gets the Trade Builder to generate trades from executions More...
 
IAlgorithmSettings Settings [get]
 Gets the user settings for the algorithm More...
 
IOptionChainProvider OptionChainProvider [get]
 Gets the option chain provider, used to get the list of option contracts for an underlying symbol More...
 
IFutureChainProvider FutureChainProvider [get]
 Gets the future chain provider, used to get the list of future contracts for an underlying symbol More...
 
InsightManager Insights [get]
 Gets the insight manager More...
 
ObjectStore ObjectStore [get]
 Gets the object store, used for persistence More...
 
Slice CurrentSlice [get]
 Returns the current Slice object More...
 
- Properties inherited from QuantConnect.Interfaces.ISecurityInitializerProvider
ISecurityInitializer SecurityInitializer [get]
 Gets an instance that is to be used to initialize newly created securities. More...
 
- Properties inherited from QuantConnect.Interfaces.IAccountCurrencyProvider
string AccountCurrency [get]
 Gets the account currency More...
 

Additional Inherited Members

- Protected Attributes inherited from QuantConnect.Python.BasePythonWrapper< IAlgorithm >
PyObject Instance
 Gets the underlying python instance More...
 
- Events inherited from QuantConnect.Interfaces.IAlgorithm
AlgorithmEvent< GeneratedInsightsCollectionInsightsGenerated
 Event fired when an algorithm generates a insight More...
 
AlgorithmEvent< string > NameUpdated
 Event fired algorithm's name is changed More...
 
AlgorithmEvent< HashSet< string > > TagsUpdated
 Event fired when the tag collection is updated More...
 

Detailed Description

Creates and wraps the algorithm written in python.

Definition at line 46 of file AlgorithmPythonWrapper.cs.

Constructor & Destructor Documentation

◆ AlgorithmPythonWrapper()

QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AlgorithmPythonWrapper ( string  moduleName)

AlgorithmPythonWrapper constructor. Creates and wraps the algorithm written in python.

Parameters
moduleNameName of the module that can be found in the PYTHONPATH

Definition at line 84 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:

Member Function Documentation

◆ SetStatus()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetStatus ( AlgorithmStatus  status)

Set the state of a live deployment

Parameters
statusLive deployment status

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetAvailableDataTypes()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetAvailableDataTypes ( Dictionary< SecurityType, List< TickType >>  availableDataTypes)

Set the available TickType supported by each SecurityType in SecurityManager

Parameters
availableDataTypes>The different TickType each Security supports

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetOptionChainProvider()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetOptionChainProvider ( IOptionChainProvider  optionChainProvider)

Sets the option chain provider, used to get the list of option contracts for an underlying symbol

Parameters
optionChainProviderThe option chain provider

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetFutureChainProvider()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetFutureChainProvider ( IFutureChainProvider  futureChainProvider)

Sets the future chain provider, used to get the list of future contracts for an underlying symbol

Parameters
futureChainProviderThe future chain provider

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetStatisticsService()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetStatisticsService ( IStatisticsService  statisticsService)

Sets the statistics service instance to be used by the algorithm

Parameters
statisticsServiceThe statistics service instance

Implements QuantConnect.Interfaces.IAlgorithm.

◆ AddSecurity() [1/2]

Security QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddSecurity ( SecurityType  securityType,
string  symbol,
Resolution resolution,
string  market,
bool  fillForward,
decimal  leverage,
bool  extendedMarketHours,
DataMappingMode dataMappingMode = null,
DataNormalizationMode dataNormalizationMode = null 
)

Set a required SecurityType-symbol and resolution for algorithm

Parameters
securityTypeSecurityType Enum: Equity, Commodity, FOREX or Future
symbolSymbol Representation of the MarketType, e.g. AAPL
resolutionThe Resolution of market data, Tick, Second, Minute, Hour, or Daily.
marketThe market the requested security belongs to, such as 'usa' or 'fxcm'
fillForwardIf true, returns the last available data even if none in that timeslice.
leverageleverage for this security
extendedMarketHoursUse extended market hours data
dataMappingModeThe contract mapping mode to use for the security
dataNormalizationModeThe price scaling mode to use for the security

Implements QuantConnect.Interfaces.IAlgorithm.

◆ AddSecurity() [2/2]

Security QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddSecurity ( Symbol  symbol,
Resolution resolution = null,
bool  fillForward = true,
decimal  leverage = Security.NullLeverage,
bool  extendedMarketHours = false,
DataMappingMode dataMappingMode = null,
DataNormalizationMode dataNormalizationMode = null,
int  contractDepthOffset = 0 
)

Set a required SecurityType-symbol and resolution for algorithm

Parameters
symbolThe security Symbol
resolutionResolution of the MarketType required: MarketData, Second or Minute
fillForwardIf true, returns the last available data even if none in that timeslice.
leverageleverage for this security
extendedMarketHoursUse extended market hours data
dataMappingModeThe contract mapping mode to use for the security
dataNormalizationModeThe price scaling mode to use for the security
contractDepthOffsetThe continuous contract desired offset from the current front month. For example, 0 (default) will use the front month, 1 will use the back month contract
Returns
The new Security that was added to the algorithm

Implements QuantConnect.Interfaces.IAlgorithm.

◆ AddFutureContract()

Future QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddFutureContract ( Symbol  symbol,
Resolution resolution = null,
bool  fillForward = true,
decimal  leverage = 0m,
bool  extendedMarketHours = false 
)

Creates and adds a new single Future contract to the algorithm

Parameters
symbolThe futures contract symbol
resolutionThe Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.Minute
fillForwardIf true, returns the last available data even if none in that timeslice. Default is

true

Parameters
leverageThe requested leverage for this equity. Default is set by SecurityInitializer
extendedMarketHoursUse extended market hours data
Returns
The new Future security

Implements QuantConnect.Interfaces.IAlgorithm.

◆ AddOptionContract()

Option QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddOptionContract ( Symbol  symbol,
Resolution resolution = null,
bool  fillForward = true,
decimal  leverage = 0m,
bool  extendedMarketHours = false 
)

Creates and adds a new single Option contract to the algorithm

Parameters
symbolThe option contract symbol
resolutionThe Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.Minute
fillForwardIf true, returns the last available data even if none in that timeslice. Default is

true

Parameters
leverageThe requested leverage for this equity. Default is set by SecurityInitializer
extendedMarketHoursUse extended market hours data
Returns
The new Option security

Implements QuantConnect.Interfaces.IAlgorithm.

◆ OnEndOfTimeStep()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnEndOfTimeStep ( )

Invoked at the end of every time step. This allows the algorithm to process events before advancing to the next time step.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 627 of file AlgorithmPythonWrapper.cs.

◆ Debug()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Debug ( string  message)

Send debug message

Parameters
messageString message

Implements QuantConnect.Interfaces.IAlgorithm.

◆ Error()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Error ( string  message)

Send an error message for the algorithm

Parameters
messageString message

Implements QuantConnect.Interfaces.IAlgorithm.

◆ AddChart()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddChart ( Chart  chart)

Add a Chart object to algorithm collection

Parameters
chartChart object to add to collection.

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetChartUpdates()

IEnumerable<Chart> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetChartUpdates ( bool  clearChartData = false)

Get the chart updates since the last request:

Parameters
clearChartData
Returns
List of Chart Updates

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetLocked()

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetLocked ( )

Gets whether or not this algorithm has been locked and fully initialized

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetParameters()

IReadOnlyDictionary<string, string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetParameters ( )

Gets a read-only dictionary with all current parameters

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetParameter() [1/4]

string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetParameter ( string  name,
string  defaultValue = null 
)

Gets the parameter with the specified name. If a parameter with the specified name does not exist, the given default value is returned if any, else null

Parameters
nameThe name of the parameter to get
defaultValueThe default value to return
Returns
The value of the specified parameter, or defaultValue if not found or null if there's no default value

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetParameter() [2/4]

int QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetParameter ( string  name,
int  defaultValue 
)

Gets the parameter with the specified name parsed as an integer. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned

Parameters
nameThe name of the parameter to get
defaultValueThe default value to return
Returns
The value of the specified parameter, or defaultValue if not found or null if there's no default value

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetParameter() [3/4]

double QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetParameter ( string  name,
double  defaultValue 
)

Gets the parameter with the specified name parsed as a double. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned

Parameters
nameThe name of the parameter to get
defaultValueThe default value to return
Returns
The value of the specified parameter, or defaultValue if not found or null if there's no default value

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetParameter() [4/4]

decimal QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetParameter ( string  name,
decimal  defaultValue 
)

Gets the parameter with the specified name parsed as a decimal. If a parameter with the specified name does not exist, or the conversion is not possible, the given default value is returned

Parameters
nameThe name of the parameter to get
defaultValueThe default value to return
Returns
The value of the specified parameter, or defaultValue if not found or null if there's no default value

Implements QuantConnect.Interfaces.IAlgorithm.

◆ Initialize()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Initialize ( )

Initialise the Algorithm and Prepare Required Data:

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 706 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:

◆ Liquidate()

List<int> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Liquidate ( Symbol  symbolToLiquidate = null,
string  tag = "Liquidated" 
)

Liquidate your portfolio holdings:

Parameters
symbolToLiquidateSpecific asset to liquidate, defaults to all.
tagCustom tag to know who is calling this.
Returns
list of order ids

Implements QuantConnect.Interfaces.IAlgorithm.

◆ Log()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Log ( string  message)

Save entry to the Log

Parameters
messageString message

Implements QuantConnect.Interfaces.IAlgorithm.

◆ OnBrokerageDisconnect()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnBrokerageDisconnect ( )

Brokerage disconnected event handler. This method is called when the brokerage connection is lost.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 728 of file AlgorithmPythonWrapper.cs.

◆ OnBrokerageMessage()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnBrokerageMessage ( BrokerageMessageEvent  messageEvent)

Brokerage message event handler. This method is called for all types of brokerage messages.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 736 of file AlgorithmPythonWrapper.cs.

◆ OnBrokerageReconnect()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnBrokerageReconnect ( )

Brokerage reconnected event handler. This method is called when the brokerage connection is restored after a disconnection.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 744 of file AlgorithmPythonWrapper.cs.

◆ OnData()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnData ( Slice  slice)

v3.0 Handler for all data types

Parameters
sliceThe current slice of data

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 753 of file AlgorithmPythonWrapper.cs.

◆ OnFrameworkData()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnFrameworkData ( Slice  slice)

Used to send data updates to algorithm framework models

Parameters
sliceThe current data slice

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 768 of file AlgorithmPythonWrapper.cs.

◆ OnSplits()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnSplits ( Splits  splits)

Event handler to be called when there's been a split event

Parameters
splitsThe current time slice splits

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 777 of file AlgorithmPythonWrapper.cs.

◆ OnDividends()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnDividends ( Dividends  dividends)

Event handler to be called when there's been a dividend event

Parameters
dividendsThe current time slice dividends

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 786 of file AlgorithmPythonWrapper.cs.

◆ OnDelistings()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnDelistings ( Delistings  delistings)

Event handler to be called when there's been a delistings event

Parameters
delistingsThe current time slice delistings

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 795 of file AlgorithmPythonWrapper.cs.

◆ OnSymbolChangedEvents()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnSymbolChangedEvents ( SymbolChangedEvents  symbolsChanged)

Event handler to be called when there's been a symbol changed event

Parameters
symbolsChangedThe current time slice symbol changed events

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 804 of file AlgorithmPythonWrapper.cs.

◆ OnEndOfAlgorithm()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnEndOfAlgorithm ( )

Call this event at the end of the algorithm running.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 812 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:

◆ OnEndOfDay() [1/2]

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnEndOfDay ( )

End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).

Method is called 10 minutes before closing to allow user to close out position.

Deprecated because different assets have different market close times, and because Python does not support two methods with the same name

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 824 of file AlgorithmPythonWrapper.cs.

◆ OnEndOfDay() [2/2]

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnEndOfDay ( Symbol  symbol)

End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).

This method is left for backwards compatibility and is invoked via OnEndOfDay(Symbol), if that method is override then this method will not be called without a called to base.OnEndOfDay(string)

Parameters
symbolAsset symbol for this end of day event. Forex and equities have different closing hours.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 849 of file AlgorithmPythonWrapper.cs.

◆ OnMarginCall()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnMarginCall ( List< SubmitOrderRequest requests)

Margin call event handler. This method is called right before the margin call orders are placed in the market.

Parameters
requestsThe orders to be executed to bring this algorithm within margin limits

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 870 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:

◆ OnMarginCallWarning()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnMarginCallWarning ( )

Margin call warning event handler. This method is called when Portfolio.MarginRemaining is under 5% of your Portfolio.TotalPortfolioValue

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 909 of file AlgorithmPythonWrapper.cs.

◆ OnOrderEvent()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnOrderEvent ( OrderEvent  newEvent)

EXPERTS ONLY:: [-!-Async Code-!-] New order event handler: on order status changes (filled, partially filled, cancelled etc).

Parameters
newEventEvent information

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 919 of file AlgorithmPythonWrapper.cs.

◆ SubmitOrderRequest()

OrderTicket QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SubmitOrderRequest ( SubmitOrderRequest  request)

Will submit an order request to the algorithm

Parameters
requestThe request to submit

Will run order prechecks, which include making sure the algorithm is not warming up, security is added and has data among others

Returns
The order ticket

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 930 of file AlgorithmPythonWrapper.cs.

◆ OnAssignmentOrderEvent()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnAssignmentOrderEvent ( OrderEvent  assignmentEvent)

Option assignment event handler. On an option assignment event for short legs the resulting information is passed to this method.

Parameters
assignmentEventOption exercise event details containing details of the assignment

This method can be called asynchronously and so should only be used by seasoned C# experts. Ensure you use proper locks on thread-unsafe objects

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 940 of file AlgorithmPythonWrapper.cs.

◆ OnSecuritiesChanged()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnSecuritiesChanged ( SecurityChanges  changes)

Event fired each time the we add/remove securities from the data feed

Parameters
changesSecurity additions/removals for this time step

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 949 of file AlgorithmPythonWrapper.cs.

◆ OnFrameworkSecuritiesChanged()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnFrameworkSecuritiesChanged ( SecurityChanges  changes)

Used to send security changes to algorithm framework models

Parameters
changesSecurity additions/removals for this time step

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 958 of file AlgorithmPythonWrapper.cs.

◆ PostInitialize()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.PostInitialize ( )

Called by setup handlers after Initialize and allows the algorithm a chance to organize the data gather in the Initialize method

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 967 of file AlgorithmPythonWrapper.cs.

◆ OnWarmupFinished()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnWarmupFinished ( )

Called when the algorithm has completed initialization and warm up.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 975 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveSecurity()

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.RemoveSecurity ( Symbol  symbol)

Removes the security with the specified symbol. This will cancel all open orders and then liquidate any existing holdings

Parameters
symbolThe symbol of the security to be removed

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetAlgorithmId()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetAlgorithmId ( string  algorithmId)

Set the algorithm Id for this backtest or live run. This can be used to identify the order and equity records.

Parameters
algorithmIdunique 32 character identifier for backtest or live server

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetBrokerageMessageHandler()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetBrokerageMessageHandler ( IBrokerageMessageHandler  handler)

Sets the implementation used to handle messages from the brokerage. The default implementation will forward messages to debug or error and when a BrokerageMessageType.Error occurs, the algorithm is stopped.

Parameters
handlerThe message handler to use

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetBrokerageModel()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetBrokerageModel ( IBrokerageModel  brokerageModel)

Sets the brokerage model used to resolve transaction models, settlement models, and brokerage specified ordering behaviors.

Parameters
brokerageModelThe brokerage model used to emulate the real brokerage

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetAccountCurrency()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetAccountCurrency ( string  accountCurrency,
decimal?  startingCash = null 
)

Sets the account currency cash symbol this algorithm is to manage, as well as the starting cash in this currency if given

Has to be called during Initialize before calling SetCash(decimal) or adding any Security

Parameters
accountCurrencyThe account currency cash symbol to set
startingCashThe account currency starting cash to set

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetCash() [1/2]

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetCash ( decimal  startingCash)

Set the starting capital for the strategy

Parameters
startingCashdecimal starting capital, default $100,000

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetCash() [2/2]

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetCash ( string  symbol,
decimal  startingCash,
decimal  conversionRate = 0 
)

Set the cash for the specified symbol

Parameters
symbolThe cash symbol to set
startingCashDecimal cash value of portfolio
conversionRateThe current conversion rate for the

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetDateTime()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetDateTime ( DateTime  time)

Set the DateTime Frontier: This is the master time and is

Parameters
time

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetStartDate()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetStartDate ( DateTime  start)

Set the start date for the backtest

Parameters
startDatetime Start date for backtest

Must be less than end date and within data available

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetEndDate()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetEndDate ( DateTime  end)

Set the end date for a backtest.

Parameters
endDatetime value for end date

Must be greater than the start date

Implements QuantConnect.Interfaces.IAlgorithm.

◆ GetLastKnownPrice()

BaseData QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.GetLastKnownPrice ( Security  security)

Get the last known price using the history provider. Useful for seeding securities with the correct price

Parameters
securitySecurity object for which to retrieve historical data
Returns
A single BaseData object with the last known price

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetRunTimeError()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetRunTimeError ( Exception  exception)

Set the runtime error

Parameters
exceptionRepresents error that occur during execution

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetFinishedWarmingUp()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetFinishedWarmingUp ( )

Sets IsWarmingUp to false to indicate this algorithm has finished its warm up

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1071 of file AlgorithmPythonWrapper.cs.

Here is the call graph for this function:

◆ SetHistoryProvider()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetHistoryProvider ( IHistoryProvider  historyProvider)

Set the historical data provider

Parameters
historyProviderHistorical data provider

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetLiveMode()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetLiveMode ( bool  live)

Set live mode state of the algorithm run: Public setter for the algorithm property LiveMode.

Parameters
liveBool live mode flag

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetAlgorithmMode()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetAlgorithmMode ( AlgorithmMode  algorithmMode)

Sets the algorithm running mode

Parameters
algorithmModeAlgorithm mode

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetDeploymentTarget()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetDeploymentTarget ( DeploymentTarget  deploymentTarget)

Sets the algorithm deployment target

Parameters
deploymentTargetDeployment target

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetLocked()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetLocked ( )

Set the algorithm as initialized and locked. No more cash or security changes.

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetMaximumOrders()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetMaximumOrders ( int  max)

Set the maximum number of orders the algorithm is allowed to process.

Parameters
maxMaximum order count int

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetParameters()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetParameters ( Dictionary< string, string >  parameters)

Sets the parameters from the dictionary

Parameters
parametersDictionary containing the parameter names to values

Implements QuantConnect.Interfaces.IAlgorithm.

◆ ToString()

override string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.ToString ( )

Returns a string that represents the current AlgorithmPythonWrapper object.

Returns

Definition at line 1144 of file AlgorithmPythonWrapper.cs.

◆ SetCurrentSlice()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetCurrentSlice ( Slice  slice)

Sets the current slice

Parameters
sliceThe Slice object

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1160 of file AlgorithmPythonWrapper.cs.

◆ SetApi()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetApi ( IApi  api)

Provide the API for the algorithm.

Parameters
apiInitiated API

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetObjectStore()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetObjectStore ( IObjectStore  objectStore)

Sets the object store

Parameters
objectStoreThe object store

Implements QuantConnect.Interfaces.IAlgorithm.

◆ Shortable()

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Shortable ( Symbol  symbol,
decimal  shortQuantity,
int?  updateOrderId = null 
)

Determines if the Symbol is shortable at the brokerage

Parameters
symbolSymbol to check if shortable
shortQuantityOrder's quantity to check if it is currently shortable, taking into account current holdings and open orders
updateOrderIdOptionally the id of the order being updated. When updating an order we want to ignore it's submitted short quantity and use the new provided quantity to determine if we can perform the update
Returns
True if the symbol can be shorted by the requested quantity

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1186 of file AlgorithmPythonWrapper.cs.

◆ ShortableQuantity()

long QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.ShortableQuantity ( Symbol  symbol)

Gets the quantity shortable for the given asset

Returns
Quantity shortable for the given asset. Zero if not shortable, or a number greater than zero if shortable.

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1198 of file AlgorithmPythonWrapper.cs.

◆ Symbol()

Symbol QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Symbol ( string  ticker)

Converts the string 'ticker' symbol into a full Symbol object This requires that the string 'ticker' has been added to the algorithm

Parameters
tickerThe ticker symbol. This should be the ticker symbol as it was added to the algorithm
Returns
The symbol object mapped to the specified ticker

Implements QuantConnect.Interfaces.IAlgorithm.

◆ Ticker()

string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Ticker ( Symbol  symbol)

For the given symbol will resolve the ticker it used at the current algorithm date

Parameters
symbolThe symbol to get the ticker for
Returns
The mapped ticker for a symbol

Implements QuantConnect.Interfaces.IAlgorithm.

◆ SetName()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetName ( string  name)

Sets name to the currently running backtest

Parameters
nameThe name for the backtest

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1223 of file AlgorithmPythonWrapper.cs.

◆ AddTag()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AddTag ( string  tag)

Adds a tag to the algorithm

Parameters
tagThe tag to add

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1232 of file AlgorithmPythonWrapper.cs.

◆ SetTags()

void QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SetTags ( HashSet< string >  tags)

Sets the tags for the algorithm

Parameters
tagsThe tags

Implements QuantConnect.Interfaces.IAlgorithm.

Definition at line 1241 of file AlgorithmPythonWrapper.cs.

Member Data Documentation

◆ AlgorithmId

string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AlgorithmId => _baseAlgorithm.AlgorithmId

AlgorithmId for the backtest

Definition at line 186 of file AlgorithmPythonWrapper.cs.

◆ Benchmark

IBenchmark QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Benchmark => _baseAlgorithm.Benchmark

Gets the function used to define the benchmark. This function will return the value of the benchmark at a requested date/time

Definition at line 192 of file AlgorithmPythonWrapper.cs.

◆ BrokerageModel

IBrokerageModel QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.BrokerageModel => _baseAlgorithm.BrokerageModel

Gets the brokerage model used to emulate a real brokerage

Definition at line 214 of file AlgorithmPythonWrapper.cs.

◆ BrokerageName

BrokerageName QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.BrokerageName => _baseAlgorithm.BrokerageName

Gets the brokerage name.

Definition at line 219 of file AlgorithmPythonWrapper.cs.

◆ RiskFreeInterestRateModel

IRiskFreeInterestRateModel QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.RiskFreeInterestRateModel => _baseAlgorithm.RiskFreeInterestRateModel

Gets the risk free interest rate model used to get the interest rates

Definition at line 224 of file AlgorithmPythonWrapper.cs.

◆ DebugMessages

ConcurrentQueue<string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.DebugMessages => _baseAlgorithm.DebugMessages

Debug messages from the strategy:

Definition at line 229 of file AlgorithmPythonWrapper.cs.

◆ EndDate

DateTime QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.EndDate => _baseAlgorithm.EndDate

Get Requested Backtest End Date

Definition at line 234 of file AlgorithmPythonWrapper.cs.

◆ ErrorMessages

ConcurrentQueue<string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.ErrorMessages => _baseAlgorithm.ErrorMessages

Error messages from the strategy:

Definition at line 239 of file AlgorithmPythonWrapper.cs.

◆ IsWarmingUp

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.IsWarmingUp => _baseAlgorithm.IsWarmingUp

Gets whether or not this algorithm is still warming up

Definition at line 260 of file AlgorithmPythonWrapper.cs.

◆ LiveMode

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.LiveMode => _baseAlgorithm.LiveMode

Algorithm is running on a live server.

Definition at line 265 of file AlgorithmPythonWrapper.cs.

◆ AlgorithmMode

AlgorithmMode QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AlgorithmMode => _baseAlgorithm.AlgorithmMode

Algorithm running mode.

Definition at line 270 of file AlgorithmPythonWrapper.cs.

◆ DeploymentTarget

DeploymentTarget QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.DeploymentTarget => _baseAlgorithm.DeploymentTarget

Deployment target, either local or cloud.

Definition at line 275 of file AlgorithmPythonWrapper.cs.

◆ LogMessages

ConcurrentQueue<string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.LogMessages => _baseAlgorithm.LogMessages

Log messages from the strategy:

Definition at line 280 of file AlgorithmPythonWrapper.cs.

◆ Notify

NotificationManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Notify => _baseAlgorithm.Notify

Notification manager for storing and processing live event messages

Definition at line 348 of file AlgorithmPythonWrapper.cs.

◆ Portfolio

SecurityPortfolioManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Portfolio => _baseAlgorithm.Portfolio

Security portfolio management class provides wrapper and helper methods for the Security.Holdings class such as IsLong, IsShort, TotalProfit

Portfolio is a wrapper and helper class encapsulating the Securities[].Holdings objects

Definition at line 355 of file AlgorithmPythonWrapper.cs.

◆ RuntimeStatistics

ConcurrentDictionary<string, string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.RuntimeStatistics => _baseAlgorithm.RuntimeStatistics

Customizable dynamic statistics displayed during live trading:

Definition at line 376 of file AlgorithmPythonWrapper.cs.

◆ Schedule

ScheduleManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Schedule => _baseAlgorithm.Schedule

Gets schedule manager for adding/removing scheduled events

Definition at line 381 of file AlgorithmPythonWrapper.cs.

◆ Securities

SecurityManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Securities => _baseAlgorithm.Securities

Security object collection class stores an array of objects representing representing each security/asset we have a subscription for.

It is an IDictionary implementation and can be indexed by symbol

Definition at line 388 of file AlgorithmPythonWrapper.cs.

◆ SecurityInitializer

ISecurityInitializer QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SecurityInitializer => _baseAlgorithm.SecurityInitializer

Gets an instance that is to be used to initialize newly created securities.

Definition at line 393 of file AlgorithmPythonWrapper.cs.

◆ TradeBuilder

ITradeBuilder QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.TradeBuilder => _baseAlgorithm.TradeBuilder

Gets the Trade Builder to generate trades from executions

Definition at line 398 of file AlgorithmPythonWrapper.cs.

◆ Settings

IAlgorithmSettings QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Settings => _baseAlgorithm.Settings

Gets the user settings for the algorithm

Definition at line 403 of file AlgorithmPythonWrapper.cs.

◆ OptionChainProvider

IOptionChainProvider QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OptionChainProvider => _baseAlgorithm.OptionChainProvider

Gets the option chain provider, used to get the list of option contracts for an underlying symbol

Definition at line 408 of file AlgorithmPythonWrapper.cs.

◆ FutureChainProvider

IFutureChainProvider QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.FutureChainProvider => _baseAlgorithm.FutureChainProvider

Gets the future chain provider, used to get the list of future contracts for an underlying symbol

Definition at line 413 of file AlgorithmPythonWrapper.cs.

◆ ObjectStore

ObjectStore QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.ObjectStore => _baseAlgorithm.ObjectStore

Gets the object store, used for persistence

Definition at line 418 of file AlgorithmPythonWrapper.cs.

◆ CurrentSlice

Slice QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.CurrentSlice => _baseAlgorithm.CurrentSlice

Returns the current Slice object

Definition at line 423 of file AlgorithmPythonWrapper.cs.

◆ StartDate

DateTime QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.StartDate => _baseAlgorithm.StartDate

Algorithm start date for backtesting, set by the SetStartDate methods.

Definition at line 428 of file AlgorithmPythonWrapper.cs.

◆ TimeKeeper

ITimeKeeper QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.TimeKeeper => _baseAlgorithm.TimeKeeper

Gets the time keeper instance

Definition at line 489 of file AlgorithmPythonWrapper.cs.

◆ SubscriptionManager

SubscriptionManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.SubscriptionManager => _baseAlgorithm.SubscriptionManager

Data subscription manager controls the information and subscriptions the algorithms recieves. Subscription configurations can be added through the Subscription Manager.

Definition at line 495 of file AlgorithmPythonWrapper.cs.

◆ Time

DateTime QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Time => _baseAlgorithm.Time

Current date/time in the algorithm's local time zone

Definition at line 515 of file AlgorithmPythonWrapper.cs.

◆ TimeZone

DateTimeZone QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.TimeZone => _baseAlgorithm.TimeZone

Gets the time zone of the algorithm

Definition at line 520 of file AlgorithmPythonWrapper.cs.

◆ Transactions

SecurityTransactionManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Transactions => _baseAlgorithm.Transactions

Security transaction manager class controls the store and processing of orders.

The orders and their associated events are accessible here. When a new OrderEvent is recieved the algorithm portfolio is updated.

Definition at line 526 of file AlgorithmPythonWrapper.cs.

◆ UniverseManager

UniverseManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.UniverseManager => _baseAlgorithm.UniverseManager

Gets the collection of universes for the algorithm

Definition at line 531 of file AlgorithmPythonWrapper.cs.

◆ UniverseSettings

UniverseSettings QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.UniverseSettings => _baseAlgorithm.UniverseSettings

Gets the subscription settings to be used when adding securities via universe selection

Definition at line 536 of file AlgorithmPythonWrapper.cs.

◆ UtcTime

DateTime QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.UtcTime => _baseAlgorithm.UtcTime

Current date/time in UTC.

Definition at line 541 of file AlgorithmPythonWrapper.cs.

◆ AccountCurrency

string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.AccountCurrency => _baseAlgorithm.AccountCurrency

Gets the account currency

Definition at line 546 of file AlgorithmPythonWrapper.cs.

◆ Insights

InsightManager QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Insights => _baseAlgorithm.Insights

Gets the insight manager

Definition at line 551 of file AlgorithmPythonWrapper.cs.

◆ Statistics

StatisticsResults QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Statistics => _baseAlgorithm.Statistics

The current statistics for the running algorithm.

Definition at line 562 of file AlgorithmPythonWrapper.cs.

Property Documentation

◆ IsOnEndOfDayImplemented

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.IsOnEndOfDayImplemented
get

True if the underlying python algorithm implements "OnEndOfDay"

Definition at line 72 of file AlgorithmPythonWrapper.cs.

◆ IsOnEndOfDaySymbolImplemented

bool QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.IsOnEndOfDaySymbolImplemented
get

True if the underlying python algorithm implements "OnEndOfDay(symbol)"

Definition at line 77 of file AlgorithmPythonWrapper.cs.

◆ BrokerageMessageHandler

IBrokerageMessageHandler QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.BrokerageMessageHandler
getset

Gets the brokerage message handler used to decide what to do with each message sent from the brokerage

Definition at line 199 of file AlgorithmPythonWrapper.cs.

◆ HistoryProvider

IHistoryProvider QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.HistoryProvider
getset

Gets or sets the history provider for the algorithm

Definition at line 245 of file AlgorithmPythonWrapper.cs.

◆ Name

string QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Name
getset

Public name for the algorithm.

Not currently used but preserved for API integrity

Definition at line 287 of file AlgorithmPythonWrapper.cs.

◆ Tags

HashSet<string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Tags
getset

A list of tags associated with the algorithm or the backtest, useful for categorization

Definition at line 302 of file AlgorithmPythonWrapper.cs.

◆ NameUpdated

AlgorithmEvent<string> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.NameUpdated
addremove

Event fired algorithm's name is changed

Definition at line 317 of file AlgorithmPythonWrapper.cs.

◆ TagsUpdated

AlgorithmEvent<HashSet<string> > QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.TagsUpdated
addremove

Event fired when the tag collection is updated

Definition at line 333 of file AlgorithmPythonWrapper.cs.

◆ RunTimeError

Exception QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.RunTimeError
getset

Gets the run time error from the algorithm, or null if none was encountered.

Definition at line 361 of file AlgorithmPythonWrapper.cs.

◆ Status

AlgorithmStatus QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Status
getset

Gets or sets the current status of the algorithm

Definition at line 434 of file AlgorithmPythonWrapper.cs.

◆ InsightsGenerated

AlgorithmEvent<GeneratedInsightsCollection> QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.InsightsGenerated
addremove

Event fired when an algorithm generates a insight

Definition at line 474 of file AlgorithmPythonWrapper.cs.

◆ ProjectId

int QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.ProjectId
getset

The project id associated with this algorithm if any

Definition at line 501 of file AlgorithmPythonWrapper.cs.


The documentation for this class was generated from the following file: