'c# Api RestClient (namespace name "RestClient" could not be found )
I'm trying to establish a connection to my banker's server using RestClient API. The code they provided is below, but the Restclient is not working. I'm not going to post the API_key here but How do I fix this issue. In the C# program, RestClient is underlined with this error message: "C20246: The type or namespace name 'RestClient could not be found." I installed RestSharp and put using RestSharp; in the top then a lot of errors CS1061 saying RestClient does not contain definition.
private string API_KEY = "REPLACEME";
private string API_SECRET = "REPLACEME";
private string API_URL = "https://paper-api.alpaca.markets";
private string symbol = "SPY";
private Decimal scale = 200;
private RestClient restClient;
private Guid lastTradeId = Guid.NewGuid();
private List<Decimal> closingPrices = new List<Decimal>();
public void Run()
{
restClient = new RestClient(API_KEY, API_SECRET, API_URL);
// First, cancel any existing orders so they don't impact our buying power.
var orders = restClient.ListOrdersAsync().Result;
foreach (var order in orders)
{
restClient.DeleteOrderAsync(order.OrderId);
}
// Figure out when the market will close so we can prepare to sell beforehand.
var calendars = restClient.ListCalendarAsync(DateTime.Today).Result;
var calendarDate = calendars.First().TradingDate;
var closingTime = calendars.First().TradingCloseTime;
closingTime = new DateTime(calendarDate.Year, calendarDate.Month, calendarDate.Day, closingTime.Hour, closingTime.Minute, closingTime.Second);
Console.WriteLine("Waiting for market open...");
AwaitMarketOpen();
Console.WriteLine("Market opened.");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
