repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_docs_app_schema.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:19.992612 | import pytest
pytest.importorskip("flask")
from docs.app import app
@pytest.fixture
def client():
app.testing = True
with app.test_client() as test_client:
yield test_client
def test_docs_api_without_schema_keeps_existing_behavior(client):
response = client.post(
"/api/repair-json",
... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_parse_object.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.081138 | from src.json_repair.json_repair import repair_json
def test_parse_object():
assert repair_json("{}", return_objects=True) == {}
assert repair_json('{ "key": "value", "key2": 1, "key3": True }', return_objects=True) == {
"key": "value",
"key2": 1,
"key3": True,
}
assert repair_... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_parse_string.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.114497 | from io import StringIO
import pytest
from src.json_repair.json_parser import JSONParser
from src.json_repair.json_repair import repair_json
from src.json_repair.parse_string import (
StringParseState,
_brace_before_code_fence_belongs_to_string,
_quoted_object_member_follows,
_scan_string_body,
_s... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_performance.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.359335 | import os
import pathlib
import pytest
from src.json_repair import repair_json
path = pathlib.Path(__file__).parent.resolve()
CI = os.getenv("CI") is not None
correct_json = (path / "valid.json").read_text()
incorrect_json = (path / "invalid.json").read_text()
schema_perf = {
"type": "array",
"items": {
... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_strict_mode.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.768592 | import pytest
from src.json_repair.json_repair import repair_json
def test_strict_rejects_multiple_top_level_values():
with pytest.raises(ValueError, match="Multiple top-level JSON elements"):
repair_json('{"key":"value"}["value"]', strict=True)
def test_strict_duplicate_keys_inside_array():
payloa... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_schema_repairer.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.769248 | import copy
from typing import Any, ClassVar
import pytest
from src.json_repair import repair_json
from src.json_repair.schema_repair import (
SchemaRepairer,
load_schema_model,
normalize_missing_values,
normalize_schema_repair_mode,
schema_from_input,
)
from src.json_repair.utils.constants import... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_type_inference.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.769852 | from pathlib import Path
import pytest
mypy_api = pytest.importorskip("mypy.api")
SNIPPET_TEMPLATE = """\
from json_repair import JSONReturnType
from json_repair.json_repair import repair_json
{assignment}
"""
def _run_type_check(tmp_path: Path, assignment: str) -> tuple[int, str, str]:
snippet = tmp_path / "... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_schema_parser_paths.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.770381 | import pytest
from src.json_repair import repair_json
from src.json_repair.json_parser import JSONParser
from src.json_repair.schema_repair import SchemaRepairer
from src.json_repair.utils.json_context import ContextValues
def parse_object_direct(raw, schema, *, strict=False, context=None):
parser = JSONParser(r... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_repair_json_from_file.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.770991 | import os
import pathlib
import tempfile
from io import StringIO
from src.json_repair.json_repair import from_file, load
def test_load_repairs_from_current_file_position():
prefix = '{"stale": true}\n'
raw = prefix + '{"key": }'
for skip_json_loads in [False, True]:
fd = StringIO(raw)
fd... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_schema_guided_parse.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.771570 | from typing import cast
import pytest
from src.json_repair import repair_json
def repair_with_schema(raw, schema, **kwargs):
return repair_json(raw, schema=schema, skip_json_loads=True, return_objects=True, **kwargs)
def _two_string_schema() -> dict:
pytest.importorskip("jsonschema")
pydantic = pytest... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/test_repair_json_cli.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:20.880823 | import io
import json
import os
import tempfile
from pathlib import Path
from unittest.mock import patch
import pytest
from src.json_repair.json_repair import cli
def test_cli(capsys):
# Create a temporary file
temp_fd, temp_path = tempfile.mkstemp(suffix=".json")
_, tempout_path = tempfile.mkstemp(suff... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/utils/test_pattern_properties.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:21.636932 | from src.json_repair.utils.pattern_properties import match_pattern_properties
def test_match_pattern_properties_exact_anchor_contains():
pattern_properties = {
"^abc$": {"name": "exact"},
"bc": {"name": "contains"},
}
matched, unsupported = match_pattern_properties(pattern_properties, "ab... |
mangiucugna/json_repair | https://github.com/mangiucugna/json_repair | null | null | null | null | 4,698 | null | null | mit | null | null | null | null | null | null | null | tests/utils/test_string_file_wrapper.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:26.143430 | import pytest
from src.json_repair.utils.string_file_wrapper import StringFileWrapper
def test_string_file_wrapper_handles_multibyte(tmp_path):
text = "\u0800"
file_path = tmp_path / "multibyte.json"
file_path.write_text(text, encoding="utf-8")
with file_path.open("r", encoding="utf-8") as handle:
... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/currencies_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.796721 | """Currencies Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.utilities import logger_model
logger = logger_model.get_logger()
# pylint: disable=comparison-with-itself,too-many-locals,protected-access
def determine_currencies(
statement_currencies: pd.DataFrame, historical_curren... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/economics/gmdb_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.872462 | """GMBD Model"""
import pandas as pd
GMD_LOCATION = "https://github.com/KMueller-Lab/Global-Macro-Database/blob/main/data/final/data_final.dta?raw=True"
def collect_global_macro_database_dataset(
gmd_location: str = GMD_LOCATION,
) -> pd.DataFrame:
"""
Collect and transform the Global Macro Database dat... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/economics/oecd_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.875281 | """OECD Model"""
__docformat__ = "google"
from io import StringIO
import pandas as pd
import requests
# pylint: disable=too-many-lines
BASE_URL = "https://sdmx.oecd.org/public/rest/data/"
EXTENSIONS = "?dimensionAtObservation=AllDimensions&format=csvfilewithlabels"
CODE_TO_COUNTRY = {
"AGO": "Angola",
"A... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.904508 | """FinanceToolkit Initialization"""
# flake8: noqa
from .toolkit_controller import Toolkit
from .economics.economics_controller import Economics
from .fixedincome.fixedincome_controller import FixedIncome
from .discovery.discovery_controller import Discovery
from .portfolio.portfolio_controller import Portfolio
|
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/discovery/discovery_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.905059 | """Discovery Model"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.fmp_model import get_financial_data
from financetoolkit.utilities import error_model
def get_instruments(
api_key: str,
query: str,
search_method: str = "name",
user_subscription: str = "Free",
) -> pd.DataFrame:... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/discovery/discovery_controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:29.971065 | """Discovery Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit import fmp_model
from financetoolkit.discovery import discovery_model
from financetoolkit.utilities import logger_model
from financetoolkit.utilities.error_model import handle_errors
# pylint: disable=too-many-instance-attribute... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/bond_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.358944 | """Bond Model Module"""
import numpy as np
def get_bond_price(
par_value: float,
coupon_rate: float,
years_to_maturity: float,
yield_to_maturity: float,
frequency: int = 1,
):
"""
Calculate the price of a bond.
Args:
par_value (float): The face value of the bond.
coup... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/derivative_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.378194 | """Derivative Models"""
import numpy as np
from scipy.stats import norm
def get_black_price(
forward_rate: float,
strike_rate: float,
volatility: float,
years_to_maturity: float,
risk_free_rate: float,
notional: float = 10_000_000,
is_receiver: bool = True,
) -> tuple[float, float]:
"... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/fed_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.490932 | """FED Model"""
__docformat__ = "google"
import pandas as pd
BASE_URL = "https://markets.newyorkfed.org/read"
EXTENSIONS_1 = "?startDt=2000-12-01&eventCodes="
CODES = {
"EFFR": "500",
"OBFR": "505",
"TGCR": "510",
"BGCR": "515",
"SOFR": "520",
"SOFRAI": "525",
}
EXTENSIONS_2 = "&productCode=... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/ecb_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.499391 | """ECB Model"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.fixedincome.helpers import collect_ecb_data
def get_main_refinancing_operations() -> pd.DataFrame:
"""
Get the Main Refinancing Operations from the European Central Bank over
time. The Main Refinancing Operations are the r... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/fred_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.500854 | """FRED Model"""
import io
import numpy as np
import pandas as pd
import requests
def get_fred_data(fred_series_id: str | list):
"""
Retrieves data from the Federal Reserve Economic Data (FRED) API for the specified series ID(s).
Args:
fred_series_id (str or list): The series ID(s) of the data ... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/euribor_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.510020 | """ECB Model"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.fixedincome.helpers import collect_ecb_data
def get_euribor_rate(maturity: str, nominal: bool = True) -> pd.DataFrame:
"""
Get the Main Refinancing Operations from the European Central Bank over
time. The Main Refinancing ... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fmp_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.521032 | """FMP Module"""
__docformat__ = "google"
import importlib.util
import threading
import time
from datetime import datetime, timedelta
from http.client import RemoteDisconnected
from io import StringIO
from urllib.error import HTTPError, URLError
import numpy as np
import pandas as pd
import requests
from tqdm impor... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.569090 | """Helpers"""
__docformat__ = "google"
import pandas as pd
BASE_URL = "https://data-api.ecb.europa.eu/service/data/"
EXTENSIONS = "?format=csvdata"
def collect_ecb_data(
ecb_data_string: str, dataset: str, frequency: str = "D"
) -> pd.DataFrame:
"""
Collect the data from the ECB API and return it as a ... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fixedincome/fixedincome_controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.631384 | """Fixed Income Module"""
__docformat__ = "google"
import re
from datetime import datetime, timedelta
import numpy as np
import pandas as pd
from financetoolkit.economics import oecd_model
from financetoolkit.fixedincome import (
bond_model,
derivative_model,
ecb_model,
euribor_model,
fed_model... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/fundamentals_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.681619 | """Fundamentals Model"""
import importlib.util
import threading
import time
import numpy as np
import pandas as pd
from tqdm import tqdm
from financetoolkit import fmp_model, normalization_model, yfinance_model
from financetoolkit.utilities import error_model, logger_model
# Check if yfinance is installed
yf_spec =... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:30.934327 | """Helpers Module"""
__docformat__ = "google"
import contextlib
import inspect
import re
import warnings
from functools import wraps
import numpy as np
import pandas as pd
import requests
from financetoolkit.utilities import logger_model
logger = logger_model.get_logger()
# pylint: disable=comparison-with-itself... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/historical_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.000928 | """Historical Module"""
__docformat__ = "google"
import importlib.util
import threading
import time
import numpy as np
import pandas as pd
from tqdm import tqdm
from financetoolkit import fmp_model, yfinance_model
from financetoolkit.utilities import error_model, logger_model
logger = logger_model.get_logger()
# ... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/altman_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.074559 | """Altman Module"""
__docformat__ = "google"
import pandas as pd
def get_working_capital_to_total_assets_ratio(
working_capital: float | pd.Series | pd.DataFrame,
total_assets: float | pd.Series | pd.DataFrame,
) -> float | pd.Series | pd.DataFrame:
"""
The Working Capital to Total Assets Ratio is a... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/enterprise_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.114155 | """Enterprise Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.ratios import valuation_model
def get_enterprise_value_breakdown(
share_price: float | pd.Series,
shares_outstanding: float | pd.Series,
total_debt: float | pd.Series,
minority_interest: float | pd.Series,
... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/growth_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.141045 | """Growth Model"""
__docformat__ = "google"
import pandas as pd
# pylint: disable=too-many-locals
def get_present_value_of_growth_opportunities(
weighted_average_cost_of_capital: pd.DataFrame,
earnings_per_share: pd.DataFrame,
close_prices: pd.DataFrame,
calculate_daily: bool = False,
) -> pd.DataF... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.170599 | """Models Helpers Module"""
__docformat__ = "google"
import pandas as pd
# pylint: disable=protected-access
PERIOD_TRANSLATION: dict[str, str] = {
"weekly": "W",
"monthly": "M",
"quarterly": "Q",
"yearly": "Y",
}
def determine_within_historical_data(
daily_historical_data: pd.DataFrame,
):
... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/dupont_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.187671 | """Dupont Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.ratios import efficiency_model, profitability_model, solvency_model
def get_dupont_analysis(
net_income: pd.Series,
total_revenue: pd.Series,
average_total_assets: pd.Series,
average_total_equity: pd.Series,
) -> p... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/intrinsic_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.210025 | """Intrinsic Value Module"""
__docformat__ = "google"
import pandas as pd
# pylint: disable=too-many-locals
def get_intrinsic_value(
cash_flow: float,
growth_rate: float,
perpetual_growth_rate: float,
weighted_average_cost_of_capital: float,
cash_and_cash_equivalents: float,
total_debt: flo... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/models_controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.283323 | """Models Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.helpers import calculate_growth
from financetoolkit.models import (
altman_model,
dupont_model,
enterprise_model,
growth_model,
helpers,
intrinsic_model,
piotroski_model,
wacc_model,
)
from financetoo... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/piotroski_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.538486 | """Altman Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit import helpers
from financetoolkit.ratios import (
efficiency_model,
liquidity_model,
profitability_model,
solvency_model,
)
def get_return_on_assets_criteria(
net_income: float | pd.Series | pd.DataFrame,
... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/normalization_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.690796 | """Normalization Module"""
__docformat__ = "google"
import shutil
from importlib import resources
from pathlib import Path
import numpy as np
import pandas as pd
from financetoolkit.utilities import cache_model, logger_model
logger = logger_model.get_logger()
# pylint: disable=too-many-locals, broad-exception-cau... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/models/wacc_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.720265 | """Weighted Average Cost of Capital Module"""
__docformat__ = "google"
import numpy as np
import pandas as pd
from financetoolkit.performance import performance_model
from financetoolkit.ratios import profitability_model, valuation_model
# pylint: disable=too-many-locals
def get_cost_of_equity(
risk_free_rate... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/options/black_scholes_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.750182 | """Black Scholes Model"""
__docformat__ = "google"
import numpy as np
import pandas as pd
from scipy.stats import norm
def get_d1(
stock_price: float | pd.Series,
strike_price: float | pd.Series,
risk_free_rate: float | pd.Series,
volatility: float | pd.Series,
time_to_expiration: float | pd.Ser... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/options/binomial_trees_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.750753 | """Binomial Trees Model"""
__docformat__ = "google"
import numpy as np
import pandas as pd
# pylint: disable=too-many-locals
def calculate_up_and_down_movements(volatility: float, time_delta: float):
"""
Calculates the up and down movements in the binomial tree.
Args:
volatility (float): the v... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/options/greeks_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.756785 | """Black Scholes Greeks Model"""
__docformat__ = "google"
import numpy as np
from scipy.stats import norm
from financetoolkit.options import black_scholes_model
def get_delta(
stock_price: float,
strike_price: float,
time_to_expiration: float,
risk_free_rate: float,
volatility: float,
divid... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/options/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.790693 | """Option Helpers Module"""
__docformat__ = "google"
import pandas as pd
from financetoolkit.utilities import logger_model
logger = logger_model.get_logger()
# pylint: disable=too-many-locals
def define_strike_prices(
tickers: list[str],
stock_price: pd.DataFrame,
strike_step_size: int,
strike_pr... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/options/options_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:31.920983 | """Options Model"""
import pandas as pd
import yfinance as yf
def get_option_expiry_dates(ticker: str) -> list[str]:
"""
Retrieve available option expiry dates for a given ticker symbol.
Args:
ticker (str): The ticker symbol for which to fetch option expiry dates.
Returns:
list[str]... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/performance/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.147012 | """Performance Helpers Module"""
__docformat__ = "google"
import inspect
import pandas as pd
from financetoolkit.utilities import logger_model
logger = logger_model.get_logger()
# pylint: disable=protected-access
PERIOD_TRANSLATION: dict[str, str | dict[str, str]] = {
"intraday": {
"1min": "h",
... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/performance/performance_controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.329915 | """Performance Module"""
__docformat__ = "google"
import warnings
import pandas as pd
from financetoolkit.helpers import calculate_growth, handle_portfolio
from financetoolkit.performance import performance_model
from financetoolkit.performance.helpers import (
determine_within_dataset,
determine_within_his... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/performance/performance_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.351894 | """Performance Model"""
import io
import urllib.request
import warnings
import zipfile
import numpy as np
import pandas as pd
import requests
from scipy.stats import linregress
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# This is meant for calculations in which a... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/portfolio/helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.391181 | """Helpers Module"""
import re
import pandas as pd
import yaml
# pylint: disable=too-few-public-methods
class Style:
"""
This class is meant for easier styling throughout the application where it
adds value (e.g. to create a distinction between an error and warning).
"""
RED = "\033[91m"
G... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/portfolio/overview_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.391935 | """Overview Model"""
import numpy as np
import pandas as pd
# pylint: disable=too-many-locals
# Matches up with currency codes EUR, USD, JPY etc. This is used for
# Yahoo Finance's notation of currencies. E.g. EURUSD=X
CURRENCY_CODE_LENGTH = 3
def create_transactions_overview(
portfolio_volume: pd... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/portfolio/portfolio_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.393777 | """Portfolio Model"""
import os
import numpy as np
import pandas as pd
from tqdm import tqdm
from financetoolkit.portfolio import helpers
from financetoolkit.utilities import logger_model
logger = logger_model.get_logger()
# pylint: disable=too-many-locals
# Matches up with currency codes EUR, USD, JPY etc. This ... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/portfolio/portfolio_controller.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.440207 | """Portfolio Module"""
import os
import shutil
from importlib import resources
import pandas as pd
from financetoolkit.portfolio import helpers, overview_model, portfolio_model
from financetoolkit.toolkit_controller import Toolkit
from financetoolkit.utilities import logger_model
logger = logger_model.g... |
JerBouma/FinanceToolkit | https://github.com/JerBouma/FinanceToolkit | null | null | null | null | 4,695 | null | null | mit | null | null | null | null | null | null | null | financetoolkit/ratios/efficiency_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:32.606069 | """Efficiency Module"""
__docformat__ = "google"
import pandas as pd
def get_asset_turnover_ratio(
sales: pd.Series,
average_total_assets: pd.Series,
) -> pd.Series:
"""
Calculate the asset turnover ratio, an efficiency ratio that measures how
efficiently a company uses its assets to generate sa... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.363091 | """Account control-plane domain — public exports."""
from .enums import AccountStatus, FeedbackKind, QuotaSource
from .models import (
AccountChangeSet,
AccountMutationResult,
AccountPage,
AccountQuotaSet,
AccountRecord,
AccountUsageStats,
QuotaWindow,
RuntimeSnapshot,
)
from .commands ... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/commands.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.364189 | """Command / query objects for the account control plane."""
from typing import Any
from pydantic import BaseModel, Field
from .enums import AccountStatus
class AccountUpsert(BaseModel):
"""Create-or-replace command for a single account.
Only ``token`` is required; all other fields use safe defaults.
... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/backends/factory.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.376054 | """Account repository factory — selects the backend from startup env."""
import os
from pathlib import Path
from typing import Any
from urllib.parse import urlsplit, urlunsplit
from app.platform.paths import data_path
from ..repository import AccountRepository
_SUPPORTED_BACKENDS = {"local", "redis", "mysql", "postg... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/backends/local.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.382251 | """SQLite account repository (WAL mode, single-process default backend)."""
import asyncio
import json
import sqlite3
from contextlib import closing
from pathlib import Path
from typing import Any
from app.platform.runtime.clock import now_ms
from ..commands import AccountPatch, AccountUpsert, BulkReplacePoolCommand,... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/backends/redis.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.384736 | """Redis account repository.
Layout:
accounts:rev — STRING global revision counter
accounts:record:<token> — HASH flattened AccountRecord fields
accounts:pool:<pool> — SET token members per pool (live)
accounts:revision_log — ZSET token → revision (for scan_change... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/enums.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.423976 | """Control-plane account enumerations."""
from enum import IntEnum, StrEnum
class AccountStatus(StrEnum):
"""Persistent lifecycle status of an account record."""
ACTIVE = "active"
COOLING = "cooling"
EXPIRED = "expired"
DISABLED = "disabled"
class QuotaSource(IntEnum):
"""Reliability o... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/backends/sql.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:35.425251 | """Shared SQLAlchemy-based backend for MySQL and PostgreSQL.
Both dialects share the same table schema and query logic;
only the DDL fragments and upsert syntax differ.
"""
import json
import os
import ssl
from threading import Lock
from typing import Any
from urllib.parse import parse_qsl, urlencode, urlparse, urlun... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/invalid_credentials.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.397327 | """Shared handling for upstream invalid-credential failures."""
from typing import TYPE_CHECKING
from app.platform.errors import UpstreamError
from app.platform.logging.logger import logger
from app.platform.runtime.clock import now_ms
from .commands import AccountPatch
from .enums import AccountStatus, FeedbackKind... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/scheduler.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.402741 | """Background scheduler for periodic account quota refresh.
Runs one independent loop per pool type (basic / super / heavy), each with
its own configurable interval read from:
account.refresh.basic_interval_sec (default 86400 — 24 h)
account.refresh.super_interval_sec (default 7200 — 2 h)
account.refr... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/repository.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.403951 | """Account repository protocol — the contract every backend must satisfy."""
from typing import Protocol, runtime_checkable
from .commands import AccountPatch, AccountUpsert, BulkReplacePoolCommand, ListAccountsQuery
from .models import (
AccountChangeSet,
AccountMutationResult,
AccountPage,
AccountRe... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/runtime.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.414232 | """Account runtime singletons and hot-apply helpers.
These helpers expose the process-local account refresh runtime without making
callers import ``app.main``. Admin handlers use them to reconcile strategy and
scheduler state after hot config updates.
"""
from typing import TYPE_CHECKING, Literal
if TYPE_CHECKING:
... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/quota_defaults.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.419832 | """Default quota windows and pool inference logic.
Canonical quota totals per pool type (from upstream rate-limits API):
auto fast expert heavy grok_4_3
basic — 30 — — — window: 86400 s
super 50 140 50 — 50 w... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/state_machine.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.420926 | """Account lifecycle state machine.
Applies feedback events to an AccountRecord, advancing its status
and updating quota / usage fields accordingly.
"""
from dataclasses import dataclass, field
from app.platform.runtime.clock import now_ms
from .enums import AccountStatus, FeedbackKind
from .models import AccountRec... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/refresh.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.429638 | """Account refresh service — mode-aware usage synchronisation."""
import asyncio
from dataclasses import dataclass
from typing import TYPE_CHECKING
from app.platform.errors import UpstreamError
from app.platform.config.snapshot import get_config
from app.platform.logging.logger import logger
from app.platform.runtime... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/account/models.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:36.431148 | """Control-plane account models — persistent record shape."""
from dataclasses import dataclass
from typing import Any
from pydantic import BaseModel, Field, field_validator
from app.platform.runtime.clock import now_ms
from .enums import AccountStatus, QuotaSource
# -----------------------------------------------... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.011599 | """ProxyDirectory — control-plane proxy pool coordinator.
Maintains the list of EgressNodes and ClearanceBundles.
Selection delegates to the dataplane ProxyTable; this module owns
configuration loading and clearance refresh lifecycle.
"""
import asyncio
from urllib.parse import urlparse
from app.platform.logging.log... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/model/spec.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.026077 | """ModelSpec — the single source of truth for model metadata."""
from dataclasses import dataclass
from .enums import Capability, ModeId, Tier
@dataclass(slots=True, frozen=True)
class ModelSpec:
"""Immutable descriptor for one model variant.
``model_name`` is the public-facing identifier used in API requ... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/model/registry.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.040418 | """Model registry — all supported model variants defined in one place."""
from .enums import Capability, ModeId, Tier
from .spec import ModelSpec
# ---------------------------------------------------------------------------
# Master model list.
# Add new models here; no other files need to change.
# -----------------... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/feedback.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.052640 | """Classify upstream HTTP responses into proxy feedback categories."""
from .models import ProxyFeedback, ProxyFeedbackKind
def classify_status_code(status_code: int) -> ProxyFeedbackKind:
if status_code == 200:
return ProxyFeedbackKind.SUCCESS
if status_code == 401:
return ProxyFeedbackKind.... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/model/enums.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.070300 | """Control-plane model enumerations."""
from enum import IntEnum, IntFlag
class ModeId(IntEnum):
"""Upstream ``modeId`` parameter values.
Integer values are stable — used as array indices in the hot path.
"""
AUTO = 0 # modeId="auto"
FAST = 1 # modeId="fast"
EXPERT = 2 # modeId="expert"
... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/config.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.622332 | """Proxy clearance config helpers shared by control and dataplane code."""
from dataclasses import dataclass
from typing import Any
from app.platform.config.snapshot import get_config
@dataclass(frozen=True)
class ClearanceConfig:
cf_cookies: str = ""
user_agent: str = ""
cf_clearance: str = ""
brow... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/providers/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.658156 | from .manual import ManualClearanceProvider
from .flaresolverr import FlareSolverrClearanceProvider
__all__ = ["ManualClearanceProvider", "FlareSolverrClearanceProvider"]
|
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/models.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:37.659446 | """Control-plane proxy domain models."""
from enum import IntEnum, StrEnum
from typing import Self
from pydantic import BaseModel
class ProxyScope(StrEnum):
APP = "app" # grok.com API calls
ASSET = "asset" # static asset / CDN fetches
class RequestKind(StrEnum):
HTTP = "http"
WEBSOCKET ... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/providers/flaresolverr.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:38.256476 | """FlareSolverr-backed managed clearance provider."""
import asyncio
import json
from urllib import request as urllib_request
from urllib.error import HTTPError, URLError
from urllib.parse import urlparse
from app.platform.logging.logger import logger
from app.platform.config.snapshot import get_config
from ..models ... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/feedback.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:38.598848 | """Apply feedback to the runtime table columns (in-place, lock-free inner ops).
The caller (AccountDirectory) is responsible for holding the state lock before
calling these functions.
Strategy-split functions
------------------------
``apply_success`` / ``apply_rate_limited`` are split into ``*_quota`` and
``*_random... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/lease.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:38.621640 | """AccountLease — minimal hot-path rental object."""
from dataclasses import dataclass
from app.platform.runtime.ids import next_id
@dataclass(slots=True)
class AccountLease:
"""Represents a reserved account slot for a single upstream request.
Holds only the minimum fields needed on the hot path — no Accou... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/selector.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:38.622331 | """Hot-path account selector — pluggable strategies.
Two fully independent strategies:
* ``_quota_select`` — scores candidates by health / quota / inflight / fails.
Used when ``account.refresh.enabled=true``. Behaviour is the historical one,
kept unchanged.
* ``_random_select`` — uniform random choice among non-c... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:38.864175 | """ProxyRuntime — thin hot-path wrapper around ProxyDirectory.
Delegates acquisition and feedback to the control-plane ProxyDirectory.
Kept as a thin shim so callers in the dataplane need not import control
modules directly.
"""
from app.control.proxy import ProxyDirectory, get_proxy_directory
from app.control.proxy.... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/adapters/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.231150 | from .headers import build_http_headers, build_sso_cookie, build_ws_headers
from .session import ResettableSession, build_session_kwargs, normalize_proxy_url
__all__ = [
"build_http_headers", "build_sso_cookie", "build_ws_headers",
"ResettableSession", "build_session_kwargs", "normalize_proxy_url",
]
|
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/adapters/profile.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.235702 | """Shared Cloudflare proxy profile resolution."""
from dataclasses import dataclass
from functools import lru_cache
import re
from typing import get_args
from app.control.proxy.config import resolve_clearance_config
from app.control.proxy.models import ProxyLease
@dataclass(frozen=True)
class ProxyProfile:
cf_c... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/adapters/headers.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.265364 | """HTTP/WebSocket header builders for reverse-proxy requests.
All values are sanitized to ASCII-safe Latin-1 before use.
"""
import base64
import random
import re
import string
import uuid
from typing import Optional
from urllib.parse import urlparse
from app.platform.logging.logger import logger
from app.platform.... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/adapters/session.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.443721 | """curl_cffi session builder for reverse-proxy requests."""
import asyncio
from typing import Any
from urllib.parse import urlparse
from curl_cffi.const import CurlOpt
from app.platform.config.snapshot import get_config
from app.platform.errors import UpstreamError
from app.control.proxy.models import ProxyLease
fro... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/lease.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.850857 | """Proxy dataplane lease — re-export from control plane.
ProxyLease is defined in ``app.control.proxy.models`` and used throughout
both control and dataplane layers. This module provides a canonical import
path within the dataplane package.
"""
from app.control.proxy.models import ProxyLease
__all__ = ["ProxyLease"... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/selector.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.859093 | """Proxy dataplane selector — pick the best egress node from a ProxyRuntimeTable.
Extracted from ProxyDirectory.acquire() to formalize the dataplane separation.
"""
from app.control.proxy.models import (
EgressMode, EgressNode, EgressNodeState,
ProxyScope, RequestKind,
)
from .table import ProxyRuntimeTable
... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/proxy/table.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:39.889162 | """Proxy dataplane table — runtime view of egress nodes and clearance bundles.
Thin wrapper around ProxyDirectory's internal state, formalizing the
dataplane/control-plane boundary. The control-plane ProxyDirectory owns
mutation; this module provides a read-only snapshot for selector logic.
"""
from dataclasses impo... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/reverse/executor.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:40.476523 | """Reverse pipeline executor — the 7-step request lifecycle.
Pipeline: plan → account → proxy → serialize → execute → classify → feedback
This executor is opt-in. Existing products-layer code that calls transport
directly continues to work; the executor wraps the same pattern with
structured feedback and classifica... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/reverse/classifier.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:40.499815 | """Reverse pipeline result classifier.
Maps upstream HTTP status codes and response bodies to a ResultCategory.
"""
from typing import Any
from app.dataplane.reverse.protocol.xai_usage import is_invalid_credentials_body
from .types import ResultCategory
def classify_result(
status_code: int,
body: str = "... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/reverse/feedback.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:40.589438 | """Reverse pipeline feedback — translate ReverseResult into account + proxy feedback.
Called after every upstream call to update account health/quota and proxy state.
"""
from app.control.account.commands import AccountPatch
from app.control.proxy.models import ProxyFeedback, ProxyFeedbackKind
from app.platform.runti... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/providers/manual.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:43.210349 | """Manual clearance provider — uses operator-supplied cookies directly."""
from app.platform.config.snapshot import get_config
from ..config import resolve_clearance_config
from ..models import ClearanceBundle, ClearanceMode
class ManualClearanceProvider:
"""Build a ClearanceBundle from static config values."""
... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:43.397404 | """AccountDirectory — high-concurrency hot-path account store.
Wraps the columnar AccountRuntimeTable with lock-minimal coordination.
Bootstrap loads a full snapshot; incremental sync applies revision-based
changesets without holding the selection lock.
"""
import asyncio
from typing import TYPE_CHECKING
from app.pl... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/sync.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:43.449933 | """Synchronise the AccountRuntimeTable from the control-plane repository.
Two modes:
bootstrap — full snapshot load at startup.
incremental — revision-based change scan at runtime.
"""
from app.platform.logging.logger import logger
from app.platform.runtime.clock import ms_to_s
from app.control.account.models im... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/dataplane/account/table.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:43.678437 | """Columnar runtime account table for high-throughput hot-path selection.
Memory layout (1 000 accounts):
Object-list design : ~800 KB (Python object overhead per entry)
Columnar array design: ~80 KB (packed C arrays)
All quota, status, health, and counter fields are stored as typed
``array.array`` columns in... |
chenyme/grok2api | https://github.com/chenyme/grok2api | null | null | null | null | 4,670 | null | null | mit | null | null | null | null | null | null | null | app/control/proxy/scheduler.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:48.029593 | """Proxy clearance refresh scheduler.
Periodically refreshes ClearanceBundles for managed (FlareSolverr) mode.
Previously inline in ProxyDirectory; extracted for separation of concerns.
"""
import asyncio
from app.platform.logging.logger import logger
from app.platform.config.snapshot import get_config
from app.cont... |
hhatto/autopep8 | https://github.com/hhatto/autopep8 | null | null | null | null | 4,667 | null | null | mit | null | null | null | null | null | null | null | test/example.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:50.443521 | import sys, os
def foo():
import subprocess, argparse
import copy; import math, email
print(1)
print(2) # e261
d = {1: 2,# e261
3: 4}
print(2) ## e262
print(2) #### e262
print(2) #e262
print(2) # e262
1 /1
1 *2
1 +1
1 -1
1 **2
def dummy1 ( a ):
print(a)
print(a)
def dummy2(a) :
... |
hhatto/autopep8 | https://github.com/hhatto/autopep8 | null | null | null | null | 4,667 | null | null | mit | null | null | null | null | null | null | null | test/acid_pypi.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:50.459644 | #!/usr/bin/env python
"""Run acid test against latest packages on PyPI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import subprocess
import sys
import tarfile
import zipfile
import acid
TMP_DIR = os.path.join(os.path.abspath(os.path.di... |
hhatto/autopep8 | https://github.com/hhatto/autopep8 | null | null | null | null | 4,667 | null | null | mit | null | null | null | null | null | null | null | test/suite/E10.py | null | null | null | null | null | null | Python | 2026-05-04T01:55:50.462133 | #: E101 E122 W191 W191
if True:
pass
change_2_log = \
"""Change 2 by slamb@testclient on 2006/04/13 21:46:23
creation
"""
p4change = {
2: change_2_log,
}
class TestP4Poller(unittest.TestCase):
def setUp(self):
self.setUpGetProcessOutput()
return self.setUpChangeSource()
def tearDown(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.