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()