From 61441cbac1b742ee012a7c9edd362d44ed50bc02 Mon Sep 17 00:00:00 2001 From: Peter Dekkers Date: Sat, 1 Apr 2023 18:05:31 +0200 Subject: [PATCH] prepared for version 1.3.0 --- .github/workflows/dockerx.yml | 2 +- Dockerfile | 8 +++---- bin/README.adoc | 8 ++++--- bin/dockerbuild.sh | 2 +- bin/dockerbuild_singleplatform.sh | 2 +- binder/Dockerfile | 2 +- notebooks/alpaca.ipynb | 2 +- notebooks/backtest.ipynb | 2 +- notebooks/basic.ipynb | 2 +- notebooks/binance.ipynb | 2 +- notebooks/charts.ipynb | 40 +++++++++++++++++++++---------- notebooks/crypto.ipynb | 2 +- notebooks/discord.ipynb | 2 +- notebooks/empty.ipynb | 2 +- notebooks/forex.ipynb | 2 +- notebooks/ibkr.ipynb | 2 +- notebooks/oanda.ipynb | 2 +- notebooks/policies.ipynb | 2 +- notebooks/preload.ipynb | 2 +- notebooks/strategies.ipynb | 2 +- notebooks/tech-analysis.ipynb | 2 +- notebooks/xgboost.ipynb | 2 +- notebooks/yahoo.ipynb | 2 +- 23 files changed, 56 insertions(+), 40 deletions(-) diff --git a/.github/workflows/dockerx.yml b/.github/workflows/dockerx.yml index 2fce0fc..bd7aebd 100644 --- a/.github/workflows/dockerx.yml +++ b/.github/workflows/dockerx.yml @@ -26,4 +26,4 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: roboquant/jupyter:1.2.1,roboquant/jupyter:latest + tags: roboquant/jupyter:1.3.0,roboquant/jupyter:latest diff --git a/Dockerfile b/Dockerfile index 7bd1062..58a22cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # we use the smaller base-notebook image as a starting point -FROM jupyter/base-notebook:2023-03-13 +FROM jupyter/base-notebook:2023-03-27 # Install OpenJDK as root USER root @@ -15,9 +15,9 @@ USER 1000 # Install the Kotlin kernel in the Jupyter environment # RUN pip install kotlin-jupyter-kernel==0.11.0.255 -RUN pip install -i https://test.pypi.org/simple/ kotlin-jupyter-kernel==0.11.0.335 +RUN pip install -i https://test.pypi.org/simple/ kotlin-jupyter-kernel==0.11.0.346 -# Make additional Kotlin kernels available with different fixed memory profiles +# Make additional Kotlin kernels available with different memory profiles RUN python -m kotlin_kernel add-kernel --name "Small_0.5GB" --jvm-arg=-Xmx512M RUN python -m kotlin_kernel add-kernel --name "Medium_2G" --jvm-arg=-Xmx2G RUN python -m kotlin_kernel add-kernel --name "Large_8GB" --jvm-arg=-Xmx8G @@ -26,7 +26,7 @@ RUN python -m kotlin_kernel add-kernel --name "Large_8GB" --jvm-arg=-Xmx8G RUN mkdir -p /home/jovyan/notebooks COPY --chown=1000:100 notebooks /home/jovyan/notebooks -# Run the preload notebook to load some libraries and historic data on the image +# Run the preload notebook to load libraries and historic data onto the image RUN jupyter nbconvert --to notebook --execute notebooks/preload.ipynb && rm -f notebooks/preload*.ipynb diff --git a/bin/README.adoc b/bin/README.adoc index 152468d..53a746f 100644 --- a/bin/README.adoc +++ b/bin/README.adoc @@ -11,11 +11,13 @@ You can start using _roboquant_ with Jupyter notebooks straight out-of-the-box b [source,shell] ---- -docker run --rm -p 8888:8888 roboquant/jupyter +docker run -p 8888:8888 roboquant/jupyter ---- Then open the url that appears in your terminal in your browser to try it out. The `./notebooks` directory contains several notebooks that provide an introduction into roboquant. +For more details, see https://roboquant.org/tutorial/install.html + == Interactive Brokers only If you also want test the Interactive Brokers Notebook that is included, it is important to realize that the notebook requires access to a (local) running instance of Trader Workstation or IB Gateway (recommended). @@ -24,7 +26,7 @@ For the docker container to have this network accessible, you can use the `--net [source,shell] ---- -docker run --rm -p 8888:8888 --network=host -roboquant/jupyter +docker run -p 8888:8888 --network=host roboquant/jupyter ---- You will also have to manually copy the required client jar file after starting a notebook (due to license constraints). See the `ibkr` notebook for more instructions. @@ -52,4 +54,4 @@ Please note the `dockerbuild.sh` script will also push the image to the Docker H NOTE: currently, only shell scripts are provided to build and start notebooks. So if you're on Windows you either have to use WSL or run the commands in the shell script from the command line manually. == MyBinder.org -In order to start _roboquant_ notebooks quickly on MyBinder.org, there is a `binder directory included with a `Dockerfile` that retrieves the latest image from Docker Hub. This avoids that MyBinder.org has to build the image from scratch and has prolonged startup times as a consequence. \ No newline at end of file +In order to start _roboquant_ notebooks quickly on MyBinder.org, there is a `binder directory included with a `Dockerfile` that retrieves the latest image from Docker Hub. This avoids that MyBinder.org has to build the image from scratch that leads to prolonged startup times. \ No newline at end of file diff --git a/bin/dockerbuild.sh b/bin/dockerbuild.sh index ab89755..890119c 100755 --- a/bin/dockerbuild.sh +++ b/bin/dockerbuild.sh @@ -11,4 +11,4 @@ rm -f notebooks/*.nbconvert.ipynb jupyter nbconvert --clear-output --inplace notebooks/*.ipynb # Build for AMD64 and ARM64 platforms -docker buildx build --platform linux/amd64,linux/arm64/v8 -t roboquant/jupyter:1.2.1 -t roboquant/jupyter:latest --push . +docker buildx build --platform linux/amd64,linux/arm64/v8 -t roboquant/jupyter:1.3.0 -t roboquant/jupyter:latest --push . diff --git a/bin/dockerbuild_singleplatform.sh b/bin/dockerbuild_singleplatform.sh index 0e43fb7..10ca7d9 100755 --- a/bin/dockerbuild_singleplatform.sh +++ b/bin/dockerbuild_singleplatform.sh @@ -5,4 +5,4 @@ rm -f notebooks/*.nbconvert.ipynb jupyter nbconvert --clear-output --inplace notebooks/*.ipynb # Build for local platform only -docker build -t roboquant/jupyter:1.2.1 -t roboquant/jupyter:latest . +docker build -t roboquant/jupyter:1.3.0 -t roboquant/jupyter:latest . diff --git a/binder/Dockerfile b/binder/Dockerfile index 2c47883..de00af1 100644 --- a/binder/Dockerfile +++ b/binder/Dockerfile @@ -1 +1 @@ -FROM roboquant/jupyter:1.2.1 +FROM roboquant/jupyter:1.3.0 diff --git a/notebooks/alpaca.ipynb b/notebooks/alpaca.ipynb index d08d271..9986f40 100644 --- a/notebooks/alpaca.ipynb +++ b/notebooks/alpaca.ipynb @@ -28,7 +28,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=extra)\n", + "%use roboquant(version=1.3.0, modules=extra)\n", "\n", "import org.roboquant.alpaca.*\n", "Welcome()" diff --git a/notebooks/backtest.ipynb b/notebooks/backtest.ipynb index a48d068..3241b3c 100644 --- a/notebooks/backtest.ipynb +++ b/notebooks/backtest.ipynb @@ -19,7 +19,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/basic.ipynb b/notebooks/basic.ipynb index ad079a7..c3d24fd 100644 --- a/notebooks/basic.ipynb +++ b/notebooks/basic.ipynb @@ -16,7 +16,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/binance.ipynb b/notebooks/binance.ipynb index 5c16571..288dde7 100644 --- a/notebooks/binance.ipynb +++ b/notebooks/binance.ipynb @@ -28,7 +28,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=crypto)\n", + "%use roboquant(version=1.3.0, modules=crypto)\n", "\n", "// import binance package\n", "import org.roboquant.binance.*\n", diff --git a/notebooks/charts.ipynb b/notebooks/charts.ipynb index 69895c2..c1ec940 100644 --- a/notebooks/charts.ipynb +++ b/notebooks/charts.ipynb @@ -31,7 +31,7 @@ }, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, @@ -79,7 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "val timeframe = Timeframe.past(1.years)\n", + "val timeframe = Timeframe.fromYears(2022, 2023)\n", "AssetPerformanceChart(feed, timeframe = timeframe)" ] }, @@ -99,18 +99,32 @@ }, "outputs": [], "source": [ - "val apple = feed.assets.getBySymbol(\"AAPL\")\n", - "PriceChart(feed, apple, timeframe = timeframe)" + "PriceChart(feed, \"AAPL\", timeframe = timeframe)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Price-bar Chart\n", - "Roboquant charts aren't designed to be a tool where you manually draw support lines on candlestick charts to make trading decisions. But that doesn't mean candlesticks cannot come in handy. For example to validate if the data in a feed is not corrupted or has some other strange anomalies. This time we don't supply a timeframe, so all prices in the feed will be displayed. \n", + "## Price Chart\n", + "Roboquant charts aren't designed to be a tool where you manually draw support lines on price charts to make trading decisions. But that doesn't mean price charts cannot come in handy. For example to validate if the data in a feed is not corrupted or has some other strange anomalies. \n", + "\n", + "There are two type of price charts:\n", + "\n", + "1. PriceChart, this one support any type of pricing info\n", + "2. PriecBarChart, that only support price-bars (candlestick) data\n", "\n", - "In the top right part of the plotted graph there is a toolbox that you can use to zoom into a particular area of interest." + "\n", + "If we don't supply a timeframe, so all prices in the feed will be displayed. In the top right part of the plotted graph there is a toolbox that you can use to zoom into a particular area of interest." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "PriceChart(feed, \"TSLA\", priceType = \"OPEN\")" ] }, { @@ -121,7 +135,7 @@ }, "outputs": [], "source": [ - "PriceBarChart(feed, apple)" + "PriceBarChart(feed, \"AAPL\")" ] }, { @@ -225,8 +239,8 @@ }, "outputs": [], "source": [ - "val chart = TradeAssetChart(account.trades.takeLast(100))\n", - "chart.height = 1000\n", + "val chart = TradeAssetChart(account.trades.takeLast(40))\n", + "chart.height = 600\n", "chart" ] }, @@ -247,7 +261,7 @@ "metadata": {}, "outputs": [], "source": [ - "PriceBarChart(feed, apple, account.trades)" + "PriceBarChart(feed, \"AAPL\", account.trades)" ] }, { @@ -380,7 +394,7 @@ }, "outputs": [], "source": [ - "val timeframe = Timeframe.past(2.years)\n", + "val timeframe = Timeframe.fromYears(2021,2023)\n", "val data2 = data.filter { timeframe.contains(it.info.time) }\n", "MetricCalendarChart(data2.diff())" ] @@ -434,7 +448,7 @@ "source": [ "roboquant.reset()\n", "\n", - "feed.timeframe.sample(6.months, 25).forEach {\n", + "feed.timeframe.sample(6.months, 50).forEach {\n", " roboquant.run(feed, it) \n", "}" ] diff --git a/notebooks/crypto.ipynb b/notebooks/crypto.ipynb index 29c8b46..d448962 100644 --- a/notebooks/crypto.ipynb +++ b/notebooks/crypto.ipynb @@ -16,7 +16,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=crypto)\n", + "%use roboquant(version=1.3.0, modules=crypto)\n", "\n", "import org.roboquant.xchange.*\n", "Welcome()" diff --git a/notebooks/discord.ipynb b/notebooks/discord.ipynb index 619ca9f..e4651c6 100644 --- a/notebooks/discord.ipynb +++ b/notebooks/discord.ipynb @@ -25,7 +25,7 @@ }, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=crypto)\n", + "%use roboquant(version=1.3.0, modules=crypto)\n", "\n", "// Load the JDA library and import the required classes\n", "@file:DependsOn(\"net.dv8tion:JDA:5.0.0-beta.4\")\n", diff --git a/notebooks/empty.ipynb b/notebooks/empty.ipynb index d3f28f2..951b294 100644 --- a/notebooks/empty.ipynb +++ b/notebooks/empty.ipynb @@ -16,7 +16,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/forex.ipynb b/notebooks/forex.ipynb index e0b606e..4f80298 100644 --- a/notebooks/forex.ipynb +++ b/notebooks/forex.ipynb @@ -16,7 +16,7 @@ }, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/ibkr.ipynb b/notebooks/ibkr.ipynb index 6609605..a1df390 100644 --- a/notebooks/ibkr.ipynb +++ b/notebooks/ibkr.ipynb @@ -58,7 +58,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=ibkr)\n", + "%use roboquant(version=1.3.0, modules=ibkr)\n", "import org.roboquant.ibkr.*\n", "Welcome()" ] diff --git a/notebooks/oanda.ipynb b/notebooks/oanda.ipynb index 66781c6..6928de3 100644 --- a/notebooks/oanda.ipynb +++ b/notebooks/oanda.ipynb @@ -22,7 +22,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=extra)\n", + "%use roboquant(version=1.3.0, modules=extra)\n", "\n", "// By default the required OANDA classes are not imported, so we need to do that first. \n", "// This import will load the various Feed and Broker classes for integrating with OANDA.\n", diff --git a/notebooks/policies.ipynb b/notebooks/policies.ipynb index e070e38..124bd28 100644 --- a/notebooks/policies.ipynb +++ b/notebooks/policies.ipynb @@ -17,7 +17,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/preload.ipynb b/notebooks/preload.ipynb index 6b872e3..e6f88c8 100644 --- a/notebooks/preload.ipynb +++ b/notebooks/preload.ipynb @@ -15,7 +15,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(version=1.3.0-SNAPSHOT, modules=extra:crypto:ibkr)" + "%use roboquant(version=1.3.0, modules=extra:crypto:ibkr)" ] }, { diff --git a/notebooks/strategies.ipynb b/notebooks/strategies.ipynb index 713fcdc..f5c1247 100644 --- a/notebooks/strategies.ipynb +++ b/notebooks/strategies.ipynb @@ -25,7 +25,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/tech-analysis.ipynb b/notebooks/tech-analysis.ipynb index d74a6d7..470d7bc 100644 --- a/notebooks/tech-analysis.ipynb +++ b/notebooks/tech-analysis.ipynb @@ -18,7 +18,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/xgboost.ipynb b/notebooks/xgboost.ipynb index 223b9b4..a2c06df 100644 --- a/notebooks/xgboost.ipynb +++ b/notebooks/xgboost.ipynb @@ -19,7 +19,7 @@ "metadata": {}, "outputs": [], "source": [ - "%use roboquant(1.3.0-SNAPSHOT)\n", + "%use roboquant(1.3.0)\n", "Welcome()" ] }, diff --git a/notebooks/yahoo.ipynb b/notebooks/yahoo.ipynb index 39eed89..78b176c 100644 --- a/notebooks/yahoo.ipynb +++ b/notebooks/yahoo.ipynb @@ -15,7 +15,7 @@ "outputs": [], "source": [ "// YahooHistoricFeed is part of the roboquant-extra module, so we include that also\n", - "%use roboquant(version=1.3.0-SNAPSHOT, modules=extra)\n", + "%use roboquant(version=1.3.0, modules=extra)\n", "\n", "\n", "// and we import the yahoo package\n",