RAPTOR v18.4: Исправлена отчетность, активированы выходные
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import asyncio
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import GetAssetReportsRequest
|
||||
from t_tech.invest.utils import now
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
instruments = await client.instruments.find_instrument(
|
||||
query="Тинькофф Квадратные метры"
|
||||
)
|
||||
instrument = instruments.instruments[0]
|
||||
print(instrument.name)
|
||||
request = GetAssetReportsRequest(
|
||||
instrument_id=instrument.uid,
|
||||
from_=now() - timedelta(days=7),
|
||||
to=now(),
|
||||
)
|
||||
print(await client.instruments.get_asset_reports(request=request))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,24 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import AssetsRequest, InstrumentStatus, InstrumentType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
r = await client.instruments.get_assets(
|
||||
request=AssetsRequest(
|
||||
instrument_type=InstrumentType.INSTRUMENT_TYPE_SHARE,
|
||||
instrument_status=InstrumentStatus.INSTRUMENT_STATUS_BASE,
|
||||
) # pylint:disable=line-too-long
|
||||
)
|
||||
print("BASE SHARE ASSETS")
|
||||
for bond in r.assets:
|
||||
print(bond)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient, InstrumentType
|
||||
from t_tech.invest.schemas import EventType, GetBondEventsRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
bond = (
|
||||
await client.instruments.find_instrument(
|
||||
query="Тинькофф Банк выпуск 1",
|
||||
instrument_kind=InstrumentType.INSTRUMENT_TYPE_BOND,
|
||||
)
|
||||
).instruments[0]
|
||||
|
||||
request = GetBondEventsRequest(
|
||||
instrument_id=bond.uid,
|
||||
type=EventType.EVENT_TYPE_CALL,
|
||||
)
|
||||
print(await client.instruments.get_bond_events(request=request))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
20
invest-python-master/examples/instruments/async_get_bonds.py
Normal file
20
invest-python-master/examples/instruments/async_get_bonds.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import InstrumentExchangeType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
bonds = await client.instruments.bonds(
|
||||
instrument_exchange=InstrumentExchangeType.INSTRUMENT_EXCHANGE_UNSPECIFIED,
|
||||
)
|
||||
for bond in bonds.instruments:
|
||||
print(bond)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,22 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import GetConsensusForecastsRequest, Page
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
request = GetConsensusForecastsRequest(
|
||||
paging=Page(page_number=0, limit=2),
|
||||
)
|
||||
response = await client.instruments.get_consensus_forecasts(request=request)
|
||||
print(response.page)
|
||||
for forecast in response.items:
|
||||
print(forecast.uid, forecast.consensus.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,23 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import GetForecastRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
instrument = (
|
||||
await client.instruments.find_instrument(
|
||||
query="Сбер Банк - привилегированные акции"
|
||||
)
|
||||
).instruments[0]
|
||||
request = GetForecastRequest(instrument_id=instrument.uid)
|
||||
response = await client.instruments.get_forecast_by(request=request)
|
||||
print(instrument.name, response.consensus.recommendation.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,22 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import InstrumentsRequest, InstrumentStatus
|
||||
|
||||
|
||||
async def main():
|
||||
token = os.environ["INVEST_TOKEN"]
|
||||
|
||||
with AsyncClient(token) as client:
|
||||
r = await client.instruments.structured_notes(
|
||||
request=InstrumentsRequest(
|
||||
instrument_status=InstrumentStatus.INSTRUMENT_STATUS_ALL
|
||||
)
|
||||
)
|
||||
for note in r.instruments:
|
||||
print(note)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,21 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import AsyncClient
|
||||
from t_tech.invest.schemas import InstrumentIdType, InstrumentRequest
|
||||
|
||||
|
||||
async def main():
|
||||
token = os.environ["INVEST_TOKEN"]
|
||||
|
||||
with AsyncClient(token) as client:
|
||||
r = await client.instruments.structured_note_by(
|
||||
request=InstrumentRequest(
|
||||
id_type=InstrumentIdType.INSTRUMENT_ID_TYPE_FIGI, id="BBG012S2DCJ8"
|
||||
)
|
||||
)
|
||||
print(r.instrument)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import GetAssetFundamentalsRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
request = GetAssetFundamentalsRequest(
|
||||
assets=["40d89385-a03a-4659-bf4e-d3ecba011782"],
|
||||
)
|
||||
print(client.instruments.get_asset_fundamentals(request=request))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import GetAssetReportsRequest
|
||||
from t_tech.invest.utils import now
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
instruments = client.instruments.find_instrument(
|
||||
query="Тинькофф Квадратные метры"
|
||||
)
|
||||
instrument = instruments.instruments[0]
|
||||
print(instrument.name)
|
||||
request = GetAssetReportsRequest(
|
||||
instrument_id=instrument.uid,
|
||||
from_=now() - timedelta(days=7),
|
||||
to=now(),
|
||||
)
|
||||
print(client.instruments.get_asset_reports(request=request))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
28
invest-python-master/examples/instruments/get_assets.py
Normal file
28
invest-python-master/examples/instruments/get_assets.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import AssetsRequest, InstrumentStatus, InstrumentType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.get_assets(
|
||||
request=AssetsRequest(instrument_type=InstrumentType.INSTRUMENT_TYPE_BOND)
|
||||
)
|
||||
print("BONDS")
|
||||
for bond in r.assets:
|
||||
print(bond)
|
||||
r = client.instruments.get_assets(
|
||||
request=AssetsRequest(
|
||||
instrument_status=InstrumentStatus.INSTRUMENT_STATUS_BASE
|
||||
)
|
||||
)
|
||||
print("BASE ASSETS")
|
||||
for bond in r.assets:
|
||||
print(bond)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
24
invest-python-master/examples/instruments/get_bond_events.py
Normal file
24
invest-python-master/examples/instruments/get_bond_events.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import EventType, GetBondEventsRequest, InstrumentType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
bond = client.instruments.find_instrument(
|
||||
query="Тинькофф Банк выпуск 1",
|
||||
instrument_kind=InstrumentType.INSTRUMENT_TYPE_BOND,
|
||||
).instruments[0]
|
||||
|
||||
request = GetBondEventsRequest(
|
||||
instrument_id=bond.uid,
|
||||
type=EventType.EVENT_TYPE_CALL,
|
||||
)
|
||||
print(client.instruments.get_bond_events(request=request))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
19
invest-python-master/examples/instruments/get_bonds.py
Normal file
19
invest-python-master/examples/instruments/get_bonds.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import InstrumentExchangeType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.bonds(
|
||||
instrument_exchange=InstrumentExchangeType.INSTRUMENT_EXCHANGE_UNSPECIFIED
|
||||
)
|
||||
for bond in r.instruments:
|
||||
print(bond)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
18
invest-python-master/examples/instruments/get_brands.py
Normal file
18
invest-python-master/examples/instruments/get_brands.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""Example - How to get Brands"""
|
||||
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.get_brands()
|
||||
for brand in r.brands:
|
||||
print(brand)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import (
|
||||
GetAssetReportsRequest,
|
||||
GetConsensusForecastsRequest,
|
||||
InstrumentIdType,
|
||||
Page,
|
||||
)
|
||||
from t_tech.invest.utils import now
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
request = GetConsensusForecastsRequest(
|
||||
paging=Page(page_number=0, limit=2),
|
||||
)
|
||||
response = client.instruments.get_consensus_forecasts(request=request)
|
||||
print(response.page)
|
||||
for forecast in response.items:
|
||||
print(forecast.uid, forecast.consensus.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
20
invest-python-master/examples/instruments/get_dfa_by.py
Normal file
20
invest-python-master/examples/instruments/get_dfa_by.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client, InstrumentIdType, InstrumentRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
dfa = client.instruments.dfa_by(
|
||||
request=InstrumentRequest(
|
||||
id_type=InstrumentIdType.INSTRUMENT_ID_TYPE_POSITION_UID,
|
||||
id="ce604b33-70c7-4609-9f42-075dbd9fe278",
|
||||
)
|
||||
)
|
||||
print(dfa)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
16
invest-python-master/examples/instruments/get_dfas.py
Normal file
16
invest-python-master/examples/instruments/get_dfas.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.dfas()
|
||||
for dfa in r.instruments:
|
||||
print(dfa)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
28
invest-python-master/examples/instruments/get_forecast_by.py
Normal file
28
invest-python-master/examples/instruments/get_forecast_by.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import (
|
||||
GetAssetReportsRequest,
|
||||
GetConsensusForecastsRequest,
|
||||
GetForecastRequest,
|
||||
InstrumentIdType,
|
||||
Page,
|
||||
)
|
||||
from t_tech.invest.utils import now
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
instrument = client.instruments.find_instrument(
|
||||
query="Сбер Банк - привилегированные акции"
|
||||
).instruments[0]
|
||||
request = GetForecastRequest(instrument_id=instrument.uid)
|
||||
response = client.instruments.get_forecast_by(request=request)
|
||||
print(instrument.name, response.consensus.recommendation.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Example - How to get list of insider deals.
|
||||
Request data in loop with batches of 10 records.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import GetInsiderDealsRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
deals = []
|
||||
|
||||
next_cursor = None
|
||||
while True:
|
||||
response = client.instruments.get_insider_deals(
|
||||
request=GetInsiderDealsRequest(
|
||||
instrument_id="BBG004730N88", limit=10, next_cursor=next_cursor
|
||||
)
|
||||
)
|
||||
deals.extend(response.insider_deals)
|
||||
next_cursor = response.next_cursor
|
||||
if not next_cursor:
|
||||
break
|
||||
print("Insider deals:")
|
||||
for deal in deals:
|
||||
print(deal)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
18
invest-python-master/examples/instruments/indicatives.py
Normal file
18
invest-python-master/examples/instruments/indicatives.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import IndicativesRequest
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
request = IndicativesRequest()
|
||||
indicatives = client.instruments.indicatives(request=request)
|
||||
for instrument in indicatives.instruments:
|
||||
print(instrument.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,54 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import (
|
||||
CreateFavoriteGroupRequest,
|
||||
DeleteFavoriteGroupRequest,
|
||||
EditFavoritesActionType as At,
|
||||
EditFavoritesRequestInstrument,
|
||||
GetFavoriteGroupsRequest,
|
||||
)
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.get_favorites()
|
||||
|
||||
print("Список избранных инструментов:")
|
||||
for i in r.favorite_instruments:
|
||||
print(f"{i.uid} - {i.name}")
|
||||
|
||||
request = CreateFavoriteGroupRequest()
|
||||
request.group_name = "My test favorite group"
|
||||
request.group_color = "aa0000" # red color
|
||||
r = client.instruments.create_favorite_group(request=request)
|
||||
group_id = r.group_id
|
||||
print(f"Создана новая группа избранного с ИД: {group_id}")
|
||||
|
||||
client.instruments.edit_favorites(
|
||||
instruments=[EditFavoritesRequestInstrument(instrument_id="BBG001M2SC01")],
|
||||
action_type=At.EDIT_FAVORITES_ACTION_TYPE_ADD,
|
||||
group_id=group_id,
|
||||
)
|
||||
|
||||
request = GetFavoriteGroupsRequest()
|
||||
request.instrument_id = ["BBG001M2SC01"]
|
||||
r = client.instruments.get_favorite_groups(request=request)
|
||||
print(f"Список групп избранного:")
|
||||
for i in r.groups:
|
||||
print(
|
||||
f"{i.group_id} - {i.group_name}. Количество элементов: {i.size}. "
|
||||
f"Содержит выбранный инструмент {request.instrument_id[0]}: "
|
||||
f"{i.contains_instrument} "
|
||||
)
|
||||
|
||||
request = DeleteFavoriteGroupRequest()
|
||||
request.group_id = group_id
|
||||
client.instruments.delete_favorite_group(request=request)
|
||||
print(f"Удалена группа избранного с ИД: {group_id}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client, InstrumentIdType
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.get_instrument_by(
|
||||
id_type=InstrumentIdType.INSTRUMENT_ID_TYPE_TICKER,
|
||||
id="LKOH",
|
||||
class_code="TQBR",
|
||||
)
|
||||
print(r.instrument)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
16
invest-python-master/examples/instruments/instruments.py
Normal file
16
invest-python-master/examples/instruments/instruments.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.find_instrument(query="BBG001M2SC01")
|
||||
for i in r.instruments:
|
||||
print(i)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
16
invest-python-master/examples/instruments/options.py
Normal file
16
invest-python-master/examples/instruments/options.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
def main():
|
||||
with Client(TOKEN) as client:
|
||||
r = client.instruments.options()
|
||||
for instrument in r.instruments:
|
||||
print(instrument)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import InstrumentsRequest, InstrumentStatus
|
||||
|
||||
|
||||
def main():
|
||||
token = os.environ["INVEST_TOKEN"]
|
||||
|
||||
with Client(token) as client:
|
||||
r = client.instruments.structured_notes(
|
||||
request=InstrumentsRequest(
|
||||
instrument_status=InstrumentStatus.INSTRUMENT_STATUS_ALL
|
||||
)
|
||||
)
|
||||
for note in r.instruments:
|
||||
print(note)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
|
||||
from t_tech.invest import Client
|
||||
from t_tech.invest.schemas import InstrumentIdType, InstrumentRequest
|
||||
|
||||
|
||||
def main():
|
||||
token = os.environ["INVEST_TOKEN"]
|
||||
|
||||
with Client(token) as client:
|
||||
r = client.instruments.structured_note_by(
|
||||
request=InstrumentRequest(
|
||||
id_type=InstrumentIdType.INSTRUMENT_ID_TYPE_UID,
|
||||
id="1d7dfabb-9e82-4de4-8add-8475db83d2bd",
|
||||
)
|
||||
)
|
||||
print(r.instrument)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user