Example #1
0
 def get_portfolio_positions(self) \
             -> List[tinvest.schemas.PortfolioPosition]:
     """Возвращает все позиции в портфеле"""
     positions = tinvest.PortfolioApi(self._client)\
         .portfolio_get(broker_account_id=self._broker_account_id)\
         .parse_json().payload.positions
     return positions
Example #2
0
def greeting():
    client = tinvest.SyncClient(TOKEN)
    api = tinvest.PortfolioApi(client)

    response = api.portfolio_get()  # requests.Response
    if response.status_code == 200:
        print(response.parse_json())  # tinvest.PortfolioResponse
Example #3
0
import argparse
import pickle
import time
from datetime import datetime
from typing import List

import tinvest
from constants import (TOKEN, MAX_PRICE_USD, USD_TO_RUB, PARSED_BONDS_FILE,
                       MIN_RATIO, DEBUG)
from tinvest.schemas import (LimitOrderRequest, MarketInstrument,
                             OperationType, Currency, OperationStatus,
                             OrderResponse, Orderbook)

client = tinvest.SyncClient(TOKEN)
portfolio = tinvest.PortfolioApi(client)
market = tinvest.MarketApi(client)
orders = tinvest.OrdersApi(client)


def round_float(x: float):
    return round(x, 3)


def print_log(param: str):
    if DEBUG:
        print(param)


class CompanyData:
    def __init__(self,
                 figi: str,
Example #4
0
def get_portfolio() -> list:
    api = tinvest.PortfolioApi(client)
    response = api.portfolio_get()
    positions = response.parse_json().payload.positions
    return positions