Closed SigmaU closed 5 years ago
It does not make sense, it seems that VS swallows the exception if there is any thrown at all. While in Visual Studio press Ctrl+Alt+E and select the following:
Rerun and see if exception is thrown.
I'll contact Spotware as well on all this and get back to you. I would love to use NumSharp in these projects - it's a game changer. Thank you @Nucs !
I don't think it has to do with our library, np.arange
is very basic, doesnt have any funky unmananged code.
Perhaps you have heap corruption or swallowed exception elsewhere. Im willing to help you find it if you can share your project so I can reproduce locally.
If it is heap corruption, the output window might shed light but not necessarily.
Yes - arange seemed just fit to test an ndarray generate. I reached out here with an issue because while v0.20.1 doesn't seem to work, v0.10.6 oddly works just fine and so I thought some major change happened at a core level. Then again i tried Numpy.Net same way and none of the version work there at all. Same odd hickup for such an easy generate.
As a full context - cTrader/cAlgo is a Spotware .Net 4.5(at the moment) windows desktop application which allows c# robots/indicators to be run within the software, live with the cAlgo interface (in this case Indicator) connected to the broker. These "Indicators" can be written within the software, Visual Studio or both. Mainly open to anything .Net related as long as data ends up back in the two main-internal methods: Initialize() & Calculate() so it can be plotted live on the software chart. What I have is a default indicator template code - empty trying to generate an ndarray and printing out its size in this case - this is just so we see it run and go trough (but it never reaches that line of code). I've set the latest .NET framework(4.7.2) and prompted, added netstandard as well (without these it wouldn't have built)
Sharing the project wouldn't be a problem since it's a small one. I'll set up a repository with everything - both v0.10.6 and v0.20.1 were added since I find this being the only clue at this point. Testing both separately might reveal something.
Appreciate it!
I'll wait for the repositories, there is not point in testing NumSharp for these two different versions, they are completely different libraries, over 90% was rewritten.
Makes sense then. I originally added both and with everything you need to replicate the scenario, in any way possible. repository
Grateful!
You are lucky I'm a quant-trader myself, After building the project it writes to calgo documents directly which then allows you to attach debugger to the cTrader process and debug the code once you add the indicator.
Heres my code changes that also print out the exception that cTrader swallows: https://pastebin.com/Hhq6XVNv The exception is printed to the (Output window) in Visual Studio
The type initializer for 'EngineCache
1' threw an exception. ---> System.Security.SecurityException: Request failed. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance[T]() at NumSharp.Backends.BackendFactory.EngineCache
1..cctor() --- End of inner exception stack trace --- at NumSharp.Backends.BackendFactory.GetEngine(BackendType backendType) at NumSharp.np.arange(Int32 start, Int32 stop, Int32 step) at cAlgo.NDArray_0_20_1.Initialize() The program '[14160] cTrader.exe' has exited with code 0 (0x0). The program '[14160] cTrader.exe: Program Trace' has exited with code 0 (0x0).
Doing a quick search about the exception with the context of cTrader yielded: https://ctrader.com/forum/cbot-support/16225
And as mentioned in the forum, changing the IndicatorAttribute
to AccessRights = AccessRights.FullAccess
fixed the issue.
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class NDArray_0_20_1 : Indicator
{
Read more about AccessRights here
It might be enough to give it just FileSystem
rights.
Hah^ quants, that's amazing! Then again, ... NumSharp, yeah should've seen that coming hehe. It makes so much sense now! Yes I'm familiar with the AccessRights but never considered it since usually these things don't build without it being set right and the output window in VS was mainly focusing on cTraders symbols missing and "just my code" thrown with or without NumSharp (thats why id didn't consider it relevant) and quite frankly debugging is quite limited as you can see with cTrader.
Nevertheless you've helped far more then I could've asked! So grateful! Thank you for your time!
This is my first post so excuse me if I'm not as sharp as you guys. Great work everyone! Cheers!
I wish to use NumSharp in my cAlgo projects and version 0.1.6 works just fine but neither one of the versions that came after (0.2.x). I cannot pinpoint the cause since I'm working with a cAlgo software/api project (comes with limitations). Nothing withing NumSharp seems to work - code just stops when calling NumSharp. Tried everything - doesn't matter, it doesn't go trough the line of code. Tried Numpy.Net as well but can't seem to have it work at all (no version).
Can someone shed some light on this matter? What changed so drastically in v0.2? Am I missing something?
Here is a default project that should generate a simple np.arange(20) and print it out on the top of the chart: