Bad request with the getting started example

var client = Environments.Paper
.GetAlpacaCryptoDataClient(new SecretKey(API_KEY, API_SECRET));

    var symbol = "BTCUSD";
    var start = DateTime.Today.AddDays(-1); // Yesterday
    var end = DateTime.Today; // Today
    var timeframe = BarTimeFrame.Day; // Denotes daily bars

    var bars = await client.ListHistoricalBarsAsync(
    new HistoricalCryptoBarsRequest(symbol, start, end, timeframe));

This is from the getting started documentation but i keep gettin a 400( Bad Requqest) error when I try to run it. Any help for a newbie appreciated.

1 Like

If you use the latest .NET SDK version you should use updated cryptocurrency symbol names. Instead of "BTCUSD", you should use "BTC/USD" (the same is true for all other cryptocurrencies).

Just one side note - if you need only today&yesterday daily bars you can use the ListSnapshotsAsync' method instead of the ListHistoricalBarsAsyncmethod. And you can request all cryptocurrencies supported by Alpaca (with correct symbol names) using theListAssetsAsync` method with proper filter.