cAlgo.NET framework version
cAlgo.NET framework version
09 Jun 2016, 18:00
Hi cTrader/cAlgo developers,
Is .NET 4.5 supported? Or do we have to compile algos against 4.0 Client Profile?
Replies
jaredthirsk
07 Sep 2016, 13:36
RE: RE: .NET 4
she666 said:
zelenij.krokodil said:
Hi cTrader/cAlgo developers,
Is .NET 4.5 supported? Or do we have to compile algos against 4.0 Client Profile?
cAlgo.dll is v4.0.30319 which implies dotNet 4.0
Spotware, any chance of dotNet upgrade for better performance? It's been 3 years and still remains stagnant.
+1
.NET 4 Client Profile is basically abandoned by Microsoft -- everybody has moved on (.NET 4.6.2). Is cTrader/cAlgo abandoned?
@jaredthirsk
galafrin
09 Sep 2016, 01:47
RE: RE: RE: .NET 4
jaredthirsk said:
she666 said:
zelenij.krokodil said:
Hi cTrader/cAlgo developers,
Is .NET 4.5 supported? Or do we have to compile algos against 4.0 Client Profile?
cAlgo.dll is v4.0.30319 which implies dotNet 4.0
Spotware, any chance of dotNet upgrade for better performance? It's been 3 years and still remains stagnant.
+1
.NET 4 Client Profile is basically abandoned by Microsoft -- everybody has moved on (.NET 4.6.2). Is cTrader/cAlgo abandoned?
Good point for Calgo is sometimes slow and consumes too much resources, for instances loading multi symbols series or the Optimizer.
@galafrin
andrewfblake
19 Apr 2017, 04:35
Fixed!
I had this problem too and did not want to change anything in cAlgo.... but managed to fix it simply by editing the Bot in Visual Studio and updating that to the new framework 4.6.2.... It then calls my Class Library in 4.6.2 and works like a dream... no need for Spotware to do any updates :-)
@andrewfblake
Mikro
28 Feb 2019, 12:07
.Net Framework update needed!
Dear support,
when will there be an update on a up to date .Net framework?
Literally no C# NuGet packages still support .Net 4.0 so coding algos is becoming a pain in the a.. needing to focus precious coding time to try and avoid the compatibility issues.
We need help here!
cheers
@Mikro
mpistorius
27 May 2019, 06:10
RE: Fixed!
andrewfblake said:
I had this problem too and did not want to change anything in cAlgo.... but managed to fix it simply by editing the Bot in Visual Studio and updating that to the new framework 4.6.2.... It then calls my Class Library in 4.6.2 and works like a dream... no need for Spotware to do any updates :-)
Would you care to elaborate on this, please? Is there some workaround to use new language features from, say C#7? When I try to build my project in Visual Studio, I still get errors from the cAlgo extension trying to build a .algo file. And I cannot disable the extension, then the project won't load.
@mpistorius
jaredthirsk
01 Jun 2019, 11:16
RE: RE: Fixed!
mpistorius said:
andrewfblake said:
I had this problem too and did not want to change anything in cAlgo.... but managed to fix it simply by editing the Bot in Visual Studio and updating that to the new framework 4.6.2.... It then calls my Class Library in 4.6.2 and works like a dream... no need for Spotware to do any updates :-)
Would you care to elaborate on this, please? Is there some workaround to use new language features from, say C#7? When I try to build my project in Visual Studio, I still get errors from the cAlgo extension trying to build a .algo file. And I cannot disable the extension, then the project won't load.
What errors are you seeing? People may be able to help if they know.
FWIW, my workflow: (admittedly complex, most people should maybe ignore most of this unless they are going deep into coding possibilities like me, though maybe it shows how you might be able to use newer .NET)
- For most of my code, I prefer .NET Standard 2.0 (I create DLLs from Visual Studio) and I believe I use the latest language features, C# 7.3 whatever, though I don't know if I'm using the new data types like tuples and Span<>s and such or if those would conflict.
- The DLL I reference from cTrader in my algos is currently .NET 4.7.2. I will probably try 4.8 here soon. There isn't much code in this DLL -- it mostly pulls in my other netstandard DLLs. I created this DLL from Visual Studio.
- I am a programming junkie and have a bunch of DLLs, but it is a pain to get a kajillion references correct in all my cAlgo projects, so I merge everything to one DLL using ILRepack as a post-build event.
- When I create a new bot in cTrader, I go to add references and add my one big DLL (.NET 4.7.2). I just leave the cTrader project at whatever Spotware created it as -- I guess Spotware still defaults to 4.0 Client? That is crazy, but I guess it doesn't matter to me. I noticed on one bot I made, I changed the cAlgo\Sources\Robots\xyz\xyz.csproj to v4.7.2, though I don't think I even need to do this, generally speaking:
- Default:
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- New:
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
- Default:
- My new bots in cTrader references a base class instead of Robot, so that I get some logic from my base class, such as my custom GetFitness scoring system. (I base it on annualized ROI divided by max equity drawdown.)
- For some bots, I started moving most trading logic to my own DLLs. I am hoping to at some point host them in my own .NET console app and use FIX protocol, instead of hosting them inside of cTrader, which is a resource hog if I want to run say 200+ bots, which I think is actually a reasonable goal for people working towards being serious algotraders. Also, I have a memory leak problem when optimizing using cTrader (not sure if it's my fault or spotware's), and if I only have one VPS that did both (probably demo account) bots and optimization, I obviously wouldn't want to shut down and restart cTrader and start all the bots up again every time I ran out of memory. I don't want to have to rent a bunch of expensive VPS's. I plan to run them on relatively cheap linux VPS's using .NET Core.
- Long-term FEATURE REQUEST: Ideally, Spotware would release some sort of UI-less bot service for running bots, and a command line interface to start/stop/query bots, which runs on .NET Core and supports Windows/Linux(/and it may work on Macs for free.)
- I forgot what the Visual Studio extension even does. But I should try to do the right click and edit in Visual Studio thing more often, since editing within cTrader is relatively painful (yet convenient) IDE compared to VS2019.
- I use new Newtonsoft.JSON (version 12)
- Every time Spotware releases a new version of cTrader, I have to hunt down the cTrader.exe.config file in c:\users\myname\appdata\local\apps\2.0\{random}\{random}\brokername...ctrader...\ and do a .NET Assembly binding redirect for Newtonsoft.Json to whatever version Spotware is using. Spotware has been shipping v9 but I see they just switched to v10. Hurrah. I might switch to another JSON serializer just to avoid having to do this. Since I am logging optimization runs, I might get a perf boost if I switch to a more performant library anyway. Microsoft started shipping their own very fast serializer -- I might try that if it is compatible.
- Caveat: I'm not 100% sure how safe this is, or if anything could possibly break from one version of cTrader to the next, though I tend to think that if all netstandard2.0 and .NET 4.7.2 code paths of my bot work, then I am probably good for the time being.
@jaredthirsk
jaredthirsk
01 Jun 2019, 11:37
RE: RE: RE: .NET 4
jaredthirsk said:
+1
.NET 4 Client Profile is basically abandoned by Microsoft -- everybody has moved on (.NET 4.6.2). Is cTrader/cAlgo abandoned?
As a followup to my comment from 21 months ago: the recent changes to cTrader are impressive, and it doesn't feel abandoned (anymore) -- it feels like it is getting some love. Keep up the good work and I hope you prioritize features that make the biggest difference to successful trading.
@jaredthirsk
jaredthirsk
01 Jun 2019, 11:43
I think this discussion as a prerequisite needs to understand in-place upgrades for .NET 4. Here are some articles from 2012 that perhaps give an adequate overview:
https://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx
https://weblog.west-wind.com/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40
Suggestion for Spotware: for your new Robot/Indicator csproj project templates, change the default to something from this era, like 4.6.1 or 4.7.2 or 4.5 or something. 4.0 Client Profile may technically work (if I understand it right?) but it sounds like people have problems with nuget (?) so it might be better to at least go to 4.5.
@jaredthirsk
driftingprogrammer
16 Feb 2020, 12:46
I think Robot is still stuck with .NetFramework 4 Client Profile
I am not sure i understand how to move my robot to higher versions of .Net Framework.
Here is a post which complains that i am unable to use SQLite from my cbot. -
When i tried using Postgres i did what is recommended, take a fresh robot, open in Visual Studio 2017, change the .net framework in the project properties to 4.6.1 from 4.0 Client Profile.
This enables me to get the latest Postgres package from nuget.
But while running this as a console application would be fine when i run it as a robot i get the following error
'FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral
In ioder to fix that i need to create a new project and not increase its .Net Framework version but rather select a older version of the postgres package on nuget to be able to install it on my project.
After compilation now when i run my robot it is able to connect to the postgres database from inside cTrader.
(Although this methodology did not fix the SQLite connectivity issue) This shows to me that although one can compile the code using latest packages from nuget, if it needs to actually be able to run in cTrader it needs to run against the version of those tools that were built for the older version 4 Client Profile to be specific in this case.
jaredthirsk said:
I think this discussion as a prerequisite needs to understand in-place upgrades for .NET 4. Here are some articles from 2012 that perhaps give an adequate overview:
https://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx
https://weblog.west-wind.com/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40
Suggestion for Spotware: for your new Robot/Indicator csproj project templates, change the default to something from this era, like 4.6.1 or 4.7.2 or 4.5 or something. 4.0 Client Profile may technically work (if I understand it right?) but it sounds like people have problems with nuget (?) so it might be better to at least go to 4.5.
@driftingprogrammer
driftingprogrammer
11 Mar 2020, 13:18
RE: I think Robot is still stuck with .NetFramework 4 Client Profile
driftingprogrammer said:
I am not sure i understand how to move my robot to higher versions of .Net Framework.
Here is a post which complains that i am unable to use SQLite from my cbot. -
When i tried using Postgres i did what is recommended, take a fresh robot, open in Visual Studio 2017, change the .net framework in the project properties to 4.6.1 from 4.0 Client Profile.
This enables me to get the latest Postgres package from nuget.
But while running this as a console application would be fine when i run it as a robot i get the following error
'FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral
In ioder to fix that i need to create a new project and not increase its .Net Framework version but rather select a older version of the postgres package on nuget to be able to install it on my project.
After compilation now when i run my robot it is able to connect to the postgres database from inside cTrader.
(Although this methodology did not fix the SQLite connectivity issue) This shows to me that although one can compile the code using latest packages from nuget, if it needs to actually be able to run in cTrader it needs to run against the version of those tools that were built for the older version 4 Client Profile to be specific in this case.
jaredthirsk said:
I think this discussion as a prerequisite needs to understand in-place upgrades for .NET 4. Here are some articles from 2012 that perhaps give an adequate overview:
https://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx
https://weblog.west-wind.com/posts/2012/Mar/13/NET-45-is-an-inplace-replacement-for-NET-40
Suggestion for Spotware: for your new Robot/Indicator csproj project templates, change the default to something from this era, like 4.6.1 or 4.7.2 or 4.5 or something. 4.0 Client Profile may technically work (if I understand it right?) but it sounds like people have problems with nuget (?) so it might be better to at least go to 4.5.
SQLite connectivity issue was resolved using the workaround mentioned here -
@driftingprogrammer
ergun
29 Apr 2020, 00:43
RE: Fixed!
andrewfblake said:
I had this problem too and did not want to change anything in cAlgo.... but managed to fix it simply by editing the Bot in Visual Studio and updating that to the new framework 4.6.2.... It then calls my Class Library in 4.6.2 and works like a dream... no need for Spotware to do any updates :-)
You saved my day. Thank you very much :)
@ergun
she666
16 Jul 2016, 08:20
RE:
zelenij.krokodil said:
cAlgo.dll is v4.0.30319 which implies dotNet 4.0
Spotware, any chance of dotNet upgrade for better performance? It's been 3 years and still remains stagnant.
@she666