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", price_fields="oclhva", and comma-separated field lists such as price_fields="volume,amount" to control which price columns are returned. PricePeriodWorkflow also supports price_source="krx" when KRX Amount data is required for VWAP.

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.1.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.1.0-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: financechatbotkit-3.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 6bc3034de640f438af091376eef46f4a2ae2424c47bd2067afadf6dd8eb04a7c
MD5 613f21bb19ea03cebbecfdf747faa81d
BLAKE2b-256 d0b95f07e97845a6a38fdd1e3749244da781b208ccf91a8234e920eba9f9ad21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for financechatbotkit-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46c2bf51f063baa5c8ed06144fe8550be0e1427aeccde4d904a4225e8a0765ba
MD5 2d30da8e9ff2f77c1edae71b583262c9
BLAKE2b-256 764461c5f086512e086a46b0c3c71fca70c585aff454300e3baccc56c5962f4c

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