Exemple #1
0
 public static void ViewTransactions()
 {
     try
     {
         Console.WriteLine("===========================================");
         Console.WriteLine("ACCOUNT - TRANSACTIONS" + "\n");
         AccountViewInput accountViewInput = new AccountViewInput()
         {
             token = token
         };
         var client = new HttpClient();
         client.BaseAddress = new Uri(BASE_URL);
         var    request       = new HttpRequestMessage(HttpMethod.Post, "/api/Account/Transactions");
         string jsonRequest   = JsonConvert.SerializeObject(accountViewInput);
         var    stringContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
         request.Content = stringContent;
         var response       = client.SendAsync(request);
         var responseString = response.Result.Content.ReadAsStringAsync();
         var responseJson   = JsonConvert.DeserializeObject <IList <Transaction> >(responseString.Result);
         foreach (Transaction transaction in responseJson)
         {
             Console.WriteLine("---------------------------------------");
             Console.WriteLine("TYPE: " + transaction.Type);
             Console.WriteLine("SYMBOL: " + transaction.Symbol);
             Console.WriteLine("QUANTITY: " + transaction.Quantity);
             Console.WriteLine("PRICE: " + transaction.Price);
             Console.WriteLine("DATE: " + transaction.Date);
             Console.WriteLine("---------------------------------------" + "\n");
         }
         Console.WriteLine("===========================================");
         Console.WriteLine("Enter to return back to menu...");
         Console.ReadKey();
         ClientMenu();
     }
     catch (Exception)
     {
         Console.WriteLine("Unable to retrieve positions, please try again later.");
         ClientMenu();
     }
 }
Exemple #2
0
 public static void ViewAccountSummary()
 {
     try
     {
         Console.WriteLine("===========================================");
         Console.WriteLine("ACCOUNT - SUMMARY" + "\n");
         AccountViewInput accountViewInput = new AccountViewInput()
         {
             token = token
         };
         var client = new HttpClient();
         client.BaseAddress = new Uri(BASE_URL);
         var    request       = new HttpRequestMessage(HttpMethod.Post, "/api/Account/Summary");
         string jsonRequest   = JsonConvert.SerializeObject(accountViewInput);
         var    stringContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
         request.Content = stringContent;
         var response       = client.SendAsync(request);
         var responseString = response.Result.Content.ReadAsStringAsync();
         var responseJson   = JsonConvert.DeserializeObject <AccountSummaryOutput>(responseString.Result);
         Console.WriteLine("ACCOUNT BALANCE: $" + responseJson.AccountBalance);
         Console.WriteLine("TOTAL INVESTED VALUE: $" + responseJson.TotalInvestedValue);
         Console.WriteLine("TOTAL CURRENT VALUE: $" + responseJson.TotalCurrentValue);
         Console.WriteLine("INVESTMENT GAIN OR LOSS: $" + responseJson.InvestmentGainOrLoss);
         Console.WriteLine("INVESTMENT GAIN OR LOSS PERCENTAGE: " + responseJson.InvestmentGainOrLossPercentage + "%");
         Console.WriteLine("NUMBER OF POSITIONS: " + responseJson.NumberOfPositions);
         Console.WriteLine("===========================================");
         Console.WriteLine("Enter to return back to menu...");
         Console.ReadKey();
         ClientMenu();
     }
     catch (Exception)
     {
         Console.WriteLine("Unable to retrieve account summary, please try again later.");
         ClientMenu();
     }
 }