Today is August 15th 2022.
Let's say I'd like to know the treasury security SOMA holdings that have matured so far this month as well as the total that will mature this month.
Here's one approach I've used using PowerShell and the New York Fed API.
Run a query for the 'as of' date right before August:
$result = Invoke-RestMethod ('https://markets.newyorkfed.org/api/soma/tsy/get/all/asof/{0}.json' -f '2022-07-27')
Show the securities maturing in August:
$result.soma.holdings |
Where-Object maturityDate -GE '2022-08-01' |
Where-Object maturityDate -LE '2022-08-31' |
Sort-Object maturityDate |
Format-Table *
Show the total amount maturing in August:
'{0:C0}' -f (
$result.soma.holdings |
Where-Object maturityDate -GE '2022-08-01' |
Where-Object maturityDate -LE '2022-08-31' |
Measure-Object -Property parValue -Sum).Sum
$194,344,004,700
'{0:C0}' -f (
$result.soma.holdings |
Where-Object maturityDate -GE '2022-08-01' |
Where-Object maturityDate -LE '2022-08-15' |
Measure-Object -Property parValue -Sum).Sum
$128,597,828,300
Question
Is this the best approach? Or is there another recommended method?