Skip to content

msdotnetclr/alpaca-trade-api-csharp

 
 

Repository files navigation

Nuget Nuget (with prereleases) Nuget

.NET SDK for Alpaca Markets API

.NET Core Usage Example

  1. Create a new console application in a new, empty folder by running dotnet new console.
  2. Add a reference for Alpaca .NET SDK with dotnet add package Alpaca.Markets.
  3. Change Main method in auto-generated Programm.cs file to this code snippet:
var client = Alpaca.Markets.Environments.Paper
    .GetAlpacaTradingClient(new SecretKey(KEY_ID, SECRET_KEY));

var clock = client.GetClockAsync().Result;

if (clock != null)
{
    Console.WriteLine(
        "Timestamp: {0}, NextOpen: {1}, NextClose: {2}",
        clock.Timestamp, clock.NextOpen, clock.NextClose);
}
  1. Replace KEY_ID and SECRET_KEY values with your own data from the Alpaca dashboard.
  2. Run the sample application using dotnet run command and check the output. You should see information about the current market timestamp and the times that the market will open and close next.

See the UsageExamples project for near-to-real-world strategy implementation using this SDK. The Wiki pages contains a lot of additonal information about different aspects of this SDK (environments handling, authentication types, different order placement approaches, streaming client subscriptions handling, etc.).

Mapping between branches and SDK versions

Branch Version Description
develop 3.9.* New features, breaking changes
master 3.8.* All new features and hot-fixes
support/v3.7.x 3.7.* Hot fixes only, some features

Packages

No packages published

Languages

  • C# 99.9%
  • Other 0.1%