Skip to content

Instantly share code, notes, and snippets.

View jweinst1's full-sized avatar
🎯
Focusing

Josh Weinstein jweinst1

🎯
Focusing
View GitHub Profile
@jweinst1
jweinst1 / rsi_sliding_window.js
Created April 2, 2026 00:44
google app script sliding window function
/**
* Calculates RSI using the last N closing prices up to the current row.
* @param {number} period The RSI period (e.g. 7, 14)
* @param {range} priceRange The full range of closing prices (e.g. C2:C)
* @return The RSI value for the current row.
* @customfunction
*/
function RSI(period, priceRange) {
if (!priceRange || !Array.isArray(priceRange)) {
return "Invalid price range";
@jweinst1
jweinst1 / rise_dips_closing.py
Last active March 26, 2026 06:57
analyze closing prices of VOO for RSI
import csv
from typing import Dict, List, Optional
import math # only for sqrt in correlation (pure basics)
class StockCloses:
def __init__(self, closes, date_stamps):
self.closes = closes
self.date_stamps = date_stamps
@jweinst1
jweinst1 / sheets_transfer.js
Created March 16, 2026 23:39
transfer prices cells in google sheets
function freezeCurrentPrices() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sourceSheet = ss.getSheetByName('Live Data');
const destSheet = ss.getSheetByName('Static Archive');
// Assume your GOOGLEFINANCE array is B2:C (headers + data)
const sourceRange = sourceSheet.getRange('B2:C' + sourceSheet.getLastRow());
const values = sourceRange.getValues(); // evaluates formulas → gets current numbers
// Paste to destination (same size, values only)
@jweinst1
jweinst1 / rsi.js
Last active March 26, 2026 08:15
rsi function in google script
/**
* Calculates the Relative Strength Index (RSI) for the most recent prices in the array.
* @param {number[]} prices - Array of closing prices (oldest first).
* @param {number} period - Lookback period (e.g., 14). Only the last (period + 1) prices are used.
* @return {number} The RSI value based on the most recent period.
* @customfunction
*/
function RSI(prices, period = 14) {
if (!prices || !Array.isArray(prices) || prices.length < period + 1) {
return "Not enough data";
@jweinst1
jweinst1 / rsiscript.js
Created March 16, 2026 00:26
google app script RSI email alert
function checkRSIAndAlert() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Change to your sheet name
// RSI cell - e.g., if your RSI is in J25 (adjust!)
const rsiCell = sheet.getRange("J25");
const currentRSI = rsiCell.getValue();
// Your thresholds
const overbought = 70;
const oversold = 30;
@jweinst1
jweinst1 / string_breaker.cpp
Created February 27, 2026 23:39
break strings by regions C++
#include <iostream>
#include <string>
#include <regex>
#include <vector>
#include <chrono>
#include <utility> // For std::pair
int main() {
// Generate approximately 10 MB of in-memory text data
const size_t target_size = 10 * 1024 * 1024; // 10 MB
@jweinst1
jweinst1 / multi-hash-graph.cpp
Last active February 22, 2026 10:35
design of multi map hash map for graph db
#include <iostream>
#include <vector>
#include <unordered_map>
#include <random>
#include <chrono>
#include <cstdint>
#include <limits>
#include <cstring>
#include <cstdlib>
#include <cstdio>
@jweinst1
jweinst1 / hash_byte_arr.cpp
Created February 22, 2026 00:18
C++ hash variable sized byte array
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <random>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
#include <map>
@jweinst1
jweinst1 / per_region_quantize.cpp
Last active February 20, 2026 10:02
region specific pattern of quantization for floats
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <random>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
#include <map>
@jweinst1
jweinst1 / mean_bit_set.cpp
Created February 16, 2026 21:28
calculates mean via pop count approximation
struct ConstexprBitset64 {
uint64_t block = 0;
constexpr void set(size_t idx) {
block |= uint64_t{1} << idx;
}
constexpr void clear(size_t idx) {
block &= ~(uint64_t{1} << idx);
}