static void Main(string[] args) { string apiToken = null; if (args.Length > 0) apiToken = args[0]; if (string.IsNullOrWhiteSpace(apiToken)) { Console.WriteLine("Please input your API token:"); apiToken = Console.ReadLine(); Console.WriteLine(); } // Initialize a new instance of the client using (var client = new OneBrokerClient(apiToken)) { // Check whether the API token being used is valid if (!client.IsApiTokenValid()) { Console.WriteLine("Invalid API token."); ShowExitMessage(); return; } // Greet the user, and show the count of open orders and positions Console.WriteLine("Welcome, " + client.Account.GetAccountInfo().Username + "!"); Console.WriteLine(); Console.WriteLine("You currently have:"); Console.WriteLine(" " + client.Orders.GetOpenOrders().Count + " open orders"); Console.WriteLine(" " + client.Positions.GetOpenPositions().Count + " open positions"); } ShowExitMessage(); }
public OneBrokerExchange() { client = new OneBrokerClient(Properties.Settings.Default.OneBrokerApiToken); if (!client.IsApiTokenValid()) { throw new Exception("API token is not valid"); } }
static void Main(string[] args) { string apiToken = null; if (args.Length > 0) { apiToken = args[0]; } if (string.IsNullOrWhiteSpace(apiToken)) { Console.WriteLine("Please input your API token:"); apiToken = Console.ReadLine(); Console.WriteLine(); } // Initialize a new instance of the client using (var client = new OneBrokerClient(apiToken)) { // Check whether the API token being used is valid if (!client.IsApiTokenValid()) { Console.WriteLine("Invalid API token."); ShowExitMessage(); return; } // Greet the user, and show the count of open orders and positions Console.WriteLine("Welcome, " + client.Account.GetAccountInfo().Username + "!"); Console.WriteLine(); Console.WriteLine("You currently have:"); Console.WriteLine(" " + client.Orders.GetOpenOrders().Count + " open orders"); Console.WriteLine(" " + client.Positions.GetOpenPositions().Count + " open positions"); } ShowExitMessage(); }
static void Main(string[] args) { string apiToken = "8257f01472ad92db5f52c527ad3fcaee"; // Initialize a new instance of the client using (var client = new OneBrokerClient(apiToken)) { // Check whether the API token being used is valid if (!client.IsApiTokenValid()) { Console.WriteLine("Invalid API token."); ShowExitMessage(); return; } // Greet the user, and show the count of open orders and positions Console.WriteLine("Welcome, " + client.Account.GetAccountInfo().Username + "!"); Console.WriteLine(); Console.WriteLine("You currently have:"); Console.WriteLine(" " + client.Orders.GetOpenOrders().Count + " open orders"); Console.WriteLine(" " + client.Positions.GetOpenPositions().Count + " open positions"); //============================================ DateTime from = new DateTime(2016, 6, 20); DateTime to = new DateTime(2016, 6, 24); IList <JsonObjects.Bar> bars = client.Markets.GetBars("AAPL", Resolution.Daily, from, to); foreach (JsonObjects.Bar bar in bars) { Console.WriteLine("[" + bar.o + "," + bar.h + "," + bar.l + "," + bar.c); } } ShowExitMessage(); }