lean-cli icon indicating copy to clipboard operation
lean-cli copied to clipboard

Lean CLI not using sandbox server for tradier paper trading account

Open wlami opened this issue 1 year ago • 2 comments

Expected Behavior

The cli parameter --tradier-environment paper should let lean access the paper trading environment at sandbox.tradier.com.

Actual Behavior

The log file shows the live endpoint and the application shuts down:

20240528 19:56:34.659 TRACE:: WebSocketClientWrapper connection task ended: wss://ws.tradier.com/v1/markets/events
20240528 19:56:34.660 TRACE:: WebSocketClientWrapper.OnClose(): Connection closed (IsOpen:False, State:Aborted): wss://ws.tradier.com/v1/markets/events

Potential Solution

I checked my lean.json and there is only an "live-tradier" environment, but no "paper-tradier" one. Maybe I am missing some config?

Reproducing the Problem

  1. Setup tradier paper trading account
  2. Start lean cli using the command given below

System Information

Register for tradier account, setup a paper trading account at and start lean live:

lean live deploy --brokerage Tradier \
    --data-provider-live Tradier \
    --tradier-account-id "xxxx" --tradier-access-token "xxxx" \
    --tradier-environment paper \
    ${projectname}

Checklist

  • [x] I have completely filled out this template
  • [ ] I have confirmed that this issue exists on the current master branch (No, could make the dotnet build work in my ubuntu environment)
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

wlami avatar May 28 '24 20:05 wlami

Hey @wlami! Tradier does not support data streaming in the paper/sandbox environment, this is probably causing the issue ur experiencing. Will keep this issue open so we update the lean CLI not to allow this invalid configuration setup.

Martin-Molinero avatar May 29 '24 19:05 Martin-Molinero

Hey @Martin-Molinero, thanks for the explanation. Could you help me understand what --tradier-environment paper then is meant to do? Does it only work with other data providers?

wlami avatar May 30 '24 16:05 wlami

Tradier brokerage internally is already not allowing paper trading being used as a data provider see https://github.com/QuantConnect/Lean.Brokerages.Tradier/blob/master/QuantConnect.TradierBrokerage/TradierBrokerage.DataQueueHandler.cs#L89.

update the lean CLI not to allow this invalid configuration

Lean cli currently can not enforce this, will skip for now, until further requirements

Martin-Molinero avatar Aug 15 '24 19:08 Martin-Molinero