• Stars
    star
    208
  • Rank 185,414 (Top 4 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Contributors Build Codacy Coverage Nuget PVS-Studio

.NET SDK for Alpaca Markets API

Package Stable Pre-release
Alpaca.Markets Nuget Nuget
Alpaca.Markets.Extensions Nuget Nuget

.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. Replace content of the auto-generated Programm.cs file with this code snippet:
using System;
using Alpaca.Markets;
using System.Threading.Tasks;

namespace AlpacaExample
{
    internal static class Program
    {
        private const String KEY_ID = "";

        private const String SECRET_KEY = "";

        public static async Task Main()
        {
            var client = Environments.Paper
                .GetAlpacaTradingClient(new SecretKey(KEY_ID, SECRET_KEY));

            var clock = await client.GetClockAsync();

            if (clock != null)
            {
                Console.WriteLine(
                    "Timestamp: {0}, NextOpen: {1}, NextClose: {2}",
                    clock.TimestampUtc, clock.NextOpenUtc, clock.NextCloseUtc);
            }
        }
    }
}
  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 and the Alpaca.Markets.Tests repository for SDK usage examples. The Wiki pages contain a lot of additional information about different aspects of this SDK (environments handling, authentication types, different order placement approaches, streaming client subscriptions handling, etc.).

Alpaca Data API subscription plans

Alpaca provides 3 different subscription plans for the Data API v2 real-time streaming data: Free, Unlimited, and Business. The first one provides only IEX data and has some subscription limits. Other plans provide full SIP data without data subscription limits. The IAlpacaDataStreamingClient interface and its implementation from SDK provide unified access for both streams.

Use the Environments.Paper.GetAlpacaDataStreamingClient(...) factory method for creating client connected to the Free IEX data stream. For the Unlimited and Business SIP data stream use the Environments.Live.GetAlpacaDataStreamingClient(...) code. So Paper environment for free data tier and Live for paid subscriptions.

Mapping between branches and SDK versions

Branch Version Description Milestone
develop 7.0.x Unstable - experimental, can contain bugs SDK 7.0.x Experimental
master 6.x Stable - good choice for the new development SDK 6.x Stable

Build instructions

  1. Install the latest version of the .NET 7.0 SDK for your OS.
  2. Clone the local version of this repository or your own fork (if you want to make changes).
  3. Build the packages using the dotnet build command running in the root directory of the cloned repo.

Contributors

Thanks a lot for all contributors. See the full list of project supporters in the CONTRIBUTORS file.

More Repositories

1

marketstore

DataFrame Server for Financial Timeseries Data
Go
1,814
star
2

alpaca-trade-api-python

Python client for Alpaca's trade API
Python
1,552
star
3

pylivetrader

Python live trade execution library with zipline interface.
Python
622
star
4

example-scalping

A working example algorithm for scalping strategy trading multiple stocks concurrently using python asyncio
Python
619
star
5

example-hftish

Example Order Book Imbalance Algorithm
Python
615
star
6

Momentum-Trading-Example

An example algorithm for a momentum-based day trading strategy.
Python
568
star
7

alpaca-backtrader-api

Alpaca Trading API integrated with backtrader
Python
524
star
8

alpaca-trade-api-js

Node.js library for Alpaca Trade API.
JavaScript
428
star
9

alpaca-trade-api-go

Go client for Alpaca's trade API
Go
253
star
10

alpaca-py

The Official Python SDK for Alpaca API
Python
249
star
11

pipeline-live

Pipeline Extension for Live Trading
Python
198
star
12

alpaca-ts

A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
TypeScript
144
star
13

Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
136
star
14

pymarketstore

Python driver for MarketStore
Python
103
star
15

user-docs

Documentation for the Alpaca platform.
HTML
72
star
16

samplealgo01

Sample algo
Python
69
star
17

slait

A time-series data cache
Go
47
star
18

roboadvisor

Python
43
star
19

example-portfolio-manager

Simple portfolio management script in python
Python
42
star
20

insomnia-workspace

An Insomnia Workspace for Alpaca API
34
star
21

ribbit-backend

Backend for Ribbit, Broker API Reference App
Go
33
star
22

blogmaterials

Jupyter Notebook
30
star
23

alpaca-postman

Postman collections for Alpaca's APIs
29
star
24

alpaca-zipline

Alpaca riding on a zipline
Python
28
star
25

ribbit-ios

iOS app for Ribbit, Broker API Reference App
Swift
28
star
26

plug-and-play-strategies

Jupyter Notebook
27
star
27

sp100algo

Follow S&P100
Python
16
star
28

alpaca-erasure

Example script to generate Erasure data
Python
15
star
29

slackbot-trader

A Slackbot that can access the Alpaca API
Python
14
star
30

ribbit-android

Android app for Ribbit, Broker API Reference App
Java
12
star
31

alpaca-docs

Developer documentation for Alpaca API's
HTML
10
star
32

broker-fastapi-backend

A reference backend for Alpaca's Broker API utilizing Python & FastAPI
Python
8
star
33

bkdocs

Broker API Documentation
HTML
8
star
34

notebooks

A collection of Jupyter notebooks for getting started with Alpaca
Jupyter Notebook
6
star
35

Alpaca-Flutter-Demo-App

A boilerplate trading application to trade crypto on Alpaca. Made with Flutter and Dart.
C++
5
star
36

alpacadecimal

Similar and compatible with decimal.Decimal, but optimized for Alpaca's data sets.
Go
5
star
37

supertrend_crypto_bot

An Alpaca Live Crypto Trading Bot built with Python!
Python
4
star
38

Triangular-Arbitrage-with-Alpaca-API-s

Python
3
star
39

quantopian-fundamentals-examples

Implementations of algorithms from https://blog.quantopian.com/fundamentals-contest-winners/ using Alpaca's API.
Python
3
star
40

plprofiler

Python
2
star
41

alpaca-discord-bot

Python
1
star
42

go-onfido

Wrapper around the go-onfido-openapi package
1
star
43

alexa-trader-skill

An Alexa skill that can access the Alpaca API
1
star
44

go-onfido-openapi

Golang sdk for onfido. Generated from openapi
Shell
1
star