Created
August 28, 2018 04:58
-
-
Save yoshyoshi/7e2955007f92be36bce1e2750c53639c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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