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 Client(token=os.getenv("TINVEST_TOKEN")) as client: # type: ignore bot = RebalanceBot( client=client, account_id="2235046505", target_weights=TARGET_WEIGHTS, corridor=CORRIDOR, dry_run=False, ) 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() # with Client(token=os.getenv("TINVEST_TOKEN")) as client: # print(client.users.get_accounts())