Lean  $LEAN_TAG$
QuantConnect.Api.Api Class Reference

QuantConnect.com Interaction Via API. More...

Inheritance diagram for QuantConnect.Api.Api:
[legend]

Public Member Functions

 Api ()
 Creates a new instance of Api More...
 
virtual void Initialize (int userId, string token, string dataFolder)
 Initialize the API with the given variables More...
 
ProjectResponse CreateProject (string name, Language language, string organizationId=null)
 Create a project with the specified name and language via QuantConnect.com API More...
 
ProjectResponse ReadProject (int projectId)
 Get details about a single project More...
 
ProjectResponse ListProjects ()
 List details of all projects More...
 
RestResponse AddProjectFile (int projectId, string name, string content)
 Add a file to a project More...
 
RestResponse UpdateProjectFileName (int projectId, string oldFileName, string newFileName)
 Update the name of a file More...
 
RestResponse UpdateProjectFileContent (int projectId, string fileName, string newFileContents)
 Update the contents of a file More...
 
ProjectFilesResponse ReadProjectFiles (int projectId)
 Read all files in a project More...
 
ProjectNodesResponse ReadProjectNodes (int projectId)
 Read all nodes in a project. More...
 
ProjectNodesResponse UpdateProjectNodes (int projectId, string[] nodes)
 Update the active state of some nodes to true. If you don't provide any nodes, all the nodes become inactive and AutoSelectNode is true. More...
 
ProjectFilesResponse ReadProjectFile (int projectId, string fileName)
 Read a file in a project More...
 
VersionsResponse ReadLeanVersions ()
 Gets a list of LEAN versions with their corresponding basic descriptions More...
 
RestResponse DeleteProjectFile (int projectId, string name)
 Delete a file in a project More...
 
RestResponse DeleteProject (int projectId)
 Delete a project More...
 
Compile CreateCompile (int projectId)
 Create a new compile job request for this project id. More...
 
Compile ReadCompile (int projectId, string compileId)
 Read a compile packet job result. More...
 
virtual RestResponse SendNotification (Notification notification, int projectId)
 Sends a notification More...
 
Backtest CreateBacktest (int projectId, string compileId, string backtestName)
 Create a new backtest request and get the id. More...
 
Backtest ReadBacktest (int projectId, string backtestId, bool getCharts=true)
 Read out a backtest in the project id specified. More...
 
List< ApiOrderResponseReadBacktestOrders (int projectId, string backtestId, int start=0, int end=100)
 Returns the orders of the specified backtest and project id. More...
 
ReadChartResponse ReadBacktestChart (int projectId, string name, int start, int end, uint count, string backtestId)
 Returns a requested chart object from a backtest More...
 
RestResponse UpdateBacktest (int projectId, string backtestId, string name="", string note="")
 Update a backtest name More...
 
BacktestSummaryList ListBacktests (int projectId, bool includeStatistics=true)
 List all the backtest summaries for a project More...
 
RestResponse DeleteBacktest (int projectId, string backtestId)
 Delete a backtest from the specified project and backtestId. More...
 
RestResponse UpdateBacktestTags (int projectId, string backtestId, IReadOnlyCollection< string > tags)
 Updates the tags collection for a backtest More...
 
InsightResponse ReadBacktestInsights (int projectId, string backtestId, int start=0, int end=0)
 Read out the insights of a backtest More...
 
CreateLiveAlgorithmResponse CreateLiveAlgorithm (int projectId, string compileId, string nodeId, Dictionary< string, object > brokerageSettings, string versionId="-1", Dictionary< string, object > dataProviders=null)
 Create a live algorithm. More...
 
CreateLiveAlgorithmResponse CreateLiveAlgorithm (int projectId, string compileId, string nodeId, PyObject brokerageSettings, string versionId="-1", PyObject dataProviders=null)
 Create a live algorithm. More...
 
LiveList ListLiveAlgorithms (AlgorithmStatus? status=null, DateTime? startTime=null, DateTime? endTime=null)
 Get a list of live running algorithms for user More...
 
LiveAlgorithmResults ReadLiveAlgorithm (int projectId, string deployId)
 Read out a live algorithm in the project id specified. More...
 
PortfolioResponse ReadLivePortfolio (int projectId)
 Read out the portfolio state of a live algorithm More...
 
List< ApiOrderResponseReadLiveOrders (int projectId, int start=0, int end=100)
 Returns the orders of the specified project id live algorithm. More...
 
RestResponse LiquidateLiveAlgorithm (int projectId)
 Liquidate a live algorithm from the specified project and deployId. More...
 
RestResponse StopLiveAlgorithm (int projectId)
 Stop a live algorithm from the specified project and deployId. More...
 
RestResponse CreateLiveCommand (int projectId, object command)
 Create a live command More...
 
LiveLog ReadLiveLogs (int projectId, string algorithmId, int startLine, int endLine)
 Gets the logs of a specific live algorithm More...
 
ReadChartResponse ReadLiveChart (int projectId, string name, int start, int end, uint count)
 Returns a chart object from a live algorithm More...
 
InsightResponse ReadLiveInsights (int projectId, int start=0, int end=0)
 Read out the insights of a live algorithm More...
 
DataLink ReadDataLink (string filePath, string organizationId)
 Gets the link to the downloadable data. More...
 
DataList ReadDataDirectory (string filePath)
 Get valid data entries for a given filepath from data/list More...
 
DataPricesList ReadDataPrices (string organizationId)
 Gets data prices from data/prices More...
 
BacktestReport ReadBacktestReport (int projectId, string backtestId)
 Read out the report of a backtest in the project id specified. More...
 
bool DownloadData (string filePath, string organizationId)
 Method to purchase and download data from QuantConnect More...
 
virtual AlgorithmControl GetAlgorithmStatus (string algorithmId)
 Get the algorithm status from the user with this algorithm id. More...
 
virtual void SetAlgorithmStatus (string algorithmId, AlgorithmStatus status, string message="")
 Algorithm passes back its current status to the UX. More...
 
virtual void SendStatistics (string algorithmId, decimal unrealized, decimal fees, decimal netProfit, decimal holdings, decimal equity, decimal netReturn, decimal volume, int trades, double sharpe)
 Send the statistics to storage for performance tracking. More...
 
virtual void SendUserEmail (string algorithmId, string subject, string body)
 Send an email to the user associated with the specified algorithm id More...
 
virtual string Download (string address, IEnumerable< KeyValuePair< string, string >> headers, string userName, string password)
 Local implementation for downloading data to algorithms More...
 
virtual byte[] DownloadBytes (string address, IEnumerable< KeyValuePair< string, string >> headers, string userName, string password)
 Local implementation for downloading data to algorithms More...
 
virtual void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 
Account ReadAccount (string organizationId=null)
 Will read the organization account status More...
 
Organization ReadOrganization (string organizationId=null)
 Fetch organization data from web API More...
 
Estimate EstimateOptimization (int projectId, string name, string target, string targetTo, decimal? targetValue, string strategy, string compileId, HashSet< OptimizationParameter > parameters, IReadOnlyList< Constraint > constraints)
 Estimate optimization with the specified parameters via QuantConnect.com API More...
 
OptimizationSummary CreateOptimization (int projectId, string name, string target, string targetTo, decimal? targetValue, string strategy, string compileId, HashSet< OptimizationParameter > parameters, IReadOnlyList< Constraint > constraints, decimal estimatedCost, string nodeType, int parallelNodes)
 Create an optimization with the specified parameters via QuantConnect.com API More...
 
List< OptimizationSummaryListOptimizations (int projectId)
 List all the optimizations for a project More...
 
Optimization ReadOptimization (string optimizationId)
 Read an optimization More...
 
RestResponse AbortOptimization (string optimizationId)
 Abort an optimization More...
 
RestResponse UpdateOptimization (string optimizationId, string name=null)
 Update an optimization More...
 
RestResponse DeleteOptimization (string optimizationId)
 Delete an optimization More...
 
bool GetObjectStore (string organizationId, List< string > keys, string destinationFolder=null)
 Download the object store files associated with the given organization ID and key More...
 
PropertiesObjectStoreResponse GetObjectStoreProperties (string organizationId, string key)
 Get Object Store properties given the organization ID and the Object Store key More...
 
RestResponse SetObjectStore (string organizationId, string key, byte[] objectData)
 Upload files to the Object Store More...
 
RestResponse DeleteObjectStore (string organizationId, string key)
 Request to delete Object Store metadata of a specific organization and key More...
 
ListObjectStoreResponse ListObjectStore (string organizationId, string path)
 Request to list Object Store files of a specific organization and path More...
 

Static Public Member Functions

static string CreateSecureHash (int timestamp, string token)
 Generate a secure hash for the authorization headers. More...
 
static string FormatPathForDataRequest (string filePath, string dataFolder=null)
 Helper method to normalize path for api data requests More...
 

Public Attributes

bool Connected => ApiConnection.Connected
 Check if Api is successfully connected with correct credentials More...
 

Properties

JsonSerializerSettings SerializerSettings [get, set]
 Serializer settings to use More...
 
ApiConnection ApiConnection [get]
 Returns the underlying API connection More...
 

Detailed Description

QuantConnect.com Interaction Via API.

Definition at line 46 of file Api.cs.

Constructor & Destructor Documentation

◆ Api()

QuantConnect.Api.Api.Api ( )

Creates a new instance of Api

Definition at line 74 of file Api.cs.

Here is the caller graph for this function:

Member Function Documentation

◆ Initialize()

virtual void QuantConnect.Api.Api.Initialize ( int  userId,
string  token,
string  dataFolder 
)
virtual

Initialize the API with the given variables

Implements QuantConnect.Interfaces.IApi.

Definition at line 86 of file Api.cs.

◆ CreateProject()

ProjectResponse QuantConnect.Api.Api.CreateProject ( string  name,
Language  language,
string  organizationId = null 
)

Create a project with the specified name and language via QuantConnect.com API

Parameters
nameProject name
languageProgramming language to use
organizationIdOptional param for specifying organization to create project under. If none provided web defaults to preferred.
Returns
Project object from the API.

Implements QuantConnect.Interfaces.IApi.

Definition at line 112 of file Api.cs.

◆ ReadProject()

ProjectResponse QuantConnect.Api.Api.ReadProject ( int  projectId)

Get details about a single project

Parameters
projectIdId of the project
Returns
ProjectResponse that contains information regarding the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 151 of file Api.cs.

◆ ListProjects()

ProjectResponse QuantConnect.Api.Api.ListProjects ( )

List details of all projects

Returns
ProjectResponse that contains information regarding the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 172 of file Api.cs.

◆ AddProjectFile()

RestResponse QuantConnect.Api.Api.AddProjectFile ( int  projectId,
string  name,
string  content 
)

Add a file to a project

Parameters
projectIdThe project to which the file should be added
nameThe name of the new file
contentThe content of the new file
Returns
ProjectFilesResponse that includes information about the newly created file

Implements QuantConnect.Interfaces.IApi.

Definition at line 192 of file Api.cs.

◆ UpdateProjectFileName()

RestResponse QuantConnect.Api.Api.UpdateProjectFileName ( int  projectId,
string  oldFileName,
string  newFileName 
)

Update the name of a file

Parameters
projectIdProject id to which the file belongs
oldFileNameThe current name of the file
newFileNameThe new name for the file
Returns
RestResponse indicating success

Implements QuantConnect.Interfaces.IApi.

Definition at line 219 of file Api.cs.

◆ UpdateProjectFileContent()

RestResponse QuantConnect.Api.Api.UpdateProjectFileContent ( int  projectId,
string  fileName,
string  newFileContents 
)

Update the contents of a file

Parameters
projectIdProject id to which the file belongs
fileNameThe name of the file that should be updated
newFileContentsThe new contents of the file
Returns
RestResponse indicating success

Implements QuantConnect.Interfaces.IApi.

Definition at line 246 of file Api.cs.

◆ ReadProjectFiles()

ProjectFilesResponse QuantConnect.Api.Api.ReadProjectFiles ( int  projectId)

Read all files in a project

Parameters
projectIdProject id to which the file belongs
Returns
ProjectFilesResponse that includes the information about all files in the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 271 of file Api.cs.

◆ ReadProjectNodes()

ProjectNodesResponse QuantConnect.Api.Api.ReadProjectNodes ( int  projectId)

Read all nodes in a project.

Parameters
projectIdProject id to which the nodes refer
Returns
ProjectNodesResponse that includes the information about all nodes in the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 292 of file Api.cs.

◆ UpdateProjectNodes()

ProjectNodesResponse QuantConnect.Api.Api.UpdateProjectNodes ( int  projectId,
string[]  nodes 
)

Update the active state of some nodes to true. If you don't provide any nodes, all the nodes become inactive and AutoSelectNode is true.

Parameters
projectIdProject id to which the nodes refer
nodesList of node ids to update
Returns
ProjectNodesResponse that includes the information about all nodes in the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 315 of file Api.cs.

◆ ReadProjectFile()

ProjectFilesResponse QuantConnect.Api.Api.ReadProjectFile ( int  projectId,
string  fileName 
)

Read a file in a project

Parameters
projectIdProject id to which the file belongs
fileNameThe name of the file
Returns
ProjectFilesResponse that includes the file information

Implements QuantConnect.Interfaces.IApi.

Definition at line 339 of file Api.cs.

◆ ReadLeanVersions()

VersionsResponse QuantConnect.Api.Api.ReadLeanVersions ( )

Gets a list of LEAN versions with their corresponding basic descriptions

Implements QuantConnect.Interfaces.IApi.

Definition at line 359 of file Api.cs.

◆ DeleteProjectFile()

RestResponse QuantConnect.Api.Api.DeleteProjectFile ( int  projectId,
string  name 
)

Delete a file in a project

Parameters
projectIdProject id to which the file belongs
nameThe name of the file that should be deleted
Returns
RestResponse that includes the information about all files in the project

Implements QuantConnect.Interfaces.IApi.

Definition at line 377 of file Api.cs.

◆ DeleteProject()

RestResponse QuantConnect.Api.Api.DeleteProject ( int  projectId)

Delete a project

Parameters
projectIdProject id we own and wish to delete
Returns
RestResponse indicating success

Implements QuantConnect.Interfaces.IApi.

Definition at line 400 of file Api.cs.

◆ CreateCompile()

Compile QuantConnect.Api.Api.CreateCompile ( int  projectId)

Create a new compile job request for this project id.

Parameters
projectIdProject id we wish to compile.
Returns
Compile object result

Implements QuantConnect.Interfaces.IApi.

Definition at line 422 of file Api.cs.

◆ ReadCompile()

Compile QuantConnect.Api.Api.ReadCompile ( int  projectId,
string  compileId 
)

Read a compile packet job result.

Parameters
projectIdProject id we sent for compile
compileIdCompile id return from the creation request
Returns
Compile

Implements QuantConnect.Interfaces.IApi.

Definition at line 445 of file Api.cs.

◆ SendNotification()

virtual RestResponse QuantConnect.Api.Api.SendNotification ( Notification  notification,
int  projectId 
)
virtual

Sends a notification

Parameters
notificationThe notification to send
projectIdThe project id
Returns
RestResponse containing success response and errors

Implements QuantConnect.Interfaces.IApi.

Definition at line 468 of file Api.cs.

◆ CreateBacktest()

Backtest QuantConnect.Api.Api.CreateBacktest ( int  projectId,
string  compileId,
string  backtestName 
)

Create a new backtest request and get the id.

Parameters
projectIdId for the project to backtest
compileIdCompile id for the project
backtestNameName for the new backtest
Returns
Backtestt

Implements QuantConnect.Interfaces.IApi.

Definition at line 481 of file Api.cs.

◆ ReadBacktest()

Backtest QuantConnect.Api.Api.ReadBacktest ( int  projectId,
string  backtestId,
bool  getCharts = true 
)

Read out a backtest in the project id specified.

Parameters
projectIdProject id to read
backtestIdSpecific backtest id to read
getChartsTrue will return backtest charts
Returns
Backtest

Implements QuantConnect.Interfaces.IApi.

Definition at line 513 of file Api.cs.

◆ ReadBacktestOrders()

List<ApiOrderResponse> QuantConnect.Api.Api.ReadBacktestOrders ( int  projectId,
string  backtestId,
int  start = 0,
int  end = 100 
)

Returns the orders of the specified backtest and project id.

Parameters
projectIdId of the project from which to read the orders
backtestIdId of the backtest from which to read the orders
startStarting index of the orders to be fetched. Required if end > 100
endLast index of the orders to be fetched. Note that end - start must be less than 100

Will throw an WebException if there are any API errors

Returns
The list of Order

Definition at line 591 of file Api.cs.

◆ ReadBacktestChart()

ReadChartResponse QuantConnect.Api.Api.ReadBacktestChart ( int  projectId,
string  name,
int  start,
int  end,
uint  count,
string  backtestId 
)

Returns a requested chart object from a backtest

Parameters
projectIdProject ID of the request
nameThe requested chart name
startThe Utc start seconds timestamp of the request
endThe Utc end seconds timestamp of the request
countThe number of data points to request
backtestIdAssociated Backtest ID for this chart request
Returns
The chart

Implements QuantConnect.Interfaces.IApi.

Definition at line 619 of file Api.cs.

◆ UpdateBacktest()

RestResponse QuantConnect.Api.Api.UpdateBacktest ( int  projectId,
string  backtestId,
string  name = "",
string  note = "" 
)

Update a backtest name

Parameters
projectIdProject for the backtest we want to update
backtestIdBacktest id we want to update
nameName we'd like to assign to the backtest
noteNote attached to the backtest
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 658 of file Api.cs.

◆ ListBacktests()

BacktestSummaryList QuantConnect.Api.Api.ListBacktests ( int  projectId,
bool  includeStatistics = true 
)

List all the backtest summaries for a project

Parameters
projectIdProject id we'd like to get a list of backtest for
includeStatisticsTrue for include statistics in the response, false otherwise
Returns
BacktestList

Implements QuantConnect.Interfaces.IApi.

Definition at line 684 of file Api.cs.

◆ DeleteBacktest()

RestResponse QuantConnect.Api.Api.DeleteBacktest ( int  projectId,
string  backtestId 
)

Delete a backtest from the specified project and backtestId.

Parameters
projectIdProject for the backtest we want to delete
backtestIdBacktest id we want to delete
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 710 of file Api.cs.

◆ UpdateBacktestTags()

RestResponse QuantConnect.Api.Api.UpdateBacktestTags ( int  projectId,
string  backtestId,
IReadOnlyCollection< string >  tags 
)

Updates the tags collection for a backtest

Parameters
projectIdProject for the backtest we want to update
backtestIdBacktest id we want to update
tagsThe new backtest tags
Returns
RestResponse

Definition at line 734 of file Api.cs.

◆ ReadBacktestInsights()

InsightResponse QuantConnect.Api.Api.ReadBacktestInsights ( int  projectId,
string  backtestId,
int  start = 0,
int  end = 0 
)

Read out the insights of a backtest

Parameters
projectIdId of the project from which to read the backtest
backtestIdBacktest id from which we want to get the insights
startStarting index of the insights to be fetched
endLast index of the insights to be fetched. Note that end - start must be less than 100
Returns
InsightResponse
Exceptions
ArgumentException

Implements QuantConnect.Interfaces.IApi.

Definition at line 761 of file Api.cs.

◆ CreateLiveAlgorithm() [1/2]

CreateLiveAlgorithmResponse QuantConnect.Api.Api.CreateLiveAlgorithm ( int  projectId,
string  compileId,
string  nodeId,
Dictionary< string, object >  brokerageSettings,
string  versionId = "-1",
Dictionary< string, object >  dataProviders = null 
)

Create a live algorithm.

Parameters
projectIdId of the project on QuantConnect
compileIdId of the compilation on QuantConnect
nodeIdId of the node that will run the algorithm
brokerageSettingsDictionary with brokerage specific settings. Each brokerage requires certain specific credentials in order to process the given orders. Each key in this dictionary represents a required field/credential to provide to the brokerage API and its value represents the value of that field. For example: "brokerageSettings: { "id": "Binance", "binance-api-secret": "123ABC", "binance-api-key": "ABC123"}. It is worth saying, that this dictionary must always contain an entry whose key is "id" and its value is the name of the brokerage (see <see cref="Brokerages.BrokerageName"/>)</param> <param name="versionId">The version of the Lean used to run the algorithm. -1 is master, however, sometimes this can create problems with live deployments. If you experience problems using, try specifying the version of Lean you would like to use.
dataProvidersDictionary with data providers credentials. Each data provider requires certain credentials in order to retrieve data from their API. Each key in this dictionary describes a data provider name and its corresponding value is another dictionary with the required key-value pairs of credential names and values. For example: "dataProviders: { "InteractiveBrokersBrokerage" : { "id": 12345, "environment" : "paper", "username": "testUsername", "password": "testPassword"}}"
Returns
Information regarding the new algorithm CreateLiveAlgorithmResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 813 of file Api.cs.

Here is the caller graph for this function:

◆ CreateLiveAlgorithm() [2/2]

CreateLiveAlgorithmResponse QuantConnect.Api.Api.CreateLiveAlgorithm ( int  projectId,
string  compileId,
string  nodeId,
PyObject  brokerageSettings,
string  versionId = "-1",
PyObject  dataProviders = null 
)

Create a live algorithm.

Parameters
projectIdId of the project on QuantConnect
compileIdId of the compilation on QuantConnect
nodeIdId of the node that will run the algorithm
brokerageSettingsPython Dictionary with brokerage specific settings. Each brokerage requires certain specific credentials in order to process the given orders. Each key in this dictionary represents a required field/credential to provide to the brokerage API and its value represents the value of that field. For example: "brokerageSettings: { "id": "Binance", "binance-api-secret": "123ABC", "binance-api-key": "ABC123"}. It is worth saying, that this dictionary must always contain an entry whose key is "id" and its value is the name of the brokerage (see <see cref="Brokerages.BrokerageName"/>)</param> <param name="versionId">The version of the Lean used to run the algorithm. -1 is master, however, sometimes this can create problems with live deployments. If you experience problems using, try specifying the version of Lean you would like to use.
dataProvidersPython Dictionary with data providers credentials. Each data provider requires certain credentials in order to retrieve data from their API. Each key in this dictionary describes a data provider name and its corresponding value is another dictionary with the required key-value pairs of credential names and values. For example: "dataProviders: { "InteractiveBrokersBrokerage" : { "id": 12345, "environment" : "paper", "username": "testUsername", "password": "testPassword"}}"
Returns
Information regarding the new algorithm CreateLiveAlgorithmResponse

Definition at line 862 of file Api.cs.

Here is the call graph for this function:

◆ ListLiveAlgorithms()

LiveList QuantConnect.Api.Api.ListLiveAlgorithms ( AlgorithmStatus status = null,
DateTime?  startTime = null,
DateTime?  endTime = null 
)

Get a list of live running algorithms for user

Parameters
statusFilter the statuses of the algorithms returned from the api
startTimeEarliest launched time of the algorithms returned by the Api
endTimeLatest launched time of the algorithms returned by the Api
Returns
LiveList

Implements QuantConnect.Interfaces.IApi.

Definition at line 888 of file Api.cs.

Here is the call graph for this function:

◆ ReadLiveAlgorithm()

LiveAlgorithmResults QuantConnect.Api.Api.ReadLiveAlgorithm ( int  projectId,
string  deployId 
)

Read out a live algorithm in the project id specified.

Parameters
projectIdProject id to read
deployIdSpecific instance id to read
Returns
LiveAlgorithmResults

Implements QuantConnect.Interfaces.IApi.

Definition at line 935 of file Api.cs.

◆ ReadLivePortfolio()

PortfolioResponse QuantConnect.Api.Api.ReadLivePortfolio ( int  projectId)

Read out the portfolio state of a live algorithm

Parameters
projectIdId of the project from which to read the live algorithm
Returns
PortfolioResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 957 of file Api.cs.

◆ ReadLiveOrders()

List<ApiOrderResponse> QuantConnect.Api.Api.ReadLiveOrders ( int  projectId,
int  start = 0,
int  end = 100 
)

Returns the orders of the specified project id live algorithm.

Parameters
projectIdId of the project from which to read the live orders
startStarting index of the orders to be fetched. Required if end > 100
endLast index of the orders to be fetched. Note that end - start must be less than 100

Will throw an WebException if there are any API errors

Returns
The list of Order

Definition at line 982 of file Api.cs.

◆ LiquidateLiveAlgorithm()

RestResponse QuantConnect.Api.Api.LiquidateLiveAlgorithm ( int  projectId)

Liquidate a live algorithm from the specified project and deployId.

Parameters
projectIdProject for the live instance we want to stop
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1005 of file Api.cs.

◆ StopLiveAlgorithm()

RestResponse QuantConnect.Api.Api.StopLiveAlgorithm ( int  projectId)

Stop a live algorithm from the specified project and deployId.

Parameters
projectIdProject for the live instance we want to stop
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1026 of file Api.cs.

◆ CreateLiveCommand()

RestResponse QuantConnect.Api.Api.CreateLiveCommand ( int  projectId,
object  command 
)

Create a live command

Parameters
projectIdProject for the live instance we want to run the command against
commandThe command to run
Returns
RestResponse

Definition at line 1048 of file Api.cs.

◆ ReadLiveLogs()

LiveLog QuantConnect.Api.Api.ReadLiveLogs ( int  projectId,
string  algorithmId,
int  startLine,
int  endLine 
)

Gets the logs of a specific live algorithm

Parameters
projectIdProject Id of the live running algorithm
algorithmIdAlgorithm Id of the live running algorithm
startLineStart line of logs to read
endLineEnd line of logs to read
Returns
LiveLog List of strings that represent the logs of the algorithm

Implements QuantConnect.Interfaces.IApi.

Definition at line 1073 of file Api.cs.

◆ ReadLiveChart()

ReadChartResponse QuantConnect.Api.Api.ReadLiveChart ( int  projectId,
string  name,
int  start,
int  end,
uint  count 
)

Returns a chart object from a live algorithm

Parameters
projectIdProject ID of the request
nameThe requested chart name
startThe Utc start seconds timestamp of the request
endThe Utc end seconds timestamp of the request
countThe number of data points to request
Returns
The chart

Implements QuantConnect.Interfaces.IApi.

Definition at line 1108 of file Api.cs.

◆ ReadLiveInsights()

InsightResponse QuantConnect.Api.Api.ReadLiveInsights ( int  projectId,
int  start = 0,
int  end = 0 
)

Read out the insights of a live algorithm

Parameters
projectIdId of the project from which to read the live algorithm
startStarting index of the insights to be fetched
endLast index of the insights to be fetched. Note that end - start must be less than 100
Returns
InsightResponse
Exceptions
ArgumentException

Implements QuantConnect.Interfaces.IApi.

Definition at line 1144 of file Api.cs.

◆ ReadDataLink()

DataLink QuantConnect.Api.Api.ReadDataLink ( string  filePath,
string  organizationId 
)

Gets the link to the downloadable data.

Parameters
filePathFile path representing the data requested
organizationIdOrganization to download from
Returns
DataLink to the downloadable data.

Implements QuantConnect.Interfaces.IApi.

Definition at line 1180 of file Api.cs.

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

◆ ReadDataDirectory()

DataList QuantConnect.Api.Api.ReadDataDirectory ( string  filePath)

Get valid data entries for a given filepath from data/list

Returns

Implements QuantConnect.Interfaces.IApi.

Definition at line 1210 of file Api.cs.

Here is the call graph for this function:

◆ ReadDataPrices()

DataPricesList QuantConnect.Api.Api.ReadDataPrices ( string  organizationId)

Gets data prices from data/prices

Implements QuantConnect.Interfaces.IApi.

Definition at line 1245 of file Api.cs.

◆ ReadBacktestReport()

BacktestReport QuantConnect.Api.Api.ReadBacktestReport ( int  projectId,
string  backtestId 
)

Read out the report of a backtest in the project id specified.

Parameters
projectIdProject id to read
backtestIdSpecific backtest id to read
Returns
BacktestReport

Implements QuantConnect.Interfaces.IApi.

Definition at line 1267 of file Api.cs.

◆ DownloadData()

bool QuantConnect.Api.Api.DownloadData ( string  filePath,
string  organizationId 
)

Method to purchase and download data from QuantConnect

Parameters
filePathFile path representing the data requested
organizationIdOrganization to buy the data with
Returns
A bool indicating whether the data was successfully downloaded or not.

Implements QuantConnect.Interfaces.IApi.

Definition at line 1297 of file Api.cs.

Here is the call graph for this function:

◆ GetAlgorithmStatus()

virtual AlgorithmControl QuantConnect.Api.Api.GetAlgorithmStatus ( string  algorithmId)
virtual

Get the algorithm status from the user with this algorithm id.

Parameters
algorithmIdString algorithm id we're searching for.
Returns
Algorithm status enum

Implements QuantConnect.Interfaces.IApi.

Definition at line 1346 of file Api.cs.

◆ SetAlgorithmStatus()

virtual void QuantConnect.Api.Api.SetAlgorithmStatus ( string  algorithmId,
AlgorithmStatus  status,
string  message = "" 
)
virtual

Algorithm passes back its current status to the UX.

Parameters
statusStatus of the current algorithm
algorithmIdString algorithm id we're setting.
messageMessage for the algorithm status event
Returns
Algorithm status enum

Implements QuantConnect.Interfaces.IApi.

Definition at line 1362 of file Api.cs.

◆ SendStatistics()

virtual void QuantConnect.Api.Api.SendStatistics ( string  algorithmId,
decimal  unrealized,
decimal  fees,
decimal  netProfit,
decimal  holdings,
decimal  equity,
decimal  netReturn,
decimal  volume,
int  trades,
double  sharpe 
)
virtual

Send the statistics to storage for performance tracking.

Parameters
algorithmIdIdentifier for algorithm
unrealizedUnrealized gainloss
feesTotal fees
netProfitNet profi
holdingsAlgorithm holdings
equityTotal equity
netReturnNet return for the deployment
volumeVolume traded
tradesTotal trades since inception
sharpeSharpe ratio since inception

Implements QuantConnect.Interfaces.IApi.

Definition at line 1381 of file Api.cs.

◆ SendUserEmail()

virtual void QuantConnect.Api.Api.SendUserEmail ( string  algorithmId,
string  subject,
string  body 
)
virtual

Send an email to the user associated with the specified algorithm id

Parameters
algorithmIdThe algorithm id
subjectThe email subject
bodyThe email message body

Implements QuantConnect.Interfaces.IApi.

Definition at line 1393 of file Api.cs.

◆ Download()

virtual string QuantConnect.Api.Api.Download ( string  address,
IEnumerable< KeyValuePair< string, string >>  headers,
string  userName,
string  password 
)
virtual

Local implementation for downloading data to algorithms

Parameters
addressURL to download
headersKVP headers
userNameUsername for basic authentication
passwordPassword for basic authentication
Returns

Implements QuantConnect.Interfaces.IApi.

Definition at line 1406 of file Api.cs.

Here is the call graph for this function:

◆ DownloadBytes()

virtual byte [] QuantConnect.Api.Api.DownloadBytes ( string  address,
IEnumerable< KeyValuePair< string, string >>  headers,
string  userName,
string  password 
)
virtual

Local implementation for downloading data to algorithms

Parameters
addressURL to download
headersKVP headers
userNameUsername for basic authentication
passwordPassword for basic authentication
Returns
A stream from which the data can be read

Stream.Close() most be called to avoid running out of resources

Implements QuantConnect.Interfaces.IApi.

Definition at line 1420 of file Api.cs.

Here is the caller graph for this function:

◆ Dispose()

virtual void QuantConnect.Api.Api.Dispose ( )
virtual

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

<filterpriority>2</filterpriority>

Definition at line 1467 of file Api.cs.

◆ CreateSecureHash()

static string QuantConnect.Api.Api.CreateSecureHash ( int  timestamp,
string  token 
)
static

Generate a secure hash for the authorization headers.

Returns
Time based hash of user token and timestamp.

Definition at line 1485 of file Api.cs.

◆ ReadAccount()

Account QuantConnect.Api.Api.ReadAccount ( string  organizationId = null)

Will read the organization account status

Parameters
organizationIdThe target organization id, if null will return default organization

Implements QuantConnect.Interfaces.IApi.

Definition at line 1497 of file Api.cs.

◆ ReadOrganization()

Organization QuantConnect.Api.Api.ReadOrganization ( string  organizationId = null)

Fetch organization data from web API

Parameters
organizationId
Returns

Implements QuantConnect.Interfaces.IApi.

Definition at line 1518 of file Api.cs.

◆ EstimateOptimization()

Estimate QuantConnect.Api.Api.EstimateOptimization ( int  projectId,
string  name,
string  target,
string  targetTo,
decimal?  targetValue,
string  strategy,
string  compileId,
HashSet< OptimizationParameter parameters,
IReadOnlyList< Constraint constraints 
)

Estimate optimization with the specified parameters via QuantConnect.com API

Parameters
projectIdProject ID of the project the optimization belongs to
nameName of the optimization
targetTarget of the optimization, see examples in PortfolioStatistics
targetToTarget extremum of the optimization, for example "max" or "min"
targetValueOptimization target value
strategyOptimization strategy, QuantConnect.Optimizer.Strategies.GridSearchOptimizationStrategy
compileIdOptimization compile ID
parametersOptimization parameters
constraintsOptimization constraints
Returns
Estimate object from the API.

Implements QuantConnect.Interfaces.IApi.

Definition at line 1547 of file Api.cs.

◆ CreateOptimization()

OptimizationSummary QuantConnect.Api.Api.CreateOptimization ( int  projectId,
string  name,
string  target,
string  targetTo,
decimal?  targetValue,
string  strategy,
string  compileId,
HashSet< OptimizationParameter parameters,
IReadOnlyList< Constraint constraints,
decimal  estimatedCost,
string  nodeType,
int  parallelNodes 
)

Create an optimization with the specified parameters via QuantConnect.com API

Parameters
projectIdProject ID of the project the optimization belongs to
nameName of the optimization
targetTarget of the optimization, see examples in PortfolioStatistics
targetToTarget extremum of the optimization, for example "max" or "min"
targetValueOptimization target value
strategyOptimization strategy, QuantConnect.Optimizer.Strategies.GridSearchOptimizationStrategy
compileIdOptimization compile ID
parametersOptimization parameters
constraintsOptimization constraints
estimatedCostEstimated cost for optimization
nodeTypeOptimization node type OptimizationNodes
parallelNodesNumber of parallel nodes for optimization
Returns
BaseOptimization object from the API.

Implements QuantConnect.Interfaces.IApi.

Definition at line 1596 of file Api.cs.

◆ ListOptimizations()

List<OptimizationSummary> QuantConnect.Api.Api.ListOptimizations ( int  projectId)

List all the optimizations for a project

Parameters
projectIdProject id we'd like to get a list of optimizations for
Returns
A list of BaseOptimization objects, BaseOptimization

Implements QuantConnect.Interfaces.IApi.

Definition at line 1640 of file Api.cs.

◆ ReadOptimization()

Optimization QuantConnect.Api.Api.ReadOptimization ( string  optimizationId)

Read an optimization

Parameters
optimizationIdOptimization id for the optimization we want to read
Returns
Optimization

Implements QuantConnect.Interfaces.IApi.

Definition at line 1661 of file Api.cs.

◆ AbortOptimization()

RestResponse QuantConnect.Api.Api.AbortOptimization ( string  optimizationId)

Abort an optimization

Parameters
optimizationIdOptimization id for the optimization we want to abort
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1682 of file Api.cs.

◆ UpdateOptimization()

RestResponse QuantConnect.Api.Api.UpdateOptimization ( string  optimizationId,
string  name = null 
)

Update an optimization

Parameters
optimizationIdOptimization id we want to update
nameName we'd like to assign to the optimization
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1704 of file Api.cs.

◆ DeleteOptimization()

RestResponse QuantConnect.Api.Api.DeleteOptimization ( string  optimizationId)

Delete an optimization

Parameters
optimizationIdOptimization id for the optimization we want to delete
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1732 of file Api.cs.

◆ GetObjectStore()

bool QuantConnect.Api.Api.GetObjectStore ( string  organizationId,
List< string >  keys,
string  destinationFolder = null 
)

Download the object store files associated with the given organization ID and key

Parameters
organizationIdOrganization ID we would like to get the Object Store files from
keysKeys for the Object Store files
destinationFolderFolder in which the object store files will be stored
Returns
True if the object store files were retrieved correctly, false otherwise

Implements QuantConnect.Interfaces.IApi.

Definition at line 1755 of file Api.cs.

Here is the call graph for this function:

◆ GetObjectStoreProperties()

PropertiesObjectStoreResponse QuantConnect.Api.Api.GetObjectStoreProperties ( string  organizationId,
string  key 
)

Get Object Store properties given the organization ID and the Object Store key

Parameters
organizationIdOrganization ID we would like to get the Object Store from
keyKey for the Object Store file
Returns
PropertiesObjectStoreResponse

It does not work when the object store is a directory

Implements QuantConnect.Interfaces.IApi.

Definition at line 1838 of file Api.cs.

Here is the call graph for this function:

◆ SetObjectStore()

RestResponse QuantConnect.Api.Api.SetObjectStore ( string  organizationId,
string  key,
byte[]  objectData 
)

Upload files to the Object Store

Parameters
organizationIdOrganization ID we would like to upload the file to
keyKey to the Object Store file
objectDataFile (as an array of bytes) to be uploaded
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1864 of file Api.cs.

◆ DeleteObjectStore()

RestResponse QuantConnect.Api.Api.DeleteObjectStore ( string  organizationId,
string  key 
)

Request to delete Object Store metadata of a specific organization and key

Parameters
organizationIdOrganization ID we would like to delete the Object Store file from
keyKey to the Object Store file
Returns
RestResponse

Implements QuantConnect.Interfaces.IApi.

Definition at line 1886 of file Api.cs.

◆ ListObjectStore()

ListObjectStoreResponse QuantConnect.Api.Api.ListObjectStore ( string  organizationId,
string  path 
)

Request to list Object Store files of a specific organization and path

Parameters
organizationIdOrganization ID we would like to list the Object Store files from
pathPath to the Object Store files
Returns
ListObjectStoreResponse

Definition at line 1911 of file Api.cs.

◆ FormatPathForDataRequest()

static string QuantConnect.Api.Api.FormatPathForDataRequest ( string  filePath,
string  dataFolder = null 
)
static

Helper method to normalize path for api data requests

Parameters
filePathFilepath to format
dataFolderThe data folder to use
Returns
Normalized path

Definition at line 1936 of file Api.cs.

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

Member Data Documentation

◆ Connected

bool QuantConnect.Api.Api.Connected => ApiConnection.Connected

Check if Api is successfully connected with correct credentials

Definition at line 101 of file Api.cs.

Property Documentation

◆ SerializerSettings

JsonSerializerSettings QuantConnect.Api.Api.SerializerSettings
getsetprotected
Initial value:
= new()
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessDictionaryKeys = false,
OverrideSpecifiedNames = true
}
}
}

Serializer settings to use

Definition at line 54 of file Api.cs.

◆ ApiConnection

ApiConnection QuantConnect.Api.Api.ApiConnection
getprotected

Returns the underlying API connection

Definition at line 69 of file Api.cs.


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