Refactor code structure for improved readability and maintainability

This commit is contained in:
Dmitry
2026-01-03 15:20:57 +03:00
commit 90295d21e6
10 changed files with 498 additions and 0 deletions

32
app/main.py Normal file
View File

@@ -0,0 +1,32 @@
import os
from dotenv import load_dotenv
from t_tech.invest import Client
from t_tech.invest.sandbox.client import SandboxClient
from rebalance import RebalanceBot
from config import TARGET_WEIGHTS, CORRIDOR
load_dotenv()
def main():
with SandboxClient(token=os.getenv("TINVEST_TOKEN")) as client: # type: ignore
bot = RebalanceBot(
client=client,
account_id="bb29bb79-8cf1-42ba-843f-47ef76c5b7c0",
target_weights=TARGET_WEIGHTS,
corridor=CORRIDOR,
dry_run=True,
)
plan = bot.calculate_rebalance(bot.fetch_portfolio())
sales = [trade for trade in plan if trade["action"] == "SELL"]
buys = [trade for trade in plan if trade["action"] == "BUY"]
bot.execute_orders(sales, "ПРОДАЖИ")
bot.execute_orders(buys, "ПОКУПКИ")
if __name__ == "__main__":
main()