Обновить конфигурацию: исправить коридор отклонения, изменить идентификатор аккаунта, добавить загрузку конфигурации из YAML
This commit is contained in:
@@ -17,4 +17,4 @@ TARGET_WEIGHTS = {
|
||||
"ROSN": Decimal("0.05"),
|
||||
}
|
||||
|
||||
CORRIDOR = Decimal("0.02") # 3% коридор отклонения от целевой доли
|
||||
CORRIDOR = Decimal("0.02") # 2% коридор отклонения от целевой доли
|
||||
|
||||
21
app/load_config.py
Normal file
21
app/load_config.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import yaml
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
def load_config(config_path: str) -> dict:
|
||||
with open(config_path, "r") as file:
|
||||
data = yaml.safe_load(file)
|
||||
|
||||
target_weights = {
|
||||
ticker: Decimal(str(weight)) for ticker, weight in data["portfolio"].items
|
||||
}
|
||||
|
||||
config = {
|
||||
"account_id": data["account"]["id"],
|
||||
"is_sandbox": data["account"]["is_sandbox"],
|
||||
"corridor": Decimal(str(data["settings"]["corridor"])),
|
||||
"dry_run": data["settings"]["dry_run"],
|
||||
"target_weights": target_weights,
|
||||
}
|
||||
|
||||
return config
|
||||
@@ -10,10 +10,10 @@ load_dotenv()
|
||||
|
||||
|
||||
def main():
|
||||
with SandboxClient(token=os.getenv("TINVEST_TOKEN")) as client: # type: ignore
|
||||
with Client(token=os.getenv("TINVEST_TOKEN")) as client: # type: ignore
|
||||
bot = RebalanceBot(
|
||||
client=client,
|
||||
account_id="bb29bb79-8cf1-42ba-843f-47ef76c5b7c0",
|
||||
account_id="2235046505",
|
||||
target_weights=TARGET_WEIGHTS,
|
||||
corridor=CORRIDOR,
|
||||
dry_run=True,
|
||||
@@ -30,3 +30,5 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
# with Client(token=os.getenv("TINVEST_TOKEN")) as client:
|
||||
# print(client.users.get_accounts())
|
||||
|
||||
@@ -71,6 +71,7 @@ class RebalanceBot:
|
||||
if lots != 0:
|
||||
plan.append(
|
||||
{
|
||||
"figi": pos.figi,
|
||||
"ticker": ticker,
|
||||
"uid": uid,
|
||||
"action": "BUY" if lots > 0 else "SELL",
|
||||
|
||||
Reference in New Issue
Block a user