Skip to main content

FinanceChatbot workflows (orchestrator) and Telegram/Firestore helpers (TeleBotKit)

Project description

FinanceChatbot

FinanceChatbot bundles three installable code areas under src/:

  • orchestrator: finance data workflows
  • utilitykit: reusable utility helpers
  • telebotkit: Telegram / Firestore helpers

The package name is financechatbotkit, and it currently requires Python 3.11+.

Orchestrator

orchestrator is the main workflow library for:

  • mapping
  • price
  • fnguide
  • bond
  • kind

Public API

from orchestrator import (
    FnGuideWorkflow,
    KindWorkflow,
    MappingWorkflow,
    MarketBondWorkflow,
    PricePeriodWorkflow,
)

Feature-level imports are also available:

from orchestrator.mapping import MappingWorkflow
from orchestrator.price import PricePeriodWorkflow
from orchestrator.fnguide import FnGuideWorkflow
from orchestrator.bond import MarketBondWorkflow
from orchestrator.kind import KindWorkflow, parse_kind_html_to_json

Most workflow classes return a normalized payload shaped like:

{
    "input": {...},
    "data": {...},
}

price workflows support price_fields="close" (default), price_fields="oclh", price_fields="oclhv", and comma-separated field lists such as price_fields="open,close" to control which price columns are returned.

Workflow Classes

The main usage pattern is class-based:

  • MappingWorkflow
  • PricePeriodWorkflow
  • PriceSnapshotWorkflow
  • FnGuideWorkflow
  • MarketBondWorkflow
  • KindWorkflow

For example, FnGuideWorkflow is used like this:

from orchestrator.fnguide import FnGuideWorkflow

workflow = FnGuideWorkflow()
result = workflow.run(stock_code="005930", statement_type="consolidated")

KIND Workflow

kind is slightly different from the other workflow modules because it supports both:

  • request payload construction and raw response download
  • HTML file parsing into structured JSON

The recommended entry point is KindWorkflow.

from pathlib import Path

from orchestrator.kind import KindWorkflow
from run import KIND_REQUEST_HEADERS

workflow = KindWorkflow()
result = workflow.run(
    output_directory=Path("resources/kind_2012"),
    request_headers=KIND_REQUEST_HEADERS,
    start_date="2012-01-01",
    end_date="2012-12-31",
    start_page=1,
    end_page=10,
    disclosure_type_groups={"01": ["0119"]},
    last_report_only=True,
    save=True,
)

print(result["input_snapshot_path"])
print(result["checkpoint_path"])

KindWorkflow stores normalized input state and, when save=True, writes:

  • raw .body files page by page
  • kind_workflow.input.json
  • kind_workflow.checkpoint.json

This makes long-running downloads easier to inspect and recover.

Lower-level helpers remain available when needed:

from orchestrator.kind import (
    build_kind_search_request_data,
    parse_kind_file_to_json,
    parse_kind_html_to_json,
    save_kind_search_results,
)

Example Script

run.py shows one concrete KIND pipeline:

  1. Download paged KIND responses through KindWorkflow
  2. Merge downloaded .body files into a single JSON file
  3. Convert the merged JSON into Excel using utilitykit

UtilityKit

utilitykit is a shared utilities package for repo-wide helpers that do not belong to orchestrator.

Current public utilities:

  • utilitykit.excel.read_xlsx_sheet_as_json()
  • utilitykit.excel.write_json_to_xlsx()
  • utilitykit.excel.records_to_table()
  • utilitykit.excel.project_records_to_table()
  • utilitykit.excel.row_cell_records_to_table()

Excel Examples

Read an Excel sheet as list[list] using A1-start automatic bounds detection:

from utilitykit import read_xlsx_sheet_as_json

table = read_xlsx_sheet_as_json("sample.xlsx", sheet_name="Data")

Write row-oriented data:

from utilitykit import write_json_to_xlsx

write_json_to_xlsx(
    [
        {"company": "Samsung", "sales": 100},
        {"company": "LG", "sales": 80},
    ],
    "rows.xlsx",
    sheet_name="Rows",
    axis="rows",
    item_mode="dict",
)

Write column-oriented data:

from utilitykit import write_json_to_xlsx

write_json_to_xlsx(
    {"company": ["Samsung", "LG"], "sales": [100, 80]},
    "columns.xlsx",
    sheet_name="Columns",
    axis="columns",
    item_mode="dict",
)

TeleBotKit

TeleBotKit is a shared helper package that lives under src/telebotkit and is packaged together with this project.

It provides helpers for:

  • Telegram bot command parsing, routing, MarkdownV2 escaping, and reply payload generation (telebotkit.bot)
  • Firestore client bootstrap, typed repositories, shared document access, and lease/lock helpers (telebotkit.firestore)
  • Excel row parsing and typed JSON payload generation for Firestore imports (telebotkit.sheets)

Example Usage

from telebotkit.bot import Reply, Router
from telebotkit.firestore import DocumentStore, get_client
from telebotkit.sheets import build_typed_rows_payload_from_xlsx

See src/telebotkit/README.md for fuller API documentation and examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

financechatbotkit-3.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

financechatbotkit-3.2.0-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file financechatbotkit-3.2.0.tar.gz.

File metadata

  • Download URL: financechatbotkit-3.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for financechatbotkit-3.2.0.tar.gz
Algorithm Hash digest
SHA256 71cfa9ae9aa822177548587cff560aeb9850e400225b288315cb225e700d0ce7
MD5 0ef816dca25dc4020643e152ecdb23f1
BLAKE2b-256 2150318f9dced58cee56eed613a73d2e5031801416ff464c80465130073966b0

See more details on using hashes here.

File details

Details for the file financechatbotkit-3.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for financechatbotkit-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc2315ba96b3b4175c6dd5bb1a7883b698216c82e37a6b8c2faf36391fcdf2c9
MD5 84747b79e2d90b8d86fb3e44caa6ff88
BLAKE2b-256 17aef263dbdac568185059ac20d3feb5802f3a9cfcf22d069d972cf8024f1c44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page