Deposit and Withdraw C# not retuning properly

I have tried basically everything and I have determined that this is a bug in the Alpaca code base. Basically, The return for withdraws is not working, can Alpaca or anyone confirm this? Deposits are returning properly. Below is my code.

public async Task GetaccountActivity()
{
try
{
var depositActivitiesRequest = new AccountActivitiesRequest(AccountActivityType.CashDisbursement)
{
Direction = SortDirection.Descending,
PageSize = 10,

            };
            var withdrawActivitiesRequest = new AccountActivitiesRequest(AccountActivityType.CashReceipt)
            {
                Direction = SortDirection.Descending,
                PageSize = 1,
               
            };
  

            var myDate = DateTime.Now;
            int month = 1;

            while(month < 13)
            {
                var startOfMonth = new DateTime(2021, month, 1);
                var endOfMonth = startOfMonth.AddMonths(1).AddDays(-1);
                var deposits = await _client.ListAccountActivitiesAsync(depositActivitiesRequest.SetInclusiveTimeInterval(startOfMonth, endOfMonth));
                var withdraws = await _client.ListAccountActivitiesAsync(withdrawActivitiesRequest);
                
                var netDeposits = deposits.Sum(deposit => deposit.NetAmount);
                var netWithdraws = withdraws.Sum(withdraw => withdraw.NetAmount);
                
                var amount = netDeposits - netWithdraws;

                month++;
                //return (decimal)amount;
            }
            

            //var amount = netDeposits - netWithdraws;

            return 0.00m;
            
        }
        catch (Exception ex)
        {
            Output.Console(ex.Message);
        }
        return 0;
    }

Question. I see that depositActivitiesRequest is defined as

var depositActivitiesRequest = new AccountActivitiesRequest(AccountActivityType.CashDisbursement)

I don’t see that withdrawActivitiesRequest is defined. Maybe just not copied into the forum post, but maybe start there?

var withdrawActivitiesRequest = new AccountActivitiesRequest(AccountActivityType.CashReceipt)
{
Direction = SortDirection.Descending,
PageSize = 1,

        };

It’s defined, I have tried everything and had some other coders look, we concluded that this is an internal bug from Alpaca. The HTTP call works… so that’s my alternative.

Looks like the underlying codes for activity types were changed and these changes have not been reflected in the SDK. I’ll open the GitHub issue and prepare an updated version soon.

Great thank you. I’m just relieved, I was going crazy…

The 4.x and 5.0 versions with the fix available on the NuGet now. 5.0.4 has breaking change - enum items are renamed for better mapping between Alpaca and SDK namings.

Tested, and it works! thanks for the update.