{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pygwalker as pyg\n", "import polars as pl\n", "df = pl.read_csv('./298040/day/candle-day-250.csv',try_parse_dates = True)\n", "gwalker = pyg.walk(df)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (269, 4)
ema-12ema-24ema-9stockBusinessDate
f64f64f64i64
59911.6035259889.67535459814.16855820220516
59851.85021559853.9949559692.71069720220517
59829.05794159841.29885959615.88837120220518
59802.75916259827.4987659519.86046420220519
59957.02980359916.84647859699.8255820220520
60058.11131159970.48530259799.78197520220523
60174.7438260028.78837259924.72746920220524
60447.78133160170.42214360305.90933620220525
60901.28615160402.63276461007.38667120220526
61163.02248260507.20952761459.23333820220527
61449.64132560612.18426861999.04167320220530
61641.89383760648.02637862448.80209120220531
87354.70144788824.11225985744.08603620230530
88393.88628589539.25245587030.10754620230531
89685.25340690368.75266988787.63443220230601
90913.7539391122.55724890559.5430420230602
91315.86991991367.99700991124.428820230605
91826.00375391660.86631491905.53620230607
92106.92740791805.28947292381.9220230608
92323.37777891901.401692802.420230609
91834.66666791588.4892128.020230612
91440.091344.091560.020230613
91200.091200.091200.020230614
91200.091200.091200.020230615
" ], "text/plain": [ "shape: (269, 4)\n", "┌──────────────┬──────────────┬──────────────┬───────────────────┐\n", "│ ema-12 ┆ ema-24 ┆ ema-9 ┆ stockBusinessDate │\n", "│ --- ┆ --- ┆ --- ┆ --- │\n", "│ f64 ┆ f64 ┆ f64 ┆ i64 │\n", "╞══════════════╪══════════════╪══════════════╪═══════════════════╡\n", "│ 59911.60352 ┆ 59889.675354 ┆ 59814.168558 ┆ 20220516 │\n", "│ 59851.850215 ┆ 59853.99495 ┆ 59692.710697 ┆ 20220517 │\n", "│ 59829.057941 ┆ 59841.298859 ┆ 59615.888371 ┆ 20220518 │\n", "│ 59802.759162 ┆ 59827.49876 ┆ 59519.860464 ┆ 20220519 │\n", "│ … ┆ … ┆ … ┆ … │\n", "│ 91834.666667 ┆ 91588.48 ┆ 92128.0 ┆ 20230612 │\n", "│ 91440.0 ┆ 91344.0 ┆ 91560.0 ┆ 20230613 │\n", "│ 91200.0 ┆ 91200.0 ┆ 91200.0 ┆ 20230614 │\n", "│ 91200.0 ┆ 91200.0 ┆ 91200.0 ┆ 20230615 │\n", "└──────────────┴──────────────┴──────────────┴───────────────────┘" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort(\"stockBusinessDate\", descending=False).select(pl.col(\"stockClosingPrice\").ewm_mean(span=14.0, adjust=False).alias(\"ema-12\"),\n", " pl.col(\"stockClosingPrice\").ewm_mean(span=24.0, adjust=False).alias(\"ema-24\"),\n", " pl.col(\"stockClosingPrice\").ewm_mean(span=9.0, adjust=False).alias(\"ema-9\"),\n", " pl.col(\"stockBusinessDate\")\n", " )" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.3" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }