User:Bpeller

    From KDE TechBase

    Central Stock Price Information

    Use Cases

    • A plasmoid wants to display a watchlist of stock quotes.
    • An investor wants to chart an investment's performance starting from their first purchase twenty-five years ago.
    • An investor wants to do some fundamental analysis on a security.
    • A student of the markets wants to "replay" the crash of '87 starting from 3 months prior and advancing one day at a time.
    • A swing trader wants to chart two month's worth of hourly data.
    • A mechanical systems trader writes a scripted trading algorithm, and they want to backtest its performance on various sets of historical data.

    Components

    • Always-On/On-Demand Backend: A member of Alkimia
    The backend handles all quote retrieval/storage, and provides a public interface for client applications to query over DBus for whatever information they need. The backend also serves as a centralized place for consolidating various price-manipulation maths common to financial applications' needs.
    • A "Master" Backend UI: Some form/combination of plasmoid/application/kpart/kcm...
    Cumulative functionality should support something along the lines of:
    • Managing which symbols and watchlists the backend permanently stores data for.
    • Configuring the backend's default historical and intra-day data sources. (And maybe resource/performance settings.)
    YahooCSV: Download quotes from Yahoo! (Default for Intra-Day & Historical)
    Directory: Import/monitor quotes from a directory containing CSV files. (For users with paid-data services.)
    Time Permitting: YahooWEB: Parse real-time data from the finance.yahoo.com website. (Intra-Day only)
    • Exporting (user specified) stored/calculated data/information/statistics to CSV.

    [Jump to Top]

    Backend Functionality

    Private:

    • Maintain/store a master list of all watchlists.
    • Maintain/store a master list of all symbols to be watched. Filters out watchlist-duplicates and includes symbols which aren't a member of any watchlist.
    • Maintain a local/offline store of downloaded data:
    1. Company info and statistics. (Used for offline mode/throughout the day. Company stats change frequently enough and are reasonably cheap (fast) to download so we update this once daily, if possible.)
    2. Accumulate sampled Intra-Day data as Minutely data.
    3. Store "primary time period" data: Minutely, Daily, Weekly, and Monthly

    Public DBus Interfaces:

    • Management of stored symbols and watchlists
    Clients can add/request-to-remove symbols to/from the master list.
    Clients can add/retrieve/request-to-modify global watchlists and use them locally.
    • Intra-Day Quotes / Most-Recent Daily Close (if after market hours)
    Inputs:
    • Symbol
    • Optional: Select:
    Absolute: the real values (Default)
    Percent: Percent change from previous close
    Output: SingleBarStruct: Contains a KDateTime, the Open, High, Low, Close, Volume, and, if applicable, Open Interest (eg for futures). Time Permitting & Optional: and Beta.
    • Previous Day (convenience function)
    Inputs:
    • Symbol
    • Optional: Select:
    Absolute: the real values (Default)
    Percent: Percent change from previous close (eg two closes ago)
    Output: SingleBarStruct: Contains a KDateTime, the Open, High, Low, Close, Volume, and, if applicable, Open Interest (eg for futures). Time Permitting & Optional: and Beta.
    • Company Information, Key Statistics and Fundamentals
    Inputs:
    • Symbol
    • Parameters (keys)
    Initially most (all?) parameters easily available from Yahoo will be supported. Time permitting, more information sources can be added (such as parsing parameter values from Yahoo's Key Statistics webpage).
    Time Permitting: There should probably be a way to query at runtime what keys are available, as well as key-lookup by human-readable names.
    Output:
    • A container object holding the requested parameters' key-value pairs.
    • Historical Quotes
    Inputs:
    • Symbol
    • Amount/duration of historical data:
    Optional: Specify an end date. (Defaults to the most recent close.)
    Specify a duration (relative to the end date) by providing one of the following:
    A start date.
    A length of elapsed time units, independent of the requested time period.
    Or directly as a number of bars.
    • Optional: Time Period: Specify by providing:
    Optional: A major time unit. (Minutely, Daily (Default), Weekly, or Monthly)
    Optional: A multiplier. Default = 1
    • Optional: Type of historical data:
    Adjusted: (Default) Prices adjusted for splits and dividends.
    Absolute: Raw price data. (Provided by default if the requested symbol has no splits or dividends.)
    • Optional: A maximum lookback. Default = 0
    The number of "hidden" bars (older than the start date) to return. Used by technical analysis indicators so their results will be complete for the requested length of "shown" price data.
    Output:
    • A container object holding the input parameters used to produce the data, as well as the data itself. Need to look into what would be the most convenient method for MVC-based clients such as KDChart as used by KMyMoney, but that's still flexible enough to be non-MVC-friendly.

    [Jump to Top]

    Backend Dreams for the Future

    Time Permitting:

    1. Support for calculating relative price/performance between multiple data sets.
    2. Support for calculating "custom Market Indexes" from watchlists.
    3. Support for browsing/querying sectors and industries, as well as tracking their performance using (1) and (2).
    4. [Maybe] Technical Analysis Indicator Calculation Support: Essentially this would be providing a Qt-like API wrapped around TA-Lib's Abstract runtime interface. TA-Lib requires data to be stored in STD c++ arrays, as well as requiring the frequent reuse of non-cheaply-calculated data, so from a convenience/performance standpoint it probably makes the most sense to try to centralize indicator support inside Alkimia. However, TA-Lib isn't exactly packaged for most (all?) distributions, let alone included by default, so that's definitely a big reason to avoid said integration. [Then again, aside from Qtstalker's port towards Qt4, I have yet to find any still-active *Linux* projects using it so... rhetorically, what recent-ish incentive have distros ever had to really consider including it?]
    5. [Depends on TA-Lib] Manual calculation of Beta with controllable inputs for the time period and the "volatility base market." This ability is probably most applicable for large private investors, portfolio analysts, and institutions/banks, and is particularly relevant for those invested in international/emerging markets who do not want to base their volatility calculations off of American markets, as Yahoo's provided Beta is assumed to do.

    [Jump to Top]