-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OnTradeUpdate not stable #170
Comments
I have the same issue |
@pratttrader @zhaizhe111 - I've tried to reproduce this problem on my side but (as expected) without any success. Could you please provide me more information about this problem?
|
This is a Windows Desktop app, .NET 4.5 x86 running on Windows 64 bit. |
@pratttrader Of course, the main question is - that Alpaca environment do you use? Paper-only environment updated much often and as a result, you can experience 'strange' API behavior often. |
yes, this is paper only.. |
So should the DisconnectAsync() method raise the SocketClosed Event? To test my change, what should I use to "close" the socket? The only thing I see is DisconnectAsync, and that's not raising the SocketClosed Event. |
The |
I'm trying to add my own auto-reconnect function in my application, using what is available to me from Alpaca.Markets. A streaming connection is useless if doesn't at least try to self-correct when the socket is broken for whatever reason. The idea I have is like other brokers do it where it tries to reconnect, say 10x, every 4 seconds and then just stop...assuming that the socket/network connection is just dead. The problem I'm facing is this: if I'm connected with the AlpacaStreamingClient, and manually break the network connection...it raises the SocketClosed event. Good. But when I go back to ConnectAsync with the connection still broken, it raises "The socket is connected, you needn't connect again!" exception.....but it's not actually connected. Is that just an incorrect error message? This is all being triggered from the SocketClosed event. Thanks |
@pratttrader I'm sorry for your disappointments but unfortunately, the problem is not in Alpaca SDK itself and I don't know how to fix it easily right now. We use WebSocket4Net library for all web socket communications in Alpaca SDK and according to their issue tracker, this library has a problem with re-connection logic (see details here). I see the next possibilities for you (from simplest to hardest from my perspective):
Implementing re-connection logic inside SDK is a breaking change and I'm not ready to do it right now (need more time for designing this feature properly). |
Thanks for the reply. I'm not disappointed because this is what I do. I currently use another broker and before I move everything to ALPACA I just need to test everything from a trading perspective and a technology perspective. I'm not asking for an implementation of logic because in my view, that's my responsibliity. I was pointing out that I'm getting "Socket Connected", when it's not...which is hard to use on my end. All I have to work with are exceptions, object states and properties, and if something is inaccurate, it makes it hard. Right now I have it set to attemptt a reconnect, and if that fails (as in, my provider's connection has dropped), it releases the ALPACA objects and alerts me. From there, I might cycle every 10 seconds to try again. I'm also using another broker's connection for real-time prices, so I handle their exceptions and tie that it into my ALPACA code..but I need to plan on the assumption that that wont always be there. Additionally I'm building a seperate "Network Listener" which monitors my own network connection. I think have a plan going forward...thanks for the help. |
* docs: add OlegRa as a contributor for code, doc, and 7 more (#121) * docs: add ttt733 as a contributor for code, example, and tutorial (#124) * docs: add ooples as a contributor for code, example, and bug (#125) * docs: add ElektroMech as a contributor for code (#126) * docs: add biyimaks as a contributor for code (#127) * docs: add gjtorikian as a contributor for code (#128) * docs: add ajit-kolathur as a contributor for code (#129) * docs: add natehitze as a contributor for code (#130) * docs: add Hard-Coder05 as a contributor for code (#131) * docs: add amwsis as a contributor for code (#132) * docs: add Dav-id as a contributor for doc (#133) * docs: add shlomikushchi as a contributor for doc (#134) * docs: add PrometheusUno as a contributor for doc (#135) * docs: add schmich as a contributor for doc (#136) * docs: add Ronmenator as a contributor for doc (#137) * docs: add codebeaulieu as a contributor for code (#138) * docs: add Xallen79 as a contributor for code (#139) * docs: add jcjurevis as a contributor for code (#140) * docs: add koolinoor as a contributor for code, and bug (#141) * docs: add umitanuki as a contributor for bug, ideas, and 2 more (#142) * docs: add smartchris84 as a contributor for bug (#143) * docs: add codebeaulieu as a contributor for bug (#144) * docs: add mercalli as a contributor for bug (#145) * docs: add thedudebond as a contributor for bug (#146) * docs: add biyimaks as a contributor for bug (#147) * docs: add xutao650 as a contributor for bug (#148) * docs: add ttt733 as a contributor for bug (#149) * docs: add Ronmenator as a contributor for bug (#150) * docs: add sghitch as a contributor for bug (#151) * docs: add Wingspear as a contributor for bug (#152) * docs: add jameswhollister as a contributor for bug (#153) * docs: add DragonMastery as a contributor for bug (#154) * docs: add apfitzge as a contributor for bug, and ideas (#155) * docs: add apasumarthi1999 as a contributor for bug (#156) * docs: add pratttrader as a contributor for bug (#157) * docs: add tclzcja as a contributor for bug (#158) * docs: add SavageShade as a contributor for bug (#159) * docs: add nkoehler as a contributor for bug (#160) * docs: add camerontbelt as a contributor for bug (#161) * docs: add adrianbegi as a contributor for bug (#162) * docs: add FranMaher as a contributor for bug (#163) * docs: add softwaresalt as a contributor for bug, and ideas (#164) * docs: add kwcoffee1 as a contributor for bug (#165) * docs: add gsalaz98 as a contributor for bug (#166) * docs: add jcjurevis as a contributor for bug, and ideas (#167) * docs: add thi517 as a contributor for bug (#168) * docs: add SteveHaudegen as a contributor for bug (#169) * docs: add samueldonovan1701 as a contributor for bug (#170) * docs: add jzderadicka as a contributor for bug (#171) * docs: add aliasgharrajabi as a contributor for bug (#172) * docs: add Huios as a contributor for bug (#173) * docs: add rudeGit as a contributor for bug (#174) * docs: add lgreenlee as a contributor for bug (#175) * docs: add r-ulak as a contributor for bug (#176) * docs: add zhorakiev as a contributor for bug, and ideas (#177) * docs: add shlomikushchi as a contributor for ideas (#178) * docs: add liftee as a contributor for bug (#179) * docs: add TonyC1Ward as a contributor for bug (#180) * docs: add jeffwlandry as a contributor for bug (#181) * docs: add nbmrao as a contributor for bug (#182) * docs: add mehtadharmesh as a contributor for bug (#183) * docs: add Ricbun16 as a contributor for bug (#184) * docs: add ayushguptacoder as a contributor for bug (#185) * docs: add opened as a contributor for bug (#186) * docs: add bizjaya as a contributor for bug (#187) * docs: add raduistrate as a contributor for bug (#188) * docs: add woaksie as a contributor for bug (#189) * docs: add ktrauberman as a contributor for bug (#190) * docs: add gchudublin as a contributor for bug (#191) * docs: add mattrobinson3 as a contributor for bug (#192) * docs: add Tifoid as a contributor for bug (#193) * docs: add AdsophicSolutions as a contributor for bug, and ideas (#194) * docs: add waymanapps as a contributor for ideas, and question (#195) * docs: add tstraus13 as a contributor for bug (#196) * docs: add matt953 as a contributor for bug, and ideas (#197) * docs: add YongliangLi as a contributor for bug, and ideas (#198) * docs: add polymorphicshade as a contributor for bug, and question (#199) * docs: add nathan-datusarator as a contributor for bug (#200) * docs: add ManfredLange as a contributor for bug, and ideas (#201) * docs: add JCloarec as a contributor for bug (#202) * docs: add jeonnagroup2 as a contributor for bug (#203) * docs: add IsaackRasmussen as a contributor for bug (#204) * docs: add matsydoodles as a contributor for bug (#205) * docs: add natehitze as a contributor for doc (#206) * docs: add logmd as a contributor for code (#207) * docs: add tdhatcher as a contributor for bug (#208) * docs: add TheHumanWithAPlan as a contributor for bug (#209) * docs: add tcj2001 as a contributor for bug (#210) * docs: add JasonAr936 as a contributor for bug, and ideas (#211) * docs: add markns as a contributor for bug (#213) * docs: add Ilya171 as a contributor for bug (#214) * docs: add waymanapps as a contributor for financial (#215) Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
I'm posting this here only because I'm using the C# API. I'm not sure if my issues are with the ALPACA backend or with the AlpacaStreamingClient.
I've been having many instances where I place on order....PostOrderAsync returns an accepted order, the order shows up in the ALPACA web interface(so it's active), but nothing gets returned ever through OnTradeUpdate. I have no way to debug this..so this is just an FYI for you. There also is no pattern to it. If I re-initialize the object, it's fine for awhile, then it stops and once it stops working it's dead. Some days it works fine all day and then others it just bombs. Should I open/close the streaming connection after every PostOrderAsync?
But as a result I need to strip out all use of AlpacaStreamingClient for now and move to ListOrdersAsync or GetOrderAsync..to verify the status of an active order.
Using 3.5.0.0
The text was updated successfully, but these errors were encountered: