Closed jamesboyer closed 3 years ago
hey @jamesboyer,
A few things here:
The client_oid that you are passing in when placing the order is different than the OrderId
on LastOrder
so the match you are doing won't work. The correct way to do this would be to use the id
property returned from your buyResult
as the match in your OnDoneRecieved
instead of the buyId. Something like this:
var tradeId = buyResult.Id;
void WebSocket_OnDoneReceived(object sender, WebfeedEventArgs<Done> e)
{
if (e.LastOrder.OrderId == tradeId)
{
Console.WriteLine("ORDER HAS BEEN FILLED");
}
}
The client_oid will only be available on the public feed for a received
message and according to the docs will NOT be used after the recieved
message is sent. But if you want to be able to see your trade on the public feed you'll have to subscribe to OnReceivedReceived
from the websocket. Also, don't forget to subscribe to the Full
channel for this otherwise the messages won't come in. For example:
coinbaseConnection.WebSocket.OnReceivedReceived += WebSocket_OnReceivedReceived;
void WebSocket_OnReceivedReceived(object sender, WebfeedEventArgs<Received> e)
{
if (e.LastOrder.ClientOid == buyId)
{
Console.WriteLine("We match!");
}
}
hope this helps. Let me know if you are still running into any issues or it's not clear.
Makes sense. Only downside is that the WebSocket_OnDoneReceived
could get handled prior to me setting tradeId
. Will have to figure out a way around that but shouldn't be too hard. Important thing is at least I do have the right event. Thanks for the help.
I was wondering what would be the recommended way to send a limit sell order after placing and filling a buy order. I have similar to the following, however I never get a Done matching my buyId so I can place a sell limit order. Is there a different web socket event I should be listening to?