Skip to content

Instantly share code, notes, and snippets.

@umitanuki
Last active May 21, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save umitanuki/11188cb31932419a40b2a09a36380505 to your computer and use it in GitHub Desktop.
Save umitanuki/11188cb31932419a40b2a09a36380505 to your computer and use it in GitHub Desktop.
using System;
using System.Configuration;
using Alpaca.Markets;
namespace example
{
class Program
{
static void Main(string[] args)
{
var client = new Alpaca.Markets.RestClient(
"APCA-API-KEY-ID", "APCA-API-SECRET-KEY");
var clock = client.GetClockAsync().Result;
if (clock != null)
{
Console.WriteLine(
"Timestamp: {0}, NextOpen: {1}, NextClose: {2}",
clock.Timestamp, clock.NextOpen, clock.NextClose);
}
var account = client.GetAccountAsync().Result;
Console.Write("portfolio_value = {0}", account.PortfolioValue);
if (clock.IsOpen) {
var order = client.PostOrderAsync("AAPL", 1,
OrderSide.Buy, OrderType.Market,
TimeInForce.Day).Result;
Console.Write("Ordered 1 share of AAPL at {0}", order.SubmittedAt);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment