QuantConnect / lean-cli

CLI for running the LEAN engine locally and in the cloud
https://www.lean.io/cli
Apache License 2.0
202 stars 102 forks source link

Does it work on macos? #9

Closed Colin123 closed 3 years ago

Colin123 commented 3 years ago

Does it work on a mac? I set up an example like in this tutorial: https://www.youtube.com/watch?v=yAVjsFdtpEY but I ended up with an error like this:

20210527 10:31:21.764 ERROR:: Failed to assign conversion rates for the following cash: EUR. Attempting to request daily resolution history to resolve conversion rate 2021-05-27T09:27:12.7093632Z ERROR:: AUSUSD 0 not found in portfolio. Request this data when initializing the algorithm.

So I also downloaded EURUSD, still no joy. My example was first written/run in the QC cloud, so it wasn't a coding issue I think.

Then I made another example using SPY and the default EMA cross from the QC builder I ended up with this error when run locally: 20210527 09:50:47.300 ERROR:: SPY: The security does not have an accurate price as it has not yet received a bar of data. Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup

It seems it doesn't run the same locally as the cloud, at least on a mac

jmerle commented 3 years ago

Yes, the CLI has been tested and should work on macOS (both with Intel and Apple chips).

20210527 10:31:21.764 ERROR:: Failed to assign conversion rates for the following cash: EUR. Attempting to request daily resolution history to resolve conversion rate So I also downloaded EURUSD, still no joy.

The logic in regards to that error is as follows:

  1. LEAN tries to use history data to calculate the initial conversion rate from EUR to account currency (presumably USD). If you subscribe to minute data for EURUSD in Initialize, it will first attempt to get minute history of the last 10 minutes to calculate the conversion rate.
  2. If 1 fails because the requested data is not available, the error you see is logged and LEAN attempts to request daily history of the last 10 days to calculate the conversion rate instead.
  3. If 2 fails too, the conversion rate is set to 0 until there is EURUSD data to calculate the conversion rate with.
  4. Regardless of the results of steps 1 through 3, the state of the cashbook including all initial conversion rates is logged after attempting to calculate the initial rates. This message looks something like this: image

I'm assuming you downloaded EURUSD data, because that would explain why you still see the error. Can you check in the cashbook that is logged in step 4 to see if the conversion rate of EUR is set to 0 or not? If it's 0 then the data that you downloaded most likely doesn't cover the 10 days before the start date of the backtest, if it's not 0 then you can safely ignore the error. To make the error disappear completely you'd need EURUSD minute history for the 10 minutes before the start of your algorithm.

2021-05-27T09:27:12.7093632Z ERROR:: AUSUSD 0 not found in portfolio. Request this data when initializing the algorithm.

This error indicates you're trying to place an order for AUSUSD without adding the security in Initialize using a method like AddForex. Please make sure this is not a typo for AUDUSD, and if it isn't that you subscribed to the security correctly.

Then I made another example using SPY and the default EMA cross from the QC builder I ended up with this error when run locally: 20210527 09:50:47.300 ERROR:: SPY: The security does not have an accurate price as it has not yet received a bar of data. Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup

This is a data error. When you run locally, your algorithm doesn't have access to the data from QC that is available when you run in the cloud. In this case that means you need to have SPY data for the resolution you are subscribing to in Initialize for the timespan of the backtest. At the moment that is a bit hard to set up, but we've got some changes coming soon that'll make it a lot easier to purchase and download LEAN-compatible data through the CLI.

Colin123 commented 3 years ago

Ok Jasper, thanks very much for taking the time for your detailed and concise reply. I will try to go further with your suggestions

jmerle commented 3 years ago

It's been more than a month since the last activity on this issue and the original questions have been answered, so I'm closing it. Please open a new issue if you're still facing issues.