This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| #include <unordered_map> | |
| #include <random> | |
| #include <chrono> | |
| #include <cstdint> | |
| #include <limits> | |
| #include <cstring> | |
| #include <cstdlib> | |
| #include <cstdio> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdint> | |
| #include <cstring> | |
| #include <cstdio> | |
| #include <random> | |
| #include <limits> | |
| #include <algorithm> | |
| #include <array> | |
| #include <vector> | |
| #include <cmath> | |
| #include <map> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdint> | |
| #include <cstring> | |
| #include <cstdio> | |
| #include <random> | |
| #include <limits> | |
| #include <algorithm> | |
| #include <array> | |
| #include <vector> | |
| #include <cmath> | |
| #include <map> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
NewerOlder