Lean  $LEAN_TAG$
QuantConnect.Api.Api Class Reference

QuantConnect.com Interaction Via API. More...

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

Public Member Functions

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...
 
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...
 
LiveAlgorithm CreateLiveAlgorithm (int projectId, string compileId, string nodeId, Dictionary< string, object > brokerageSettings, string versionId="-1", Dictionary< string, object > dataProviders=null)
 Create a live algorithm. More...
 
LiveAlgorithm 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...
 
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...
 
LiveLog ReadLiveLogs (int projectId, string algorithmId, DateTime? startTime=null, DateTime? endTime=null)
 Gets the logs of a specific 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 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...
 
List< OrganizationListOrganizations ()
 Get a list of organizations tied to this account 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...
 
BaseOptimization 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< BaseOptimizationListOptimizations (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

ApiConnection ApiConnection [get]
 Returns the underlying API connection More...
 

Detailed Description

QuantConnect.com Interaction Via API.

Definition at line 42 of file Api.cs.

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 55 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 81 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 120 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 141 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 161 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 188 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 215 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 240 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 261 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 284 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 308 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 328 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 346 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 369 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 391 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 414 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 437 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 450 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 482 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 560 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 587 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 613 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 639 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 663 of file Api.cs.

◆ CreateLiveAlgorithm() [1/2]

LiveAlgorithm 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 LiveAlgorithm

Implements QuantConnect.Interfaces.IApi.

Definition at line 702 of file Api.cs.

Here is the caller graph for this function:

◆ CreateLiveAlgorithm() [2/2]

LiveAlgorithm 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 LiveAlgorithm

Definition at line 752 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 778 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 825 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 851 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 874 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 896 of file Api.cs.

◆ ReadLiveLogs()

LiveLog QuantConnect.Api.Api.ReadLiveLogs ( int  projectId,
string  algorithmId,
DateTime?  startTime = null,
DateTime?  endTime = null 
)

Gets the logs of a specific live algorithm

Parameters
projectIdProject Id of the live running algorithm
algorithmIdAlgorithm Id of the live running algorithm
startTimeNo logs will be returned before this time
endTimeNo logs will be returned after this time
Returns
LiveLog List of strings that represent the logs of the algorithm

Implements QuantConnect.Interfaces.IApi.

Definition at line 921 of file Api.cs.

Here is the call graph for this function:

◆ 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
Link to the downloadable data.

Implements QuantConnect.Interfaces.IApi.

Definition at line 950 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 980 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 1015 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 1037 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 1061 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 1105 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 1121 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 1140 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 1152 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 1165 of file Api.cs.

◆ 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 1201 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 1213 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 1225 of file Api.cs.

◆ ListOrganizations()

List<Organization> QuantConnect.Api.Api.ListOrganizations ( )

Get a list of organizations tied to this account

Returns

Implements QuantConnect.Interfaces.IApi.

Definition at line 1245 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 1261 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, GridSearchOptimizationStrategy
compileIdOptimization compile ID
parametersOptimization parameters
constraintsOptimization constraints
Returns
Estimate object from the API.

Implements QuantConnect.Interfaces.IApi.

Definition at line 1290 of file Api.cs.

◆ CreateOptimization()

BaseOptimization 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, 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 1339 of file Api.cs.

◆ ListOptimizations()

List<BaseOptimization> 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 1383 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 1404 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 1425 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 1447 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 1475 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 1498 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 1576 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 1602 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 1624 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 1649 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 1674 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 70 of file Api.cs.

Property Documentation

◆ ApiConnection

ApiConnection QuantConnect.Api.Api.ApiConnection
getprotected

Returns the underlying API connection

Definition at line 50 of file Api.cs.


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