diff --git a/testing.ipynb b/testing.ipynb index c74d549..22839a5 100644 --- a/testing.ipynb +++ b/testing.ipynb @@ -485,7 +485,7 @@ "source": [ "import random\n", "import math\n", - "import fincal as fc\n", + "import pyfacts as pft\n", "from typing import List\n", "import datetime\n", "from dateutil.relativedelta import relativedelta" @@ -536,7 +536,7 @@ "\n", "\n", "def sample_data_generator(\n", - " frequency: fc.Frequency,\n", + " frequency: pft.Frequency,\n", " num: int = 1000,\n", " skip_weekends: bool = False,\n", " mu: float = 0.1,\n", @@ -571,11 +571,11 @@ " start_date = datetime.datetime(2017, 1, 1)\n", " timedelta_dict = {\n", " frequency.freq_type: int(\n", - " frequency.value * num * (7 / 5 if frequency == fc.AllFrequencies.D and skip_weekends else 1)\n", + " frequency.value * num * (7 / 5 if frequency == pft.AllFrequencies.D and skip_weekends else 1)\n", " )\n", " }\n", " end_date = start_date + relativedelta(**timedelta_dict)\n", - " dates = fc.create_date_series(start_date, end_date, frequency.symbol, skip_weekends=skip_weekends, eomonth=eomonth)\n", + " dates = pft.create_date_series(start_date, end_date, frequency.symbol, skip_weekends=skip_weekends, eomonth=eomonth)\n", " values = create_prices(1000, mu, sigma, num)\n", " ts = list(zip(dates, values))\n", " return ts\n" @@ -583,40 +583,36 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 6, "id": "c85b5dd9-9a88-4608-ac58-1a141295f63f", "metadata": {}, "outputs": [], "source": [ - "data = sample_data_generator(num=261, frequency=fc.AllFrequencies.W)\n", - "ts = fc.TimeSeries(data, \"W\")" + "market_data = sample_data_generator(num=3600, frequency=pft.AllFrequencies.D)\n", + "mts = pft.TimeSeries(market_data, \"D\")\n", + "stock_data = sample_data_generator(num=3600, frequency=pft.AllFrequencies.D, mu=0.12, sigma=0.05)\n", + "sts = pft.TimeSeries(stock_data, 'D')" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 8, "id": "0488a4d0-bca1-4341-9fae-1fd254adc0dc", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "TimeSeries([(datetime.datetime(2017, 1, 1, 0, 0), 1003.03),\n", - "\t (datetime.datetime(2017, 1, 8, 0, 0), 1002.71),\n", - "\t (datetime.datetime(2017, 1, 15, 0, 0), 1008.77)\n", - "\t ...\n", - "\t (datetime.datetime(2021, 12, 12, 0, 0), 1107.21),\n", - "\t (datetime.datetime(2021, 12, 19, 0, 0), 1106.66),\n", - "\t (datetime.datetime(2021, 12, 26, 0, 0), 1104.32)], frequency='W')" + "1.020217253491451" ] }, - "execution_count": 13, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ts" + "pft.beta(sts, mts)" ] }, { @@ -708,7 +704,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.2" + "version": "3.10.4" } }, "nbformat": 4,