v2.0 Major Release and end of beta

This commit is contained in:
2026-01-21 22:23:32 +01:00
parent a82642d454
commit ce8c362a2c
151 changed files with 1501 additions and 1961796 deletions

View File

@@ -0,0 +1,42 @@
### --------- PROGRAMM CONFIGUARTION
# Program Functionality Switch
update_notion = True
update_TRMNL = True
calculate_benchmark = True
# Program Functionality Configuration
programm_cooldown_time = 15 # Programm cooldown timer in minutes
api_cooldowm_time = 0.1 # API cooldown timer in minutes
trmnl_granularity = 80 # Days in between two data points in the TRMNL chart
ticker_benchmark = "VGWL.DE" # Ticker to benchmark the trades against
# Programm Execution Configuration
selected_logging_level = "warning" # must be one from the list below
logging_levels = ("none", "error", "success", "warning", "info", "debug") # ordered by amount of logs
class log_colors:
error = '\033[91m'
warning = '\033[93m'
success = '\033[92m'
info = '\033[90m'
debug = '\033[4m'
endcode = '\033[0m'
### --------- API CONFIGURATION
# NOTION
notion_token = "secret_b7PiPL2FqC9QEikqkAEWOht7LmzPMIJMWTzUPWwbw4H"
notion_headers = {
"Authorization": "Bearer " + notion_token,
"Content-Type": "application/json",
"Notion-Version": "2022-02-22"
}
notion_db_id_trades = "95f7a2b697a249d4892d60d855d31bda"
notion_db_id_investments = "2ba10a5f51bd8160ab9ee982bbef8cc3"
notion_db_id_performance = "1c010a5f51bd806f90d8e76a1286cfd4"
# TRMNL
trmnl_headers = {"Content-Type": "application/json"}
trmnl_url_chart_1 = "https://usetrmnl.com/api/custom_plugins/334ea2ed-1f20-459a-bea5-dca2c8cf7714"
trmnl_url_chart_2 = "https://usetrmnl.com/api/custom_plugins/72950759-38df-49eb-99fb-b3e2e67c385e"
trmnl_url_chart_3 = "https://usetrmnl.com/api/custom_plugins/a975543a-51dc-4793-b7fa-d6a101dc4025"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,170 @@
import functions
import config
import imp
while True:
# ------------------------------------------- #
# PART 1: Updating the notion trades database #
# ------------------------------------------- #
# Fetches the list of all trades stored in notion
print("Fetching Data from Notion...", end=" ", flush=True)
trades = functions.fetch_format_notion_trades(config.notion_db_id_trades)
# Generates a list with unique tickers and no duplicates to reduce workload for the yfinance api
print("Creating a list of unique tickers...", end=" ", flush=True)
tickers = functions.filter_list_of_tickers(trades)
# Configuration dependent execution:
if config.calculate_benchmark == True:
# Add the benchmark-ticker to the list of tickers to download data from yfinance from
print("Adding benchmark-ticker...", end="", flush=True)
tickers = functions.add_benchmark_ticker(tickers, config.ticker_benchmark)
# Fetches & formats the complete history per ticker from yfinance
print("Fetching & formating yfinance data", end="", flush=True)
yf_data = functions.fetch_format_yf_data(tickers)
# Calculates & stores a history per trade
print("Calculating the history per trade...", end=" ", flush=True)
history_per_trade = functions.calc_history_per_trade(trades, yf_data)
# Configuration dependent execution:
if config.update_notion == True:
# Selects the most current values from the history per trade and overwrites them in the "trades" feteched from notion
print("Selecting the most current values...", end=" ", flush=True)
trades = functions.select_current_value_per_trade(trades, history_per_trade)
# Updates the values in the notion database
print("Updating the notion trades database", end="", flush=True)
functions.push_notion_trades_update(trades)
# ------------------------------------------------ #
# PART 2: Updating the notion investments database #
# ------------------------------------------------ #
# Fetches the list of entries in the investment-overview database stored in notion
print("Fetching & formating notion investments...", end=" ", flush=True)
investments = functions.fetch_format_notion_investments(config.notion_db_id_investments)
# Calculates & stores a history per ticker AND a total across all tickers indexed by the ticker name
print("Calculating history per ticker...", end=" ", flush=True)
history_per_ticker = functions.calc_history_per_ticker(history_per_trade, tickers, trades)
# Configuration dependent execution:
if config.update_notion == True:
# Selects the most current values from the history per ticker and overwrites them in the "investments" feteched from notion
print("Calculating current value per ticker...", end=" ", flush=True)
investments = functions.select_current_value_per_ticker(investments, history_per_ticker)
# Updates the values in the notion database
print("Updating the notion ticker database", end="", flush=True)
functions.push_notion_investment_update(investments)
# ----------------------------------------- #
# PART 3: Calculating Benchmark performance #
# ----------------------------------------- #
# Configuration dependent execution:
if config.calculate_benchmark == True:
# Creating benchmark trades
print("Creating 'benchmark trades'...", end="", flush=True)
benchmark_trades = functions.create_benchmark_trades(trades, yf_data)
# Calculating benchmark trades
print("Calculating the history per benchmark-trade...", end=" ", flush=True)
history_per_benchmark_trade = functions.calc_history_per_trade(benchmark_trades, yf_data)
# Calculates & stores a history for the benchmark
print("Calculating benchmark-history overall...", end=" ", flush=True)
history_benchmark = functions.calc_history_per_ticker(history_per_benchmark_trade, tickers, benchmark_trades)
# Merging the benchmark_history into the ticker_history
print("Merging the benchmark-history into the ticker-history...", end=" ", flush=True)
history_per_ticker = functions.merge_histories(history_per_ticker, history_benchmark)
# --------------------------------- #
# PART 4: Updating the TRMNL Screen #
# --------------------------------- #
# Configuration dependent execution:
if config.update_TRMNL == True:
# Creates a list containing one date per week
print("Creating a list with one entry per week...", end=" ", flush=True)
list_filtered_dates = functions.create_list_filtered_dates(trades, config.trmnl_granularity)
# Filter a weekly snapshot from the history per ticker
print("Filtering the history per ticker to weekly values...", end=" ", flush=True)
history_per_ticker_filtered = functions.filter_history_by_list(history_per_ticker, list_filtered_dates)
# Prepare a new TRMNL update
print("Constructing a TERMNL update object...", end=" ", flush=True)
trmnl_update_object = functions.prep_trmnl_chart_udpate(
history_per_ticker_filtered,
series_to_show_1="total",
data_to_show_1="current_value",
series_to_show_2="benchmark",
data_to_show_2="current_value"
)
# Push the update to TRMNL
print("Updating a TERMNL screen...", end=" ", flush=True)
functions.push_trmnl_update_chart(trmnl_update_object, config.trmnl_url_chart_1, config.trmnl_headers)
# Prepare a new TRMNL update
print("Constructing a TERMNL update object...", end=" ", flush=True)
trmnl_update_object = functions.prep_trmnl_chart_udpate(
history_per_ticker_filtered,
series_to_show_1="total",
data_to_show_1="current_irr",
series_to_show_2="benchmark",
data_to_show_2="current_irr"
)
# Push the update to TRMNL
print("Updating a TERMNL screen...", end=" ", flush=True)
functions.push_trmnl_update_chart(trmnl_update_object, config.trmnl_url_chart_2, config.trmnl_headers)
# Prepare a new TRMNL update
print("Constructing a TERMNL update object...", end=" ", flush=True)
trmnl_update_object = functions.prep_trmnl_chart_udpate(
history_per_ticker_filtered,
series_to_show_1="total",
data_to_show_1="total_performanance",
series_to_show_2="benchmark",
data_to_show_2="total_performanance"
)
# Push the update to TRMNL
print("Updating a TERMNL screen...", end=" ", flush=True)
functions.push_trmnl_update_chart(trmnl_update_object, config.trmnl_url_chart_3, config.trmnl_headers)
# --------------------------- #
# PART 5: Cool off and repeat #
# --------------------------- #
# Clear variables
trades = {}
yf_data = {}
history_per_trade = {}
tickers = []
# Reload config
imp.reload(config)
# Logging
print("Completed cycle at: {}".format(functions.datetime.datetime.now()))
print("Waiting a few minutes before the next execution")
print("---------------------------------------------------------------------------")
# Wait for api-cooldown
functions.time.sleep(config.programm_cooldown_time * 60)