Skip to content

hummerpj/alpaca-trade-api-csharp

 
 

Repository files navigation

Master build status Develop build status

.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 = new Alpaca.Markets.RestClient(
    KEY_ID, SECRET_KEY, API_URL);

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, SECRET_KEY and API_URL 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.

Use .NET Core configuration

Starting from version 1.1.0 you can use the IConfiguration interface for providing configuration data to constructors. You can read more about the new .NET Core configuration approach in this article. Please also read the appropriate Wiki pages about expected configuration parameters for each constructor.

Assembly signing in NuGet package

Starting from version 1.2.3 and 2.0.0 NuGet packages contains strongly signed assemblies only for .NET Standard 1.6 and 2.0 targets. .NET Framework 4.5 version of Alpaca.Markets.dll is packaged unsigned because a dependent assembly, NATS.Client.dll, also shipped unsigned.

Packages

No packages published

Languages

  • C# 100.0%