WIP
This commit is contained in:
84
main.py
84
main.py
@@ -1,6 +1,7 @@
|
||||
|
||||
import functions
|
||||
import config
|
||||
import imp
|
||||
|
||||
while True:
|
||||
|
||||
@@ -43,27 +44,6 @@ while True:
|
||||
|
||||
|
||||
|
||||
# ----------------------------------------- #
|
||||
# PART 2: 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)
|
||||
|
||||
# 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)
|
||||
|
||||
###
|
||||
# ICH BIN MIR UNSICHER, WIE ICH HIERMIT WEITER MACHEN SOLL
|
||||
# ICH GLAUBE, ICH MUSS DIE HISTORY PER BENCHMARK-TICKER UND PER TICKER MERGEN
|
||||
# DANN HABE ICH ABER DAS PROBLEM, DASS ICH DIE ECHTEN TRADES NICHT VON DEN BENCHMARKS UNTERSCHEIDEN KANN
|
||||
###
|
||||
|
||||
|
||||
# ------------------------------------------------ #
|
||||
# PART 2: Updating the notion investments database #
|
||||
# ------------------------------------------------ #
|
||||
@@ -73,7 +53,7 @@ while True:
|
||||
|
||||
# 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)
|
||||
history_per_ticker = functions.calc_history_per_ticker(history_per_trade, tickers, trades)
|
||||
|
||||
# Configuration dependent execution:
|
||||
if config.update_notion == True:
|
||||
@@ -87,8 +67,32 @@ while 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 3: Updating the TRMNL Screen #
|
||||
# PART 4: Updating the TRMNL Screen #
|
||||
# --------------------------------- #
|
||||
# Configuration dependent execution:
|
||||
if config.update_TRMNL == True:
|
||||
@@ -107,7 +111,7 @@ while True:
|
||||
history_per_ticker_filtered,
|
||||
series_to_show_1="total",
|
||||
data_to_show_1="current_value",
|
||||
series_to_show_2="DBPG.DE",
|
||||
series_to_show_2="benchmark",
|
||||
data_to_show_2="current_value"
|
||||
)
|
||||
|
||||
@@ -121,7 +125,7 @@ while True:
|
||||
history_per_ticker_filtered,
|
||||
series_to_show_1="total",
|
||||
data_to_show_1="current_irr",
|
||||
series_to_show_2="DBPG.DE",
|
||||
series_to_show_2="benchmark",
|
||||
data_to_show_2="current_irr"
|
||||
)
|
||||
|
||||
@@ -129,20 +133,38 @@ while True:
|
||||
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 4: Cool off and repeat #
|
||||
# PART 5: Cool off and repeat #
|
||||
# --------------------------- #
|
||||
# Logging
|
||||
print("Completed cycle at: {}".format(functions.datetime.datetime.now()))
|
||||
print("Waiting a few minutes before the next execution")
|
||||
print("---------------------------------------------------------------------------")
|
||||
|
||||
# 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)
|
||||
Reference in New Issue
Block a user