{"id":548,"date":"2020-05-25T06:45:20","date_gmt":"2020-05-25T06:45:20","guid":{"rendered":"http:\/\/datadigging.ru\/?p=548"},"modified":"2020-05-25T06:55:31","modified_gmt":"2020-05-25T06:55:31","slug":"%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d1%8f-%d1%80%d0%b0%d1%81%d1%87%d0%b5%d1%82%d0%b0-twr-time-weighted-return","status":"publish","type":"post","link":"https:\/\/datadigging.ru\/?p=548","title":{"rendered":"\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 TWR (time weighted return)"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def twr_eavaluate(df):\n    \n    \"\"\"\u0424-\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 time weighted return  \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430 ['AUM_DATE', 'POSITION_VALUE','NET_INPUT']\n\n     AUM_DATE - \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438\n     POSITION_VALUE - \u043e\u0446\u0435\u043d\u043e\u0447\u043d\u0430\u044f  \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044f \u043d\u0430 \u0434\u0430\u0442\u0443\n     NET_INPUT - \u0432\u0432\u043e\u0434\u044b-\u0432\u044b\u0432\u043e\u0434\u044b \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u043d\u0430 \u0434\u0430\u0442\u0443 (\u0432\u0432\u043e\u0434 - \u0432\u044b\u0432\u043e\u0434)\"\"\"\n\n    df.sort_values(by='AUM_DATE', inplace=True)\n\n    # \u043f\u043e\u0440\u0444\u0442\u0435\u043b\u044c \u043d\u0430  \u0434\u0435\u043d\u044c-1\n    prev_portf = [0] + df['POSITION_VALUE'].tolist()[:-1]\n    df['prev_portf'] = prev_portf\n\n    df['delta_for_twr'] = (df['POSITION_VALUE'] - df['NET_INPUT']) \/ df['prev_portf']\n\n    # \u0437\u0430\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432\n    df = df.replace([np.inf, -np.inf], np.nan)\n    df.dropna(axis=0, subset=['delta_for_twr'], inplace=True)\n    twr = df['delta_for_twr'].prod() - 1\n    return twr\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 TWR (time-weighted return)  \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f   \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0432\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 TWR (time-weighted return) \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0432\u043e\u0434\u043e\u0432 \u0438 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[12,9,16,59,58],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-pandas","tag-python","tag-16","tag-59","tag-58"],"_links":{"self":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=548"}],"version-history":[{"count":1,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions"}],"predecessor-version":[{"id":549,"href":"https:\/\/datadigging.ru\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions\/549"}],"wp:attachment":[{"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadigging.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}