Topics
Replies
gutygs
25 Jul 2019, 17:25
Hello!
I am having the same problem yet I can't find a way to fix it.
I'm trying to reference the NumSharp library in my code. To do that, I downloaded the package via NuGet on VisualStudio and I followed the steps on the link to point to the downloaded .dll
The program seems to compile just fine when I use the statement
using NumSharp;
nonetheless, when I try to use any of the many classes from the package, I get a compilation error. For instance, when trying to use
var nd = np.arange(12);
which is a statement that's perfectly fine on VisualStudio when using Numsharp, in cTrader I get several errors point that System.object .ICloneable .Collections.IList etc are defined on an assembly that is not referenced, and that I must add a reference to assembly netstandard.
I know this is probably not the correct way to get the Library, but there's no other way, and since I can't interact with Visual Studio, I am left with no other choice but to point to the library like this.
Is there any way to work around this?
Thank you very much!
@gutygs
gutygs
25 Jul 2019, 18:36
Sure thing!
This is the package I'm trying to install:
https://www.nuget.org/packages/NumSharp/
And this is the code that I'm trying to build:
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using NumSharp; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Strategy5 : Robot { [Parameter("iCandle", DefaultValue = 7)] public int iCandle { get; set; } protected override void OnStart() { Print("initializing console"); } protected override void OnBar() { //lets print the last 7 candle closes Print("Printing the last 7 candles"); var lastIndex = MarketSeries.Close.Count - 2; //start from -2 because -1 corresponds to current candle price Print(lastIndex); //Define the dataseries arrays double[] closePrices = new double[iCandle]; double[] openPrices = new double[iCandle]; double[] highPrices = new double[iCandle]; double[] lowPrices = new double[iCandle]; //Fill the dataseries arrays with data for (int i = 0; i < iCandle; i++) { double close = MarketSeries.Close[lastIndex - i]; double open = MarketSeries.Open[lastIndex - i]; double high = MarketSeries.High[lastIndex - i]; double low = MarketSeries.Low[lastIndex - i]; closePrices[iCandle - 1 - i] = close; openPrices[iCandle - 1 - i] = open; highPrices[iCandle - 1 - i] = high; lowPrices[iCandle - 1 - i] = low; } var nd = np.arange(12); //error on this line } protected override void OnStop() { // Put your deinitialization logic here } } }I installed the package in another project in Visual Studio by using the NuGet command line via
and pointed back on cTrader, pointed to the dll as showin in the tutorial here: https://ctrader.com/api/guides/referencing_dll
The reason I want to install this package is because I need to perform matrix operations with tensors, and back when using python, I mainly used Numpy.
Thanks for the help!!
@gutygs