TinkoffInvestmentsが言っていないこと。APIを介してポートフォリオのすべてのデータを大きなExcelテーブルに引き出します

Tinkoff Investmentsは、モバイルデバイスとブラウザ用の高度なクライアントアプリケーションを備えた人気のロシアのブローカーです。このアプリケーションは、取引プロセスを簡素化し、投資を入力するためのしきい値を最小限に抑えて、可能な限り幅広いオーディエンスを獲得するように設計されています。





ただし、投資が深刻になると、投資家は、特に投資の有効性を評価するために、ポートフォリオに関する正確で詳細なデータを必要とします。そして、これはアプリケーションであいまいさが生じる場所です。





問題の説明

モバイルアプリケーションでのポートフォリオ(IISではない)の例を使用して検討します。(発行日から、申請書が更新される場合があります)。





メイン画面には、心強い意味があります。





私はすぐにここに質問があります:





  • このグリーン量と12.21%はどのように計算されましたか?さらに、数日前に私は約+ 17%の何かを持っていました、そして私は利益で1つの証券を修正しました、ポートフォリオの価値はほとんど変わりませんでした、しかしこの緑の「合計パーセンテージ」はすぐに12.21に落ちました。





  • ずっと-それは数年以上の投資ですか?オプションもあります:今日のために。そして、たとえば1年間、何パーセントありますか?





  • 私のポートフォリオはほぼ完全に外国証券と米ドルです。それはどのようにルーブルに変換されましたか:中央銀行の為替レートまたは市場で?





  • ポートフォリオ全体を売却してお金を引き出すと、税金と手数料を差し引いた後、実際にこの金額のどれくらいが得られますか?





, :





+955 644, 2 ?





, , , .





, .





! -.





. 4 +6,67%, 2020 , +31,41%. , , S&P 500 2020 16,26%. , , . , +12,21% , .. 2019 2018 . , , , .





, , :





  • , ,









  • ,





  • , ,





, , , , . , USD , .





  • , Excel, Excel Google Sheets.





, , . , .





Tinkoff API - , .





, API . , .





API

Open API :





https://tinkoffcreditsystems.github.io/invest-openapi/





SDK: Java, C#, Go, NodeJS.





: Python @daxartio,Python @Awethon, Python @Fatal1ty, PHP, Ruby.





, . , DIY Arduino- WiFi, , WEB- - . .., Arduino Wiring ( C++).





Python, - print('Hello World')



. , , API Python.





.





.





: , API.





, :





  • Python









  • PIP tinvest





, Idle, :





import tinvest







API:





client = tinvest.SyncClient(account_data['my_token'])







my_token API key, .





-, API .





:





positions = client.get_portfolio()



, .





. .





operations = client.get_operations(from_=account_data['start_date'], to=account_data['now_date'])







( ):





course_usd = client.get_market_orderbook(figi='BBG0013HGFT4', depth=20







course_eur = client.get_market_orderbook(figi='BBG0013HJJ31', depth=20)







, , :





currencies = client.get_portfolio_currencies()







print



, :





for pos in positions.payload.positions:







print('name:', pos.name)







print('ticker:', pos.ticker)







print('balance:', pos.balance)







print('currency:', pos.average_position_price.currency)







print('price:', pos.average_position_price.value)







print(' ')







- Excel . XlsxWriter:





https://xlsxwriter.readthedocs.io/





import xlsxwriter







excel . - . , , , / :





ecxelFileName = 'tinkoffReport_' + today + '.xlsx'







workbook = xlsxwriter.Workbook(ecxelFileName)







worksheet = workbook.add_worksheet()







, , , , API, :





, , , , , .





: .





Idle, - : ( !)





繰り返さないでください

Python, , , -, .





, , .





Python

, PyCharm.





, PEP8 ( ).





Python : https://www.w3schools.com/





, .





, , . . , , - , , . , , . , https://stackoverflow.com/





3 ( .py) .txt .





main.py - , . , , . API .





data_parser.py - , , .





excel_builder.py - , , main.py .





-

:





(, API):





name -





ticker -





balance -





currency -





ave.price -





exp.yield - ( )





, , , 955 644 (+12,21%) - exp.yield .





, :





market price - (ave.price + exp.yield)





% change - (market_price / ave.price) * 100) - 100)





market value - (market_price * balance)





market value RUB - ( )





ave. % - % change. , . -, .





total value: - ( market value RUB)





, total value 8 782 836, : 8 782 160, --. 0,0077%. , , . - , , .





- !





, , , : .





CB value RUB - .





, 8 749 045 - , , 33 791 , .





ave.buy in RUB - . .





, , , . , , .





, (). , figi , , . , . . , .





, , Tinkoff API , , .





API , , . , , . 15 430 , 1 .





- , , , .





, :





sum.buy in RUB - (ave.buy in RUB * balance)





, 7 178 123 - , , .





tax base - (sum.buy in RUB - CB value RUB)





expected tax - 13%, , .





: 207 145 . - , .





-

, , Tinkoff API. , , :





. , . - .





( )





, , :





, , , !





, .





.





-

.





Investing period - , . , .





, , , - .





PayIn - PayOut - . 5 843 172 - .





Commissions payed - , . 17 315 , 2200 - 2% IPO , . , 15 000 , , , . $1000 18,22 .





, - "" IPO . API .





Taxes payed - , . , , , .





, W8BEN, , , , .





, 117 631 , , , 207, .





: , $100 60 , , 80, $100, 260 , , , 6000, 8000, $ .





Clean portfolio - . , , . , , . , $116000 , - 2000. , . , .





Profit - , . Clean portfolio - (PayIn - PayOut), .., , , . 2 732 519, " " " " , 207. 2500 . , .





-, , .





. , . , , , , , . - XIRR Excel, , . - , .





, , , .





, , , .





, , .





: Excel, Excel, Google Sheets, .





GitHub





.exe , Python , ( , , ).





Python .





この情報が、Tinkoffアプリケーションとの相互作用の改善、APIの操作、および同様のプログラムの開発に役立つだけでなく、より多くの情報に基づいた投資に貢献し、それによってあなたの幸福を高めることを願っています。最後までお読みいただきありがとうございます。








All Articles