Skip to content

Instantly share code, notes, and snippets.

@yoshyoshi
Created August 28, 2018 04:58
Show Gist options
  • Save yoshyoshi/7e2955007f92be36bce1e2750c53639c to your computer and use it in GitHub Desktop.
Save yoshyoshi/7e2955007f92be36bce1e2750c53639c 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