Lean
$LEAN_TAG$
|
Interface for QuantConnect algorithm implementations. All algorithms must implement these basic members to allow interaction with the Lean Backtesting Engine. More...
Public Member Functions | |
void | Initialize () |
Initialise the Algorithm and Prepare Required Data: 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... | |
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 | SetParameters (Dictionary< string, string > parameters) |
Sets the parameters from the dictionary 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... | |
void | SetBrokerageModel (IBrokerageModel brokerageModel) |
Sets the brokerage model used to resolve transaction models, settlement models, and brokerage specified ordering behaviors. 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 | OnSecuritiesChanged (SecurityChanges changes) |
Event fired each time that we add/remove securities from the data feed More... | |
void | OnFrameworkSecuritiesChanged (SecurityChanges changes) |
Used to send security changes to algorithm framework models 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 | Log (string message) |
Save entry to the Log More... | |
void | Error (string message) |
Send an error message for the algorithm 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 | OnEndOfDay () |
Call this method at the end of each day of data. More... | |
void | OnEndOfDay (Symbol symbol) |
Call this method at the end of each day of data. More... | |
void | OnEndOfAlgorithm () |
Call this event at the end of the algorithm running. More... | |
void | OnOrderEvent (OrderEvent newEvent) |
EXPERTS ONLY:: [-!-Async Code-!-] New order event handler: on order status changes (filled, partially filled, cancelled etc). More... | |
bool? | OnCommand (dynamic data) |
Generic untyped command call handler 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 | OnBrokerageMessage (BrokerageMessageEvent messageEvent) |
Brokerage message event handler. This method is called for all types of brokerage messages. More... | |
void | OnBrokerageDisconnect () |
Brokerage disconnected event handler. This method is called when the brokerage connection is lost. More... | |
void | OnBrokerageReconnect () |
Brokerage reconnected event handler. This method is called when the brokerage connection is restored after a disconnection. 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... | |
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 | SetLocked () |
Set the algorithm as initialized and locked. No more cash or security changes. More... | |
bool | GetLocked () |
Gets whether or not this algorithm has been locked and fully initialized More... | |
void | AddChart (Chart chart) |
Add a Chart object to algorithm collection More... | |
IEnumerable< Chart > | GetChartUpdates (bool clearChartData=false) |
Get the chart updates since the last request: 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... | |
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 | 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... | |
List< OrderTicket > | Liquidate (Symbol symbol=null, bool asynchronous=false, string tag="Liquidated", IOrderProperties orderProperties=null) |
Liquidate your portfolio holdings 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 | SetFinishedWarmingUp () |
Sets IsWarmingUp to false to indicate this algorithm has finished its warm up More... | |
void | SetMaximumOrders (int max) |
Set the maximum number of orders the algorithm is allowed to process. 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 | SetHistoryProvider (IHistoryProvider historyProvider) |
Set the historical data provider 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 | 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 | 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... | |
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 | SetStatisticsService (IStatisticsService statisticsService) |
Sets the statistics service instance to be used by the algorithm 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... | |
CommandResultPacket | RunCommand (CallbackCommand command) |
Run a callback command instance More... | |
Properties | |
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... | |
Events | |
AlgorithmEvent< GeneratedInsightsCollection > | InsightsGenerated |
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... | |
Interface for QuantConnect algorithm implementations. All algorithms must implement these basic members to allow interaction with the Lean Backtesting Engine.
Definition at line 51 of file IAlgorithm.cs.
void QuantConnect.Interfaces.IAlgorithm.Initialize | ( | ) |
Initialise the Algorithm and Prepare Required Data:
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.PostInitialize | ( | ) |
Called by setup handlers after Initialize and allows the algorithm a chance to organize the data gather in the Initialize method
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnWarmupFinished | ( | ) |
Called when the algorithm has completed initialization and warm up.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
IReadOnlyDictionary<string, string> QuantConnect.Interfaces.IAlgorithm.GetParameters | ( | ) |
Gets a read-only dictionary with all current parameters
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
string QuantConnect.Interfaces.IAlgorithm.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
name | The name of the parameter to get |
defaultValue | The default value to return |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
int QuantConnect.Interfaces.IAlgorithm.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
name | The name of the parameter to get |
defaultValue | The default value to return |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
double QuantConnect.Interfaces.IAlgorithm.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
name | The name of the parameter to get |
defaultValue | The default value to return |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
decimal QuantConnect.Interfaces.IAlgorithm.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
name | The name of the parameter to get |
defaultValue | The default value to return |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetParameters | ( | Dictionary< string, string > | parameters | ) |
Sets the parameters from the dictionary
parameters | Dictionary containing the parameter names to values |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
bool QuantConnect.Interfaces.IAlgorithm.Shortable | ( | Symbol | symbol, |
decimal | shortQuantity, | ||
int? | updateOrderId = null |
||
) |
Determines if the Symbol is shortable at the brokerage
symbol | Symbol to check if shortable |
shortQuantity | Order's quantity to check if it is currently shortable, taking into account current holdings and open orders |
updateOrderId | Optionally 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 |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
long QuantConnect.Interfaces.IAlgorithm.ShortableQuantity | ( | Symbol | symbol | ) |
Gets the quantity shortable for the given asset
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetBrokerageModel | ( | IBrokerageModel | brokerageModel | ) |
Sets the brokerage model used to resolve transaction models, settlement models, and brokerage specified ordering behaviors.
brokerageModel | The brokerage model used to emulate the real brokerage |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnData | ( | Slice | slice | ) |
v3.0 Handler for all data types
slice | The current slice of data |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnFrameworkData | ( | Slice | slice | ) |
Used to send data updates to algorithm framework models
slice | The current data slice |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnSplits | ( | Splits | splits | ) |
Event handler to be called when there's been a split event
splits | The current time slice splits |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnDividends | ( | Dividends | dividends | ) |
Event handler to be called when there's been a dividend event
dividends | The current time slice dividends |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnDelistings | ( | Delistings | delistings | ) |
Event handler to be called when there's been a delistings event
delistings | The current time slice delistings |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnSymbolChangedEvents | ( | SymbolChangedEvents | symbolsChanged | ) |
Event handler to be called when there's been a symbol changed event
symbolsChanged | The current time slice symbol changed events |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnSecuritiesChanged | ( | SecurityChanges | changes | ) |
Event fired each time that we add/remove securities from the data feed
changes | Security additions/removals for this time step |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnFrameworkSecuritiesChanged | ( | SecurityChanges | changes | ) |
Used to send security changes to algorithm framework models
changes | Security additions/removals for this time step |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnEndOfTimeStep | ( | ) |
Invoked at the end of every time step. This allows the algorithm to process events before advancing to the next time step.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.Debug | ( | string | message | ) |
Send debug message
message |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.Log | ( | string | message | ) |
Save entry to the Log
message | String message |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.Error | ( | string | message | ) |
Send an error message for the algorithm
message | String message |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnMarginCall | ( | List< SubmitOrderRequest > | requests | ) |
Margin call event handler. This method is called right before the margin call orders are placed in the market.
requests | The orders to be executed to bring this algorithm within margin limits |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnMarginCallWarning | ( | ) |
Margin call warning event handler. This method is called when Portfolio.MarginRemaining is under 5% of your Portfolio.TotalPortfolioValue
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnEndOfDay | ( | ) |
Call this method at the end of each day of data.
Deprecated because different assets have different market close times, and because Python does not support two methods with the same name
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnEndOfDay | ( | Symbol | symbol | ) |
Call this method at the end of each day of data.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnEndOfAlgorithm | ( | ) |
Call this event at the end of the algorithm running.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnOrderEvent | ( | OrderEvent | newEvent | ) |
EXPERTS ONLY:: [-!-Async Code-!-] New order event handler: on order status changes (filled, partially filled, cancelled etc).
newEvent | Event information |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
bool? QuantConnect.Interfaces.IAlgorithm.OnCommand | ( | dynamic | data | ) |
Generic untyped command call handler
data | The associated data |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
OrderTicket QuantConnect.Interfaces.IAlgorithm.SubmitOrderRequest | ( | SubmitOrderRequest | request | ) |
Will submit an order request to the algorithm
request | The 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
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnAssignmentOrderEvent | ( | OrderEvent | assignmentEvent | ) |
Option assignment event handler. On an option assignment event for short legs the resulting information is passed to this method.
assignmentEvent | Option 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
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnBrokerageMessage | ( | BrokerageMessageEvent | messageEvent | ) |
Brokerage message event handler. This method is called for all types of brokerage messages.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnBrokerageDisconnect | ( | ) |
Brokerage disconnected event handler. This method is called when the brokerage connection is lost.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.OnBrokerageReconnect | ( | ) |
Brokerage reconnected event handler. This method is called when the brokerage connection is restored after a disconnection.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetDateTime | ( | DateTime | time | ) |
Set the DateTime Frontier: This is the master time and is
time |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetStartDate | ( | DateTime | start | ) |
Set the start date for the backtest
start | Datetime Start date for backtest |
Must be less than end date and within data available
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetEndDate | ( | DateTime | end | ) |
Set the end date for a backtest.
end | Datetime value for end date |
Must be greater than the start date
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetAlgorithmId | ( | string | algorithmId | ) |
Set the algorithm Id for this backtest or live run. This can be used to identify the order and equity records.
algorithmId | unique 32 character identifier for backtest or live server |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetLocked | ( | ) |
Set the algorithm as initialized and locked. No more cash or security changes.
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
bool QuantConnect.Interfaces.IAlgorithm.GetLocked | ( | ) |
Gets whether or not this algorithm has been locked and fully initialized
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.AddChart | ( | Chart | chart | ) |
Add a Chart object to algorithm collection
chart | Chart object to add to collection. |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
IEnumerable<Chart> QuantConnect.Interfaces.IAlgorithm.GetChartUpdates | ( | bool | clearChartData = false | ) |
Get the chart updates since the last request:
clearChartData |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Security QuantConnect.Interfaces.IAlgorithm.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
securityType | SecurityType Enum: Equity, Commodity, FOREX or Future |
symbol | Symbol Representation of the MarketType, e.g. AAPL |
resolution | Resolution of the MarketType required: MarketData, Second or Minute |
market | The market the requested security belongs to, such as 'usa' or 'fxcm' |
fillForward | If true, returns the last available data even if none in that timeslice. |
leverage | leverage for this security |
extendedMarketHours | ExtendedMarketHours send in data from 4am - 8pm, not used for FOREX |
dataMappingMode | The contract mapping mode to use for the security |
dataNormalizationMode | The price scaling mode to use for the security |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Security QuantConnect.Interfaces.IAlgorithm.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
symbol | The security Symbol |
resolution | Resolution of the MarketType required: MarketData, Second or Minute |
fillForward | If true, returns the last available data even if none in that timeslice. |
leverage | leverage for this security |
extendedMarketHours | Use extended market hours data |
dataMappingMode | The contract mapping mode to use for the security |
dataNormalizationMode | The price scaling mode to use for the security |
contractDepthOffset | The 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 |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Future QuantConnect.Interfaces.IAlgorithm.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
symbol | The futures contract symbol |
resolution | The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.Minute |
fillForward | If true, returns the last available data even if none in that timeslice. Default is |
true
leverage | The requested leverage for this equity. Default is set by SecurityInitializer |
extendedMarketHours | Show the after market data as well |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Option QuantConnect.Interfaces.IAlgorithm.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
symbol | The option contract symbol |
resolution | The Resolution of market data, Tick, Second, Minute, Hour, or Daily. Default is Resolution.Minute |
fillForward | If true, returns the last available data even if none in that timeslice. Default is |
true
leverage | The requested leverage for this equity. Default is set by SecurityInitializer |
extendedMarketHours | Show the after market data as well |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
bool QuantConnect.Interfaces.IAlgorithm.RemoveSecurity | ( | Symbol | symbol | ) |
Removes the security with the specified symbol. This will cancel all open orders and then liquidate any existing holdings
symbol | The symbol of the security to be removed |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.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
accountCurrency | The account currency cash symbol to set |
startingCash | The account currency starting cash to set |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetCash | ( | decimal | startingCash | ) |
Set the starting capital for the strategy
startingCash | decimal starting capital, default $100,000 |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetCash | ( | string | symbol, |
decimal | startingCash, | ||
decimal | conversionRate = 0 |
||
) |
Set the cash for the specified symbol
symbol | The cash symbol to set |
startingCash | Decimal cash value of portfolio |
conversionRate | The current conversion rate for the |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
List<OrderTicket> QuantConnect.Interfaces.IAlgorithm.Liquidate | ( | Symbol | symbol = null , |
bool | asynchronous = false , |
||
string | tag = "Liquidated" , |
||
IOrderProperties | orderProperties = null |
||
) |
Liquidate your portfolio holdings
symbol | Specific asset to liquidate, defaults to all. |
asynchronous | Flag to indicate if the symbols should be liquidated asynchronously |
tag | Custom tag to know who is calling this |
orderProperties | Order properties to use |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetLiveMode | ( | bool | live | ) |
Set live mode state of the algorithm run: Public setter for the algorithm property LiveMode.
live | Bool live mode flag |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetAlgorithmMode | ( | AlgorithmMode | algorithmMode | ) |
Sets the algorithm running mode
algorithmMode | Algorithm mode |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetDeploymentTarget | ( | DeploymentTarget | deploymentTarget | ) |
Sets the algorithm deployment target
deploymentTarget | Deployment target |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetFinishedWarmingUp | ( | ) |
Sets IsWarmingUp to false to indicate this algorithm has finished its warm up
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetMaximumOrders | ( | int | max | ) |
Set the maximum number of orders the algorithm is allowed to process.
max | Maximum order count int |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.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.
handler | The message handler to use |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetHistoryProvider | ( | IHistoryProvider | historyProvider | ) |
Set the historical data provider
historyProvider | Historical data provider |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Get the last known price using the history provider. Useful for seeding securities with the correct price
security | Security object for which to retrieve historical data |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetRunTimeError | ( | Exception | exception | ) |
Set the runtime error
exception | Represents error that occur during execution |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetStatus | ( | AlgorithmStatus | status | ) |
Set the state of a live deployment
status | Live deployment status |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetAvailableDataTypes | ( | Dictionary< SecurityType, List< TickType >> | availableDataTypes | ) |
Set the available TickType supported by each SecurityType in SecurityManager
availableDataTypes | >The different TickType each Security supports |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetOptionChainProvider | ( | IOptionChainProvider | optionChainProvider | ) |
Sets the option chain provider, used to get the list of option contracts for an underlying symbol
optionChainProvider | The option chain provider |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetFutureChainProvider | ( | IFutureChainProvider | futureChainProvider | ) |
Sets the future chain provider, used to get the list of future contracts for an underlying symbol
futureChainProvider | The future chain provider |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetCurrentSlice | ( | Slice | slice | ) |
Sets the current slice
slice | The Slice object |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetApi | ( | IApi | api | ) |
Provide the API for the algorithm.
api | Initiated API |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetObjectStore | ( | IObjectStore | objectStore | ) |
Sets the object store
objectStore | The object store |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
Symbol QuantConnect.Interfaces.IAlgorithm.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
ticker | The ticker symbol. This should be the ticker symbol as it was added to the algorithm |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
string QuantConnect.Interfaces.IAlgorithm.Ticker | ( | Symbol | symbol | ) |
For the given symbol will resolve the ticker it used at the current algorithm date
symbol | The symbol to get the ticker for |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetStatisticsService | ( | IStatisticsService | statisticsService | ) |
Sets the statistics service instance to be used by the algorithm
statisticsService | The statistics service instance |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetName | ( | string | name | ) |
Sets name to the currently running backtest
name | The name for the backtest |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.AddTag | ( | string | tag | ) |
Adds a tag to the algorithm
tag | The tag to add |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
void QuantConnect.Interfaces.IAlgorithm.SetTags | ( | HashSet< string > | tags | ) |
Sets the tags for the algorithm
tags | The tags |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
CommandResultPacket QuantConnect.Interfaces.IAlgorithm.RunCommand | ( | CallbackCommand | command | ) |
Run a callback command instance
command | The callback command instance |
Implemented in QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.
|
get |
Gets the time keeper instance
Definition at line 62 of file IAlgorithm.cs.
|
get |
Data subscription manager controls the information and subscriptions the algorithms recieves. Subscription configurations can be added through the Subscription Manager.
Definition at line 71 of file IAlgorithm.cs.
|
getset |
The project id associated with this algorithm if any
Definition at line 79 of file IAlgorithm.cs.
|
get |
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 90 of file IAlgorithm.cs.
|
get |
Gets the collection of universes for the algorithm
Definition at line 98 of file IAlgorithm.cs.
|
get |
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 108 of file IAlgorithm.cs.
|
get |
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 117 of file IAlgorithm.cs.
|
get |
Gets the brokerage model used to emulate a real brokerage
Definition at line 125 of file IAlgorithm.cs.
|
get |
Gets the brokerage name.
Definition at line 133 of file IAlgorithm.cs.
|
get |
Gets the risk free interest rate model used to get the interest rates
Definition at line 141 of file IAlgorithm.cs.
|
getset |
Gets the brokerage message handler used to decide what to do with each message sent from the brokerage
Definition at line 150 of file IAlgorithm.cs.
|
get |
Notification manager for storing and processing live event messages
Definition at line 159 of file IAlgorithm.cs.
|
get |
Gets schedule manager for adding/removing scheduled events
Definition at line 167 of file IAlgorithm.cs.
|
getset |
Gets or sets the history provider for the algorithm
Definition at line 175 of file IAlgorithm.cs.
|
getset |
Gets or sets the current status of the algorithm
Definition at line 184 of file IAlgorithm.cs.
|
get |
Gets whether or not this algorithm is still warming up
Definition at line 193 of file IAlgorithm.cs.
|
getset |
Public name for the algorithm.
Definition at line 201 of file IAlgorithm.cs.
|
getset |
A list of tags associated with the algorithm or the backtest, useful for categorization
Definition at line 210 of file IAlgorithm.cs.
|
get |
Current date/time in the algorithm's local time zone
Definition at line 229 of file IAlgorithm.cs.
|
get |
Gets the time zone of the algorithm
Definition at line 237 of file IAlgorithm.cs.
|
get |
Current date/time in UTC.
Definition at line 245 of file IAlgorithm.cs.
|
get |
Algorithm start date for backtesting, set by the SetStartDate methods.
Definition at line 253 of file IAlgorithm.cs.
|
get |
Get Requested Backtest End Date
Definition at line 261 of file IAlgorithm.cs.
|
get |
AlgorithmId for the backtest
Definition at line 269 of file IAlgorithm.cs.
|
get |
Algorithm is running on a live server.
Definition at line 277 of file IAlgorithm.cs.
|
get |
Algorithm running mode.
Definition at line 285 of file IAlgorithm.cs.
|
get |
Deployment target, either local or cloud.
Definition at line 293 of file IAlgorithm.cs.
|
get |
Gets the subscription settings to be used when adding securities via universe selection
Definition at line 301 of file IAlgorithm.cs.
|
get |
Debug messages from the strategy:
Definition at line 309 of file IAlgorithm.cs.
|
get |
Error messages from the strategy:
Definition at line 317 of file IAlgorithm.cs.
|
get |
Log messages from the strategy:
Definition at line 325 of file IAlgorithm.cs.
|
getset |
Gets the run time error from the algorithm, or null if none was encountered.
Definition at line 333 of file IAlgorithm.cs.
|
get |
Customizable dynamic statistics displayed during live trading:
Definition at line 342 of file IAlgorithm.cs.
|
get |
The current algorithm statistics for the running algorithm.
Definition at line 350 of file IAlgorithm.cs.
|
get |
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 359 of file IAlgorithm.cs.
|
get |
Gets the Trade Builder to generate trades from executions
Definition at line 367 of file IAlgorithm.cs.
|
get |
Gets the user settings for the algorithm
Definition at line 375 of file IAlgorithm.cs.
|
get |
Gets the option chain provider, used to get the list of option contracts for an underlying symbol
Definition at line 383 of file IAlgorithm.cs.
|
get |
Gets the future chain provider, used to get the list of future contracts for an underlying symbol
Definition at line 391 of file IAlgorithm.cs.
|
get |
Gets the insight manager
Definition at line 399 of file IAlgorithm.cs.
|
get |
Gets the object store, used for persistence
Definition at line 406 of file IAlgorithm.cs.
|
get |
Returns the current Slice object
Definition at line 411 of file IAlgorithm.cs.
AlgorithmEvent<GeneratedInsightsCollection> QuantConnect.Interfaces.IAlgorithm.InsightsGenerated |
Event fired when an algorithm generates a insight
Definition at line 56 of file IAlgorithm.cs.
AlgorithmEvent<string> QuantConnect.Interfaces.IAlgorithm.NameUpdated |
Event fired algorithm's name is changed
Definition at line 218 of file IAlgorithm.cs.
AlgorithmEvent<HashSet<string> > QuantConnect.Interfaces.IAlgorithm.TagsUpdated |
Event fired when the tag collection is updated
Definition at line 223 of file IAlgorithm.cs.