Create Live Algorithms

Bitfinex

Introduction

This page explains how to use the QuantConnect API to deploy live algorithms that connect to the Bitfinex brokerage.

Prerequisites

Working knowledge of C#.

Working knowledge of Python and pandas. If you are not familiar with pandas, refer to the pandas documentation.

Compile Projects

To compile a project, call the CreateCompile method with the project ID.

#load "../Initialize.csx"
#load "../QuantConnect.csx"

using QuantConnect;
using QuantConnect.Api;

var compile = api.CreateCompile(projectID);
compile = api.CreateCompile(project_id)

The CreateCompile method returns a Compile object, which have the following attributes:

Select a Node

You need to select a node to deploy a live algorithm. To view the live trading nodes in your organization, call the ReadNodes method with your organization ID.

var nodes = api.ReadNodes(organizationId);
nodes = api.ReadNodes(organization_id)

The ReadNodes method returns a NodeList object, which have the following attributes:

To select the first available live trading node in your organization, run:

var nodeId = nodes.LiveNodes.Where(x => x.Busy == false).FirstOrDefault().Id;
node_id = [x for x in nodes.LiveNodes if not x.Busy][0].Id

Define Algorithm Settings

To use the Bitfinex brokerage, create a BitfinexLiveAlgorithmSettings object.

var liveSettings = new BitfinexLiveAlgorithmSettings(key: "", secret: "");
live_settings = BitfinexLiveAlgorithmSettings(key="", secret="")

To generate your API credentials, see Account Types. Your account details are not saved on QuantConnect.

Deploy Algorithms

You need to compile the project, select a node, and define the algorithm settings before you can deploy live algorithms.

To deploy live algorithms, call the CreateLiveAlgorithm method.

var liveAlgorithm = api.CreateLiveAlgorithm(projectId, compile.CompileId, nodeId, liveSettings);
new_live_algorithm = api.CreateLiveAlgorithm(project_id, compile.CompileId, node_id, live_settings)

By default, LEAN uses the latest master branch. If the latest master branch causes issues with your live deployment, pass a LEAN version to the CreateLiveAlgorithm method.

var liveAlgorithm = api.CreateLiveAlgorithm(projectId, compile.CompileId, nodeId, liveSettings, versionId);
new_live_algorithm = api.CreateLiveAlgorithm(project_id, compile.CompileId, node_id, live_settings, version_id)

The CreateLiveAlgorithm method returns a LiveAlgorithm object, which have the following attributes:

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: