-
-
Notifications
You must be signed in to change notification settings - Fork 78
Alpaca Streaming API
All WebSocket-based streaming messages described here are available for you via events of Alpaca.Markets.SockClient
class. All these events provides you read-only interfaces for related JSON objects.
For creating instance of Alpaca.Markets.SockClient
object you have to specify API ID, secret key and API endpoint URL. You have two main options - provide these values as parameters in constructor (last parameter is optional and can be omitted):
var client = new Alpaca.Markets.SockClient(
KEY_ID, SECRET_KEY, alpacaRestApi: new Uri(API_URL));
or use IConfiguration interface for providing data from configuration providers. In 2nd case API ID and secret key should be provided as configuration values keyId
and secretKey
respectively and endpoint URL can be optionally provided as alpacaRestApi
configuration value.
You have to call ConnectAsync
method for connecting stream and DisconnectAsync
for disconnecting. It also would be very helpful to dispose instance of Alpaca.Markets.SockClient
object using standard .NET IDisposable
pattern.
See usage examples for each event in unit test SockClientTest.cs.