diff --git a/tutorials/20260622164035_Let's Build a Quant Trading Strategy, MemLabs/part1.ipynb b/tutorials/20260622164035_Let's Build a Quant Trading Strategy, MemLabs/part1.ipynb index 2cfbe57..d19b11c 100644 --- a/tutorials/20260622164035_Let's Build a Quant Trading Strategy, MemLabs/part1.ipynb +++ b/tutorials/20260622164035_Let's Build a Quant Trading Strategy, MemLabs/part1.ipynb @@ -370,11 +370,139 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "id": "fe1ac560", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "
\n", + "" + ], + "text/plain": [ + "alt.Chart(...)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "price_time_series = pl.DataFrame({'price':[100.0,120.0,100.0]})\n", + "research.plot_column(price_time_series, 'price')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "497659ef", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "shape: (3, 5)
pricedeltareturnlog_returntest
f64f64f64f64f64
100.0nullnullnullnull
120.020.00.20.182322100.0
100.0-20.0-0.166667-0.182322120.0
" + ], + "text/plain": [ + "shape: (3, 5)\n", + "┌───────┬───────┬───────────┬────────────┬───────┐\n", + "│ price ┆ delta ┆ return ┆ log_return ┆ test │\n", + "│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", + "│ f64 ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n", + "╞═══════╪═══════╪═══════════╪════════════╪═══════╡\n", + "│ 100.0 ┆ null ┆ null ┆ null ┆ null │\n", + "│ 120.0 ┆ 20.0 ┆ 0.2 ┆ 0.182322 ┆ 100.0 │\n", + "│ 100.0 ┆ -20.0 ┆ -0.166667 ┆ -0.182322 ┆ 120.0 │\n", + "└───────┴───────┴───────────┴────────────┴───────┘" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "price_time_series.with_columns(\n", + " pl.col('price').diff().alias('delta'),\n", + " ((pl.col('price')-pl.col('price').shift())/pl.col('price').shift()).alias('return'),\n", + " (pl.col('price')/pl.col('price').shift()).log().alias('log_return'),\n", + ")" + ] } ], "metadata": {