Getting started
Lime C# SDK is a nuget package compatible with .Net Standard that allows you to send orders and receive order events as callbacks. The SDK uses async/await
programming pattern, is friendly to dependency injection frameworks, introduces minimal footprint to latency. Install the package from nuget.org as nuget install LimeFinancial.Trading.Api
.
Implement ICallback
interface that receives events from the trading server:
public class MyEventProcessor : ICallback
{
// other methods are omitted for simplicity
public void OnOrderAck(long eventId, long orderId, long limeOrderId, AckOptions options)
{
Console.WriteLine($"Accepted, order id: {orderId}, lime order id: {limeOrderId}");
}
public void OnCancelAck(long eventId, long orderId)
{
Console.WriteLine($"Cancelled, order id: {orderId}");
}
}
Connect to the trading server and send orders:
// create the Client object passing a logger and connection parameters
IClient client = new Client(callback, host, port, account, username, password, logger);
// an instance of a class implementing ICallback that will receive order updates
ICallback callback = new MyEventProcessor();
// establish the tcp connection and attempt to login
await client.ConnectAsync(0, false, false, CancellationToken.None);
// create and order with id 123 to buy 50 shares of PAR at $40 (forty dollars zero cents) via ARCP route
await client.PlaceAsync(123, 50, 400000, Side.Buy, "PAR", "ARCP");
// cancel the order known to server as 123
await client.CancelAsync(123);