zombomb220 / alpaca-trade-api-csharp

C# SDK for Alpaca Trade API https://docs.alpaca.markets/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET SDK for Alpaca Markets API

.NET Core Usage Example

  1. Create new console application using command dotnet new console in new empty folder.
  2. Add reference for Alpaca .NET SDK using dotnet add package Alpaca.Markets command.
  3. Change Main method in auto-generated Programm.cs file using next code snippet:
var client = new Alpaca.Markets.RestClient(
    KEY_ID, SECRET_KEY, new Uri(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 data from web console.
  2. Run sample application using dotnet run command and check output

Use .NET Core configuration

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

About

C# SDK for Alpaca Trade API https://docs.alpaca.markets/

License:Apache License 2.0


Languages

Language:C# 100.0%