Skip to content

Commit

Permalink
Chore/update version readme (#105)
Browse files Browse the repository at this point in the history
Adding scripts to automatically update README.md with new
version/release number and keep README.tex.md updated
  • Loading branch information
fmilthaler authored Jul 17, 2023
1 parent 562d9ca commit 13217b5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 0 additions & 1 deletion README.tex.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,3 @@ Furthermore, it is also shown how the entire *Efficient Frontier* and the optima
Also, the optimisation of a portfolio and its visualisation based on a *Monte Carlo* is shown.

Finally, *FinQuant*'s visualisation methods allow for overlays, if this is desired. Thus, with only the following few lines of code, one can create an overlay of the *Monte Carlo* run, the *Efficient Frontier*, its optimised portfolios for *Minimum Volatility* and *Maximum Sharpe Ratio*, as well as the portfolio's individual stocks.

27 changes: 27 additions & 0 deletions scripts/update_readme.tex.md.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

replace_patterns() {
local file_path="$1"

# Copy README.md to README.tex.md
cp README.md "$file_path"

# Read the contents of README.tex.md
local content=$(<"$file_path")

# Replace patterns
content=$(echo "$content" | sed -E "s/<img src=\"(.*?)\" align=middle width=194.52263655pt height=46.976899200000005pt\/>/\$\\\\displaystyle\\\\dfrac{\\\\text{price}_{t_i} - \\\\text{price}_{t_0} + \\\\text{dividend}}{\\\\text{price}_{t_0}}\$/")

content=$(echo "$content" | sed -E "s/<img src=\"(.*?)\" align=middle width=126.07712039999997pt height=48.84266309999997pt\/>/\$\\\\displaystyle\\\\dfrac{\\\\text{price}_{t_i} - \\\\text{price}_{t_{i-1}}}{\\\\text{price}_{t_{i-1}}}\$/")

content=$(echo "$content" | sed -E "s/<img src=\"(.*?)\" align=middle width=208.3327686pt height=57.53473439999999pt\/>/\$\\\\displaystyle\\\\log\\\\left(1 + \\\\dfrac{\\\\text{price}_{t_i} - \\\\text{price}_{t_{i-1}}}{\\\\text{price}_{t_{i-1}}}\\\\right)\$/")

# Write the updated contents back to README.tex.md
echo "$content" > "$file_path"
}

# Specify the file path for README.tex.md
tex_file_path="README.tex.md"

# Call the function to perform the replacements
replace_patterns "$tex_file_path"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
update_version_readme() {
local version_file="version"
local readme_md="README.md"
local readme_tex="README.tex.md"

# Read the current version from the "version" file
local current_version=$(grep -Eo 'version=([0-9]+\.){2}[0-9]+' "$version_file" | cut -d'=' -f2)
Expand All @@ -16,9 +15,6 @@ update_version_readme() {

# Update version in README.md
update_file "$readme_md"

# Update version in README.tex
update_file "$readme_tex"
}

# Call the update_version function
Expand Down

0 comments on commit 13217b5

Please sign in to comment.