spotware / openapi.net Goto Github PK
View Code? Open in Web Editor NEWcTrader Open API .NET Rx library
Home Page: https://spotware.github.io/OpenAPI.Net/
License: MIT License
cTrader Open API .NET Rx library
Home Page: https://spotware.github.io/OpenAPI.Net/
License: MIT License
Hi,
I've been testing out the API with python, but I'm having some trouble with getting the initial authorization working. Would it be ok if I share the code here, work on it and once it works, clean it up and put it up as a simple python examples repository for OpenAPI?
Thanks!
There is no longer a response when using GetTrendbars in the APIService.cs (WPF.Sample project). I have had no issues previously. Note that I can still get a trendbar response if I use the winforms sample.
Hey, I just want to inform you that the link on NuGet is wrong.
It goes to afhacker
instead of this repo. ๐
Hi,
i have the latest npm package and get issue sometimes in Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 65
How fix it?
Exception: OpenAPI.Net.Exceptions.ReceiveException: An exception occurred while reading from stream
---> System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter)
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory1 buffer) at OpenAPI.Net.OpenClient.ReadTcp(CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Reactive.AnonymousSafeObserver1.OnError(Exception error) in //Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 65
at System.Reactive.Sink1.ForwardOnError(Exception error) in //Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 61 at OpenAPI.Net.OpenClient.OnError(Exception exception) --- End of stack trace from previous location --- at System.Reactive.AnonymousSafeObserver1.OnError(Exception error) in //Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 65
at System.Reactive.Sink1.ForwardOnError(Exception error) in //Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 61 at OpenAPI.Net.OpenClient.OnError(Exception exception) --- End of stack trace from previous location --- at System.Reactive.AnonymousSafeObserver1.OnError(Exception error) in //Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 65
at System.Reactive.Sink1.ForwardOnError(Exception error) in //Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 61 at OpenAPI.Net.OpenClient.OnError(Exception exception) --- End of stack trace from previous location --- at System.Reactive.AnonymousSafeObserver1.OnError(Exception error) in //Rx.NET/Source/src/System.Reactive/AnonymousSafeObserver.cs:line 65
at System.Reactive.Sink`1.ForwardOnError(Exception error) in //Rx.NET/Source/src/System.Reactive/Internal/Sink.cs:line 61
at OpenAPI.Net.OpenClient.OnError(Exception exception)
Despite our best efforts, bugs can slip into releases or corner cases forgotten about. We will try our best to remedy the situation
and/or provide workarounds. Note that certain (odd) behaviors are by design and as such are not considered bugs.
Which library version? last release
What are the platform(s), environment(s) and related component version(s)? dotnet
What is the use case or problem? Stream get sometimes canced
What is the expected outcome? transfer data as complete
What is the actual outcome? Stream will be closed
What is the stacktrace of the exception(s) if any?
How can i fix it?
I've come across an issue with the library where calling ProtoOAAccountAuthReq does not return any response, no errors or anything, it just waits for a response indefinitely. (The initial request to ProtoOAApplicationAuthReq always succeeded.)
This issue doesn't happen all the time, I feel like it only occurs if there is a deployment ongoing on the Spotware side, I'm not sure. I've seen this happen several times in the past and usually fixes itself after a few hours.
I have figured out the cause of the issue, and it has something to do with the proxy URL returned by ApiInfo.GetInfo(Mode). The GetInfo() method returns "demo.ctraderapi.com" or "live.ctraderapi.com".
however, based on the Proxies/Endpoints documentation (https://help.ctrader.com/open-api/proxies-endpoints/), there are several region-specific servers that should be used, such as "demo-sg.ctraderapi.com" or "live-sg.ctraderapi.com".
Since I started using this library, the examples specify that the way to initialize the SpotwareClient object should be done like this:
OpenClient client = new(ApiInfo.GetHost(Mode.Demo), ApiInfo.Port, TimeSpan.FromSeconds(10));
Which would return the "demo.ctraderapi.com" or "live.ctraderapi.com" URL.
The fix is to not use ApiInfo at all during initialization of the OpenClient object, instead, either retrieve the region-specific URL from your database or hardcode the URL during ctor initialization.
I am currently using v1.4.4 of this library.
Maybe an update to the ApiInfo code should be done to support these region-specific API servers?
When going through the file samples/Console.Sample/Program.cs
came across the following code at line 88
:
System.Diagnostics.Process.Start("explorer.exe", $"\"{authUri}\"");
Since this is valid only on Windows, it can be wrapped in an if statement checking
System.OperatingSystem.IsWindows()
For the rest of the operating systems, the final authUri
can be printed to the console or appropriate process can be opened (in MacOS it would be open
command).
I can't create and a branch and create a pull request so the fix is here:
MessageFactory in GetMessage this line is missing
(int)ProtoOAPayloadType.ProtoOaDealListByPositionIdRes => ProtoOADealListByPositionIdRes.Parser.ParseFrom(payload),
Hi, I'm creating a Node.js framework for automatically operating in financial markets: https://github.com/Reiryoku-Technologies/Mida.
I understand that you are allowing this through the OpenAPI referenced at:
https://connect.spotware.com/docs/open_api_2
I have a question:
Thank you.
Had a problem with sending/receiving over TCP, but
I had just forgotten to use a SSL stream.
I'm unable to query PnL because this message does not exist in the dll
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.