Files
t_tech-gyro/app/main.py
Dmitry c9e39b07f0
Some checks failed
Weekly Portfolio Rebalance / rebalance (push) Failing after 41s
Изменить режим выполнения бота на реальный (dry_run=False)
2026-01-06 19:15:15 +03:00

35 lines
974 B
Python

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