C# autocomplete with Skylight?

Back

Is there a recommended procedure for getting C# autocomplete working while using Skylight?  Ultimately, I would like to use VSCode with Skylight. Is this just a matter of building LEAN locally and adding the assemblies to some library path in VSCode?

Thanks!

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.


Hey RJJ,

You're absolute correct! You can use autocomplete locally by installing and building Lean locally. Skylight can be used with any editor, including VSCode. It will sync your project files in the cloud with changes made locally.

Best
Rahul

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.


Just replying here for posterity. I finally got it working but it was a bit of a struggle. The problem is that the LEAN project is set up to have all the algo source in a specific folder. And Skylight is set up so that all synced code is in a specific folder... and those aren't the same folders.

So, in order to have autocomplete in the Skylight project folder, you need to create a .csproj file there that will add the correct references from LEAN build folder. I started with QuantConnect.Algorithm.CSharp.csproj and modified all the paths to point to the correct LEAN directory. This way I can create a new Skylight project and just drop the .csproj file in there and autocomplete will work.

It would be nice to have this process officially documented somewhere.

3

Hi RJJ,

I was wondering, is your setup still working fine? I did something similar and successfully got the intellisense autocomplete working, but unfortunately Skylight is now having issues with syncing the project. It doesn't seem to like the project related files generated by Visual Studio. 

For example, these are the lines relevant taken from my log file:
 

2020-09-09T03:49:20.549Z ERROR:: FileSync.UploadFileToCloud(): Failed to upload new file: packages.config in project: 5466880 File extension is not valid.
2020-09-09T03:49:20.549Z ERROR:: FileSync.UploadLocalProject(): Failed to upload file for project: C:\Users\leagu\QuantConnect\Brett Young\Optimized horizontal atmospheric scrubbers, File extension is not valid.
2020-09-09T03:49:20.561Z ERROR:: FileSync.UploadFileToCloud(): Failed to upload new file: obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache in project: 5466880 File extension is not valid.
2020-09-09T03:49:20.571Z ERROR:: FileSync.UploadFileToCloud(): Failed to upload new file: app.config in project: 5466880 File extension is not valid.
2020-09-09T03:49:20.576Z TRACE:: FileSync.UploadFileToCloud(): Updated file: Research.ipynb
2020-09-09T03:49:20.580Z TRACE:: FileSync.UploadFileToCloud(): Updated file: Main.cs


This would not be a problem if the other files were updated correctly as the cloud only really needs the .cs files; but unfortunately they are also not updated/synced. For example, in this case even though it says "Updated file: Main.cs", the file is not synced between the web and my local machine. It seems that the errors destroy the whole syncing process.

Did you also encounter this problem?
 

0

Hi RJJ,

 

We have notified the engineer team about documenting the procedure for C# autocomplete in Skylight. We’ll update the community when we have a solution.

 

Best,

Gahl Goziker

0

Just replying here for posterity. I found an alternative way to get this working. 

Using the Lean .sln file (clone github repo) with Visual Studio you can create links to the files contained within the local Skylight project folders, so you can work with them in the same project. I only included the .cs files, to do this add the following to the QuantConnect.Algorithm.CSharp.csproj (but be sure to change User in the path):

<ItemGroup>
<Compile Include="C:\Users\User\QuantConnect\User\**\*.cs*">
<Link>SkyLightProjects\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>


No compiling/building is done locally and everything is synced with Skylight so it's very easy and quick to do backtests online. I really like this setup. 

I later found out about the .qcignore file inside the local Skylight folder, which can probably be used to solve the problems mentioned for the setup described in my previous comment (approach of having .csproj file in each local project folder).

I prefer this new way over the other  Perhaps flaws will become apparent as I start to use it more.
In the meantime while a official solution is yet to be documented, this setup works great for me.

2

Hi Brett,

I haven't experienced the problems you've mentioned previously. It seems to sync fine for me. On a new Skylight project I just drop my modified .csproj file in and all is good. I had no idea about the .gcignore though. Good to know!

Your new approach also makes sense. So you basically open the LEAN workspace and then work on the Skylight files in there, correct?

0

Hi Gahl,

I'm wondering how your engineers are getting on with writing a how-to setup intellisense with Skylight? 

I have Skylight installed and can edit and sync locally, but I'm really unclear about the correct method to setup a local IDE that works with Skylight and has QuantConnect code intellisense.

I've cloned the LEAN repository and built it - but how do I then use it?

I've also got Docker installed and have downloaded LEAN to it and can have this running, and can install VScode extensions for Docker and can remote into the LEAN project - but whatever I do I cannot get code completion to work.  I read somewhere that this was the preferred method to work, but not being a Docker user I'm now stuck.

Any pointers would very much be appreciated!

 

0

Hi Nick,

To get autocomplete working for Skylight files, please follow these steps (note: this assumes the user has Lean installed locally):

  1. Open the Lean project using VSCode
  2. Install a Symbolic Linking extension (for reference, I use autolink by Archal)
  3. Follow the steps for the Symbolic Linking extension, and then go to File->Open File, then select the .cs files in the Skylight folder that you’d like to edit. If you are using autolink, then simply opening the .cs files automatically creates the Symbolic Link for you
  4. Make any changes, then save using ctrl-s, then right-click the Skylight icon in the toolbar, and sync, and any changes made should be reflected in the cloud

Best,
Shile Wen 

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.


Hi Shile,

Many thanks for the help - this is great and something I haven't seen mentioned elsewhere.  Sounds like a very simple workflow which is great.

So I've opened the project (stage 1) and installed Autolink & activated it.  However when I open the .cs file from a folder outside the LEAN project, I still get no intellisense on the file (I still have the full LEAN folder open in VSCode).  You say follow the steps on the Autolink extension, but as far as I can see there are no steps - the helpfile isn't what you can say "helpful".   It says that a dialogue should pop up when you open the other file and ask you to add a symlink, but nothing happens like this.

Intellisense seems to be working in the LEAN project, since I can open pre-existing .cs files and all works fine.  However if I open a file from another directory it still doesn't work.

Apologies - but I'm not sure what I'm doing wrong.

Nick

0

Hi Nick,

That may not be the Autolink by Archal, as the one by Archal doesn't require you to confirm the symlink, it automatically creates them for you. Furthermore, you may have to use File->Open instead of double-clicking the file in the folder if you have done otherwise.

Best,
Shile Wen 

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.


Hi Shile,

Thanks for your help - still doesn't work I'm afraid.  However not to worry as I've managed to use the first method (create a C# project in the folder and add references to LEAN).

  • I installed c# extensions to enable c# coding/debugging in vs code.
  • Followed these instructions to create a new project (in the folder that Skylight was syncing to QuantConnect): 
  • https://www.tutorialkart.com/c-sharp-tutorial/create-csharp-project-with-visual-studio-code/
  • Added reference to C# project to all DLLs in the LEAN directory under Algorithm.Csharp/bin/debug  (used Visual Studio2019 for this as was quicker).

Then autocomplete works with full intellisense.  I guess I can then copy/paste this project around for other folders as it uses relative links to the LEAN folder.

 

0

Thanks to Brett Young I was able to solve this problem in a very elegant manner. Simply adding the folowing to the bottom of my QuantConnect.Algorithm.CSharp.csproj file (right above the </Project> tag), within the lean folder/project, I was able to get full autocomplete/intellisense support within VSCode. This solution, along with `pip install quantconnect-stubs` for Python, has allowed for an ideal setup for writing strategies in both languages.

118619_1606310091.jpg

Note that I'm personally using qcli instead of Skylight for syncing local code with QuantConnect, but the premise is the same. I have one VSCode workspace setup with a project for Lean, and another project for my trading algorithms. Here's a snapshot below to give you guys an idea.

118619_1606309702.jpg

 

P.S. Make sure you have VSCode/Omnisharp pointed to QuantConnect.Lean.sln as the primary project, otherwise this won't work. VSCode/Omnisharp currently only support one csharp project being active at a time. You can switch using the command pallet `Omnisharp: Select Project` or clicking to the right of the little fire icon at the bottom left within VSCode.

118619_1606309983.jpg

0

Just wanted to report back my final solution, which I feel is much simpler/elegant. 

Given the following directory structure:

118619_1606309702.jpg

Simply add the following .csproj to your trading-algorithms folder (apologize for using an image, but the community editor doesn't like xml): 

https://gist.github.com/cnaccio/365713c44a2c6b59ae27776541d6acb1

118619_1606420798.jpg

0

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

To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!