Optional Parquet save/load functions for clj-yfinance datasets.
REQUIRES: Add to your deps.edn aliases: {:parquet {:extra-deps {com.techascent/tmd-parquet {:mvn/version "1.000-beta-39"} techascent/tech.ml.dataset {:mvn/version "7.032"}}}}
Then start your REPL with: clojure -M:parquet:nrepl
USAGE: (require '[clj-yfinance.parquet :as yfp])
;; Save and load historical data (yfp/save-historical! "AAPL" "aapl.parquet" :period "5y") (yfp/load-historical "aapl.parquet")
;; Save a multi-ticker dataset in one file (yfp/save-multi-ticker! ["AAPL" "GOOGL" "MSFT"] "prices.parquet" :period "1y") (yfp/load-dataset "prices.parquet")
Optional Parquet save/load functions for clj-yfinance datasets.
REQUIRES: Add to your deps.edn aliases:
{:parquet {:extra-deps {com.techascent/tmd-parquet {:mvn/version "1.000-beta-39"}
techascent/tech.ml.dataset {:mvn/version "7.032"}}}}
Then start your REPL with: clojure -M:parquet:nrepl
USAGE:
(require '[clj-yfinance.parquet :as yfp])
;; Save and load historical data
(yfp/save-historical! "AAPL" "aapl.parquet" :period "5y")
(yfp/load-historical "aapl.parquet")
;; Save a multi-ticker dataset in one file
(yfp/save-multi-ticker! ["AAPL" "GOOGL" "MSFT"] "prices.parquet" :period "1y")
(yfp/load-dataset "prices.parquet")(load-dataset path)Load any Parquet file and return a dataset. Column names are keywordized on load.
Example: (load-dataset "prices.parquet")
Load any Parquet file and return a dataset. Column names are keywordized on load. Example: (load-dataset "prices.parquet")
(load-historical path)Load a Parquet file saved by save-historical! and return a dataset.
Column names are keywordized on load. Column types are restored as saved: :timestamp (int64), OHLCV as float64/int64.
Example: (load-historical "aapl.parquet")
Load a Parquet file saved by save-historical! and return a dataset. Column names are keywordized on load. Column types are restored as saved: :timestamp (int64), OHLCV as float64/int64. Example: (load-historical "aapl.parquet")
(save-dataset! ds path)Save an arbitrary tech.v3.dataset to a Parquet file.
Use this when you have already transformed a dataset and want to persist it.
Example: (require '[tablecloth.api :as tc]) (-> (yfd/historical->dataset "AAPL" :period "1y") (tc/add-column :log-return ...) (yfp/save-dataset! "aapl-enriched.parquet"))
Save an arbitrary tech.v3.dataset to a Parquet file.
Use this when you have already transformed a dataset and want to persist it.
Example:
(require '[tablecloth.api :as tc])
(-> (yfd/historical->dataset "AAPL" :period "1y")
(tc/add-column :log-return ...)
(yfp/save-dataset! "aapl-enriched.parquet"))(save-historical! ticker path & opts)Fetch historical OHLCV data for ticker and save to a Parquet file.
Returns the dataset on success, nil if fetch fails or data is empty.
Options are passed through to fetch-historical: :period, :interval, :start, :end, :adjusted, :prepost
Examples: (save-historical! "AAPL" "aapl.parquet" :period "5y") (save-historical! "TSLA" "tsla-1h.parquet" :start start-inst :end end-inst :interval "1h")
Fetch historical OHLCV data for ticker and save to a Parquet file. Returns the dataset on success, nil if fetch fails or data is empty. Options are passed through to fetch-historical: :period, :interval, :start, :end, :adjusted, :prepost Examples: (save-historical! "AAPL" "aapl.parquet" :period "5y") (save-historical! "TSLA" "tsla-1h.parquet" :start start-inst :end end-inst :interval "1h")
(save-multi-ticker! tickers path & opts)Fetch historical OHLCV data for multiple tickers and save to a single Parquet file.
The dataset includes a :ticker column to identify each row's source. Returns the combined dataset on success, nil if all fetches fail.
Options are passed through to fetch-historical: :period, :interval, :start, :end, :adjusted, :prepost
Examples: (save-multi-ticker! ["AAPL" "GOOGL" "MSFT"] "tech.parquet" :period "1y") (save-multi-ticker! tickers "portfolio.parquet" :period "5y")
Fetch historical OHLCV data for multiple tickers and save to a single Parquet file. The dataset includes a :ticker column to identify each row's source. Returns the combined dataset on success, nil if all fetches fail. Options are passed through to fetch-historical: :period, :interval, :start, :end, :adjusted, :prepost Examples: (save-multi-ticker! ["AAPL" "GOOGL" "MSFT"] "tech.parquet" :period "1y") (save-multi-ticker! tickers "portfolio.parquet" :period "5y")
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |