Back

Lean: Live Data Setup

Hello, I'm going to post a quick question and will edit to add more specifics in a minute:

What is the cheapest option for getting started with live data using Lean? And how do I set this up?

I've run backtesting on QC web and on Lean with Windows. I'm now on a linux box (and don't have IB TWS installed) and am deploying to a Google Cloud Platform instance. I used the Container OS with Docker and pulled the Lean Foundation image from Docker Hub (using docker pull quantconnect/lean:foundation). Have it installed with commmands from (github.com/QuantConnect/Lean/blob/master/Dockerfile) running the basic Python algo and set my config to 'paper-trading'. Current error is regarding data function.

I don't mind using IB delayed data, but when I tried that before it was just being implemented and wasn't working. It would be good to have that as an option anyway. I'm currently attempting the IB setup, but remember having to set options in an installed gui app that would be good to be able to avoid when deploying with Docker. (Speaking of, what is the difference between the Foundation and much older Foundation-live images?)

Are any of the newer APIs from Alpaca (or even TDA Ameritrade) free and sane to setup? I see config.json settings for Alpaca and read it uses IEX data, but don't know if there is an account minimum for free data like with IB. Thank you!!

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


A quick update, it looks like Alpaca data is what I'm looking for. Just waiting for ID verification for the API to work. Tried both paper and live, with error: No connection to server, by data function.

0

I talked to a rep who said the paper API keys should be working, but I'm still getting the error below. Any help appreciated. I'm going to test the API on another service.

ERROR:: Algorithm.Initialize() Error: Unable to connect to a server. Stack Trace: NATS.Client.NATSNoServersException: Unable to connect to a
server.
at NATS.Client.Connection.connect () [0x00063] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at NATS.Client.ConnectionFactory.CreateConnection (NATS.Client.Options opts) [0x00016] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at QuantConnect.Brokerages.Alpaca.Markets.NatsClient.Open () [0x00006] in <96df0ce48d5a474caeca6d3c59b26a57>:0
at QuantConnect.Brokerages.Alpaca.AlpacaBrokerage.Connect () [0x0002e] in <96df0ce48d5a474caeca6d3c59b26a57>:0
at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize (QuantConnect.Data.HistoryProviderInitializeParameters parameters) [0x00000] in <d
3dede4f0689492380f43dee850652af>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPa
th, QuantConnect.Util.WorkerThread workerThread) [0x00437] in <d3dede4f0689492380f43dee850652af>:0
NATS.Client.NATSNoServersException: Unable to connect to a server.
at NATS.Client.Connection.connect () [0x00063] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at NATS.Client.ConnectionFactory.CreateConnection (NATS.Client.Options opts) [0x00016] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at QuantConnect.Brokerages.Alpaca.Markets.NatsClient.Open () [0x00006] in <96df0ce48d5a474caeca6d3c59b26a57>:0
at QuantConnect.Brokerages.Alpaca.AlpacaBrokerage.Connect () [0x0002e] in <96df0ce48d5a474caeca6d3c59b26a57>:0
at QuantConnect.Lean.Engine.HistoricalData.BrokerageHistoryProvider.Initialize (QuantConnect.Data.HistoryProviderInitializeParameters parameters) [0x00000] in <d
3dede4f0689492380f43dee850652af>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPa
th, QuantConnect.Util.WorkerThread workerThread) [0x00437] in <d3dede4f0689492380f43dee850652af>:0

 

0

Just tested the Alpaca API with paper ID and key on Apitester.com and not working (404 response). Sent a message to support. Below is the link that says the paper data is the same as live and doesn't require a brokerage account. And another article about the Alpaca NBBO specifics vs QC. Following the Alpaca testing guide for Postman.

https://www.reddit.com/r/algotrading/comments/a32rwf/alpaca_paper_trading_api_is_out_for_anyone/
https://medium.com/automation-generation/quantopian-vs-alpaca-when-paper-trading-your-algorithms-d6b17ad6f49
https://forum.alpaca.markets/t/manually-trading-stocks-using-postman-and-the-alpaca-api/166

 

0

Alright, so the paper data API is working on ApiTester and WrapApi, the basic example needed to be a GET request actually. Must be in the QC Lean code. Any help is appreciated.

0

here is the error more consisely:

ERROR:: Engine.Run(): NATS.Client.NATSNoServersException: Unable to connect to a server.
at NATS.Client.Connection.connect () [0x00063] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at NATS.Client.ConnectionFactory.CreateConnection (NATS.Client.Options opts) [0x00016] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0
at QuantConnect.Brokerages.Alpaca.Markets.NatsClient.Open () [0x00006] in <96df0ce48d5a474caeca6d3c59b26a57>:0

gosh, the formatting on this forum is challenging.. it is registering tabs when I'm pressing space to replace the inconsistent whitespace below. So I used underscores instead for readability:

  • ERROR:: Engine.Run():  NATS.Client.NATSNoServersException: Unable to connect to a server.
  • at NATS.Client.Connection.connect () [0x00063] in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0 
  • at_NATS.Client.ConnectionFactory.CreateConnection_(NATS.Client.Options_opts)_[0x00016]_in <e4e5f1e1c6b343ca8a8a4ce61a60596d>:0 
  • at_QuantConnect.Brokerages.Alpaca.Markets.NatsClient.Open_()_[0x00006]_in <96df0ce48d5a474caeca6d3c59b26a57>:0 
0

Jared Broad   Looks like you have a problem with code injection for javascript. Engine.Run() text is being typecast as code. Hope that @ to you registered. Also would be great if the screen remembered the comment position on refresh so I don't have to scoll back down every time #firstworldproblems...  

Oh, I see. Nevermind, it thinks it is an html address.

0

This is an open issue being actively worked on, please see more here. 

https://github.com/QuantConnect/Lean/issues/4111

 

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed