Skip to content

Instantly share code, notes, and snippets.

$month = '2022-12-'
$rate = 0.83
$dates = @(
'2022-11-30'
'2022-12-07'
'2022-12-14'
'2022-12-21'
# ----------------------------------------------------------------------
# UMBS
$result_soma_mbs_a = Invoke-RestMethod 'https://markets.newyorkfed.org/api/soma/mbs/get/asof/2022-11-23.json'
# $result_soma_mbs_a.soma.holdings | Where-Object securityDescription -match 'UMBS' | Format-Table *
$umbs_a = ($result_soma_mbs_a.soma.holdings | Where-Object securityDescription -match 'UMBS' | Measure-Object -Property currentFaceValue -Sum).Sum
function get-rrp-award-rate ()
{
if ((Test-Path 'rrp-award-rate.csv') -eq $false)
{
Write-Host 'Downloading' -ForegroundColor Yellow
$result = Invoke-RestMethod 'https://fred.stlouisfed.org/graph/fredgraph.csv?id=RRPONTSYAWARD'
$result | Out-File 'rrp-award-rate.csv'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# $result_as_of_dates = Invoke-RestMethod https://markets.newyorkfed.org/api/soma/asofdates/list.json
#
# $result_as_of_dates.soma.asOfDates | Sort-Object | Select-Object -Last 20
# $dates = @(
# '2022-11-02'
# '2022-11-09'
# '2022-11-16'
# '2022-11-23'
# $result = Invoke-RestMethod 'https://home.treasury.gov/resource-center/data-chart-center/interest-rates/daily-treasury-rates.csv/2022/all?type=daily_treasury_yield_curve&field_tdr_date_value=2022&page&_format=csv'
$year = Get-Date -Format 'yyyy'
$result = Invoke-RestMethod ('https://home.treasury.gov/resource-center/data-chart-center/interest-rates/daily-treasury-rates.csv/{0}/all?type=daily_treasury_yield_curve&field_tdr_date_value={0}&page&_format=csv' -f $year)
$table = $result | ConvertFrom-Csv | Sort-Object Date
function color ($a, $b)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jdehorty
// @version=5
indicator('cal-jdehorty-alt', overlay=true, scale=scale.none, max_lines_count=500)
import jdehorty/EconomicCalendar/1 as calendar
// ==================
// ==== Settings ====
$date = '2022-01-01'
$result = Invoke-RestMethod ('https://markets.newyorkfed.org/api/rp/reverserepo/propositions/search.json?startDate={0}' -f $date)
$items = $result.repo.operations | Sort-Object operationDate | Where-Object note -NotMatch 'Small Value Exercise'
$table = $items | ForEach-Object {
[pscustomobject]@{
<mxfile host="app.diagrams.net" modified="2022-11-03T02:59:37.641Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" etag="VB3dl1hTGfbvLUdXV9Yb" version="20.5.1" type="device"><diagram id="9-wZCS-z9ZMLKD7XJHV1" name="Page-1">5XxXk6xGtu6v0eNEYAt4xPvCQ8EbrvAeCvPrb9La0kjaW3fOiSPN3BO3OrqbSiDNl8t8a5HJTyjbHeIcj6U+ZHn7EwJlx08o9xOCwA8CBf/ukvNbCYU8fi4p5ir7VvbPAqe68m+F0LfSrcry5XcXrsPQrtX4+8J06Ps8XX9XFs/zsP/+svfQ/r7VMS7y7wqcNG6/Lw2qbC1/LiVx6J/lUl4V5S8tw9C3M138y8XfCpYyzob9N0Uo/xPKzsOw/nzUHWze3uj9gsvP9wl/cvbXjs15v/5XbpD6yHGPQH9vq/JOrPMNfZ7/+KWaT9xu30b8rbfr+QsE87D1WX7XAv2EMntZrbkzxul9dgezDsrKtWvBNxgcft+rX1rI5zU/flP0rZdiPnT5Op/gkm9nfwHsm8ig377u/4T/V+kofwP94xfk429TXvxa8z9RAQffgPlvgPQ9Rt3Q5+fXJM9Nvt5yBSD6Djgw4+N9uHUtna7DDOC5UaiAdGlxkrfmsFRrNfTgkmRY16H7zQV0WxX3iXX4A8DDtrZVn7O/yjv016COob+H/VeMf4M7+kPY/ybU0X8tmb8AXHVfWvyv0W3vE0ycNsWXULNDe88Kl+XveGvXP4U/XsafsX5Xx60IzFeD9C+l0C8ld1XxGv+E0j9/RYR6zIufkBsAqgZ/MJq2nCZS7IJmaIsG38B/GgxFQHaWp+lBZA7d5Y8Q/OqBUIa//Ib/PC5C0f46jqVz