Files
raptor-trading/test_new_uid.py

20 lines
826 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
from datetime import datetime, timezone
from dotenv import load_dotenv
from t_tech.invest import Client
os.environ['SSL_CERT_FILE'] = '/etc/ssl/certs/ca-certificates.crt'
os.environ['GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'] = '/etc/ssl/certs/ca-certificates.crt'
load_dotenv("tok.env")
TOKEN = os.getenv("TINKOFF_TOKEN")
# НОВЫЙ UID ОТ ПОДДЕРЖКИ
SBER_UID = "e6123145-9665-43e0-8413-cd61b8aa9b13"
with Client(TOKEN, target="invest-public-api.tbank.ru:443") as client:
lp = client.market_data.get_last_prices(instrument_id=[SBER_UID]).last_prices[0]
price = lp.price.units + lp.price.nano / 1e9
print(f"\n--- РЕЗУЛЬТАТ ---")
print(f"Актуальная цена SBER: {price} руб.")
print(f"Дата и время цены: {lp.time.strftime('%Y-%m-%d %H:%M:%S')} UTC")