partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
request_response
Takes a function or coroutine `func(request) -> response`, and returns an ASGI application.
starlette/routing.py
def request_response(func: typing.Callable) -> ASGIApp: """ Takes a function or coroutine `func(request) -> response`, and returns an ASGI application. """ is_coroutine = asyncio.iscoroutinefunction(func) async def app(scope: Scope, receive: Receive, send: Send) -> None: request = Reque...
def request_response(func: typing.Callable) -> ASGIApp: """ Takes a function or coroutine `func(request) -> response`, and returns an ASGI application. """ is_coroutine = asyncio.iscoroutinefunction(func) async def app(scope: Scope, receive: Receive, send: Send) -> None: request = Reque...
[ "Takes", "a", "function", "or", "coroutine", "func", "(", "request", ")", "-", ">", "response", "and", "returns", "an", "ASGI", "application", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/routing.py#L30-L45
[ "def", "request_response", "(", "func", ":", "typing", ".", "Callable", ")", "->", "ASGIApp", ":", "is_coroutine", "=", "asyncio", ".", "iscoroutinefunction", "(", "func", ")", "async", "def", "app", "(", "scope", ":", "Scope", ",", "receive", ":", "Receiv...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
websocket_session
Takes a coroutine `func(session)`, and returns an ASGI application.
starlette/routing.py
def websocket_session(func: typing.Callable) -> ASGIApp: """ Takes a coroutine `func(session)`, and returns an ASGI application. """ # assert asyncio.iscoroutinefunction(func), "WebSocket endpoints must be async" async def app(scope: Scope, receive: Receive, send: Send) -> None: session = W...
def websocket_session(func: typing.Callable) -> ASGIApp: """ Takes a coroutine `func(session)`, and returns an ASGI application. """ # assert asyncio.iscoroutinefunction(func), "WebSocket endpoints must be async" async def app(scope: Scope, receive: Receive, send: Send) -> None: session = W...
[ "Takes", "a", "coroutine", "func", "(", "session", ")", "and", "returns", "an", "ASGI", "application", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/routing.py#L48-L58
[ "def", "websocket_session", "(", "func", ":", "typing", ".", "Callable", ")", "->", "ASGIApp", ":", "# assert asyncio.iscoroutinefunction(func), \"WebSocket endpoints must be async\"", "async", "def", "app", "(", "scope", ":", "Scope", ",", "receive", ":", "Receive", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
compile_path
Given a path string, like: "/{username:str}", return a three-tuple of (regex, format, {param_name:convertor}). regex: "/(?P<username>[^/]+)" format: "/{username}" convertors: {"username": StringConvertor()}
starlette/routing.py
def compile_path( path: str ) -> typing.Tuple[typing.Pattern, str, typing.Dict[str, Convertor]]: """ Given a path string, like: "/{username:str}", return a three-tuple of (regex, format, {param_name:convertor}). regex: "/(?P<username>[^/]+)" format: "/{username}" convertors: {"user...
def compile_path( path: str ) -> typing.Tuple[typing.Pattern, str, typing.Dict[str, Convertor]]: """ Given a path string, like: "/{username:str}", return a three-tuple of (regex, format, {param_name:convertor}). regex: "/(?P<username>[^/]+)" format: "/{username}" convertors: {"user...
[ "Given", "a", "path", "string", "like", ":", "/", "{", "username", ":", "str", "}", "return", "a", "three", "-", "tuple", "of", "(", "regex", "format", "{", "param_name", ":", "convertor", "}", ")", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/routing.py#L85-L122
[ "def", "compile_path", "(", "path", ":", "str", ")", "->", "typing", ".", "Tuple", "[", "typing", ".", "Pattern", ",", "str", ",", "typing", ".", "Dict", "[", "str", ",", "Convertor", "]", "]", ":", "path_regex", "=", "\"^\"", "path_format", "=", "\"...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
BaseSchemaGenerator.get_endpoints
Given the routes, yields the following information: - path eg: /users/ - http_method one of 'get', 'post', 'put', 'patch', 'delete', 'options' - func method ready to extract the docstring
starlette/schemas.py
def get_endpoints( self, routes: typing.List[BaseRoute] ) -> typing.List[EndpointInfo]: """ Given the routes, yields the following information: - path eg: /users/ - http_method one of 'get', 'post', 'put', 'patch', 'delete', 'options' - func ...
def get_endpoints( self, routes: typing.List[BaseRoute] ) -> typing.List[EndpointInfo]: """ Given the routes, yields the following information: - path eg: /users/ - http_method one of 'get', 'post', 'put', 'patch', 'delete', 'options' - func ...
[ "Given", "the", "routes", "yields", "the", "following", "information", ":" ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/schemas.py#L35-L82
[ "def", "get_endpoints", "(", "self", ",", "routes", ":", "typing", ".", "List", "[", "BaseRoute", "]", ")", "->", "typing", ".", "List", "[", "EndpointInfo", "]", ":", "endpoints_info", ":", "list", "=", "[", "]", "for", "route", "in", "routes", ":", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
BaseSchemaGenerator.parse_docstring
Given a function, parse the docstring as YAML and return a dictionary of info.
starlette/schemas.py
def parse_docstring(self, func_or_method: typing.Callable) -> dict: """ Given a function, parse the docstring as YAML and return a dictionary of info. """ docstring = func_or_method.__doc__ if not docstring: return {} # We support having regular docstrings be...
def parse_docstring(self, func_or_method: typing.Callable) -> dict: """ Given a function, parse the docstring as YAML and return a dictionary of info. """ docstring = func_or_method.__doc__ if not docstring: return {} # We support having regular docstrings be...
[ "Given", "a", "function", "parse", "the", "docstring", "as", "YAML", "and", "return", "a", "dictionary", "of", "info", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/schemas.py#L84-L104
[ "def", "parse_docstring", "(", "self", ",", "func_or_method", ":", "typing", ".", "Callable", ")", "->", "dict", ":", "docstring", "=", "func_or_method", ".", "__doc__", "if", "not", "docstring", ":", "return", "{", "}", "# We support having regular docstrings bef...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
StaticFiles.get_directories
Given `directory` and `packages` arugments, return a list of all the directories that should be used for serving static files from.
starlette/staticfiles.py
def get_directories( self, directory: str = None, packages: typing.List[str] = None ) -> typing.List[str]: """ Given `directory` and `packages` arugments, return a list of all the directories that should be used for serving static files from. """ directories = [] ...
def get_directories( self, directory: str = None, packages: typing.List[str] = None ) -> typing.List[str]: """ Given `directory` and `packages` arugments, return a list of all the directories that should be used for serving static files from. """ directories = [] ...
[ "Given", "directory", "and", "packages", "arugments", "return", "a", "list", "of", "all", "the", "directories", "that", "should", "be", "used", "for", "serving", "static", "files", "from", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/staticfiles.py#L57-L80
[ "def", "get_directories", "(", "self", ",", "directory", ":", "str", "=", "None", ",", "packages", ":", "typing", ".", "List", "[", "str", "]", "=", "None", ")", "->", "typing", ".", "List", "[", "str", "]", ":", "directories", "=", "[", "]", "if",...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
StaticFiles.get_path
Given the ASGI scope, return the `path` string to serve up, with OS specific path seperators, and any '..', '.' components removed.
starlette/staticfiles.py
def get_path(self, scope: Scope) -> str: """ Given the ASGI scope, return the `path` string to serve up, with OS specific path seperators, and any '..', '.' components removed. """ return os.path.normpath(os.path.join(*scope["path"].split("/")))
def get_path(self, scope: Scope) -> str: """ Given the ASGI scope, return the `path` string to serve up, with OS specific path seperators, and any '..', '.' components removed. """ return os.path.normpath(os.path.join(*scope["path"].split("/")))
[ "Given", "the", "ASGI", "scope", "return", "the", "path", "string", "to", "serve", "up", "with", "OS", "specific", "path", "seperators", "and", "any", "..", ".", "components", "removed", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/staticfiles.py#L96-L101
[ "def", "get_path", "(", "self", ",", "scope", ":", "Scope", ")", "->", "str", ":", "return", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "*", "scope", "[", "\"path\"", "]", ".", "split", "(", "\"/\"", ")", ")", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
StaticFiles.get_response
Returns an HTTP response, given the incoming path, method and request headers.
starlette/staticfiles.py
async def get_response(self, path: str, scope: Scope) -> Response: """ Returns an HTTP response, given the incoming path, method and request headers. """ if scope["method"] not in ("GET", "HEAD"): return PlainTextResponse("Method Not Allowed", status_code=405) if pat...
async def get_response(self, path: str, scope: Scope) -> Response: """ Returns an HTTP response, given the incoming path, method and request headers. """ if scope["method"] not in ("GET", "HEAD"): return PlainTextResponse("Method Not Allowed", status_code=405) if pat...
[ "Returns", "an", "HTTP", "response", "given", "the", "incoming", "path", "method", "and", "request", "headers", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/staticfiles.py#L103-L143
[ "async", "def", "get_response", "(", "self", ",", "path", ":", "str", ",", "scope", ":", "Scope", ")", "->", "Response", ":", "if", "scope", "[", "\"method\"", "]", "not", "in", "(", "\"GET\"", ",", "\"HEAD\"", ")", ":", "return", "PlainTextResponse", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
StaticFiles.check_config
Perform a one-off configuration check that StaticFiles is actually pointed at a directory, so that we can raise loud errors rather than just returning 404 responses.
starlette/staticfiles.py
async def check_config(self) -> None: """ Perform a one-off configuration check that StaticFiles is actually pointed at a directory, so that we can raise loud errors rather than just returning 404 responses. """ if self.directory is None: return try: ...
async def check_config(self) -> None: """ Perform a one-off configuration check that StaticFiles is actually pointed at a directory, so that we can raise loud errors rather than just returning 404 responses. """ if self.directory is None: return try: ...
[ "Perform", "a", "one", "-", "off", "configuration", "check", "that", "StaticFiles", "is", "actually", "pointed", "at", "a", "directory", "so", "that", "we", "can", "raise", "loud", "errors", "rather", "than", "just", "returning", "404", "responses", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/staticfiles.py#L175-L193
[ "async", "def", "check_config", "(", "self", ")", "->", "None", ":", "if", "self", ".", "directory", "is", "None", ":", "return", "try", ":", "stat_result", "=", "await", "aio_stat", "(", "self", ".", "directory", ")", "except", "FileNotFoundError", ":", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
StaticFiles.is_not_modified
Given the request and response headers, return `True` if an HTTP "Not Modified" response could be returned instead.
starlette/staticfiles.py
def is_not_modified( self, response_headers: Headers, request_headers: Headers ) -> bool: """ Given the request and response headers, return `True` if an HTTP "Not Modified" response could be returned instead. """ try: if_none_match = request_headers["if-n...
def is_not_modified( self, response_headers: Headers, request_headers: Headers ) -> bool: """ Given the request and response headers, return `True` if an HTTP "Not Modified" response could be returned instead. """ try: if_none_match = request_headers["if-n...
[ "Given", "the", "request", "and", "response", "headers", "return", "True", "if", "an", "HTTP", "Not", "Modified", "response", "could", "be", "returned", "instead", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/staticfiles.py#L195-L222
[ "def", "is_not_modified", "(", "self", ",", "response_headers", ":", "Headers", ",", "request_headers", ":", "Headers", ")", "->", "bool", ":", "try", ":", "if_none_match", "=", "request_headers", "[", "\"if-none-match\"", "]", "etag", "=", "response_headers", "...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
build_environ
Builds a scope and request body into a WSGI environ object.
starlette/middleware/wsgi.py
def build_environ(scope: Scope, body: bytes) -> dict: """ Builds a scope and request body into a WSGI environ object. """ environ = { "REQUEST_METHOD": scope["method"], "SCRIPT_NAME": scope.get("root_path", ""), "PATH_INFO": scope["path"], "QUERY_STRING": scope["query_str...
def build_environ(scope: Scope, body: bytes) -> dict: """ Builds a scope and request body into a WSGI environ object. """ environ = { "REQUEST_METHOD": scope["method"], "SCRIPT_NAME": scope.get("root_path", ""), "PATH_INFO": scope["path"], "QUERY_STRING": scope["query_str...
[ "Builds", "a", "scope", "and", "request", "body", "into", "a", "WSGI", "environ", "object", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/middleware/wsgi.py#L10-L52
[ "def", "build_environ", "(", "scope", ":", "Scope", ",", "body", ":", "bytes", ")", "->", "dict", ":", "environ", "=", "{", "\"REQUEST_METHOD\"", ":", "scope", "[", "\"method\"", "]", ",", "\"SCRIPT_NAME\"", ":", "scope", ".", "get", "(", "\"root_path\"", ...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
WebSocket.receive
Receive ASGI websocket messages, ensuring valid state transitions.
starlette/websockets.py
async def receive(self) -> Message: """ Receive ASGI websocket messages, ensuring valid state transitions. """ if self.client_state == WebSocketState.CONNECTING: message = await self._receive() message_type = message["type"] assert message_type == "web...
async def receive(self) -> Message: """ Receive ASGI websocket messages, ensuring valid state transitions. """ if self.client_state == WebSocketState.CONNECTING: message = await self._receive() message_type = message["type"] assert message_type == "web...
[ "Receive", "ASGI", "websocket", "messages", "ensuring", "valid", "state", "transitions", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/websockets.py#L29-L49
[ "async", "def", "receive", "(", "self", ")", "->", "Message", ":", "if", "self", ".", "client_state", "==", "WebSocketState", ".", "CONNECTING", ":", "message", "=", "await", "self", ".", "_receive", "(", ")", "message_type", "=", "message", "[", "\"type\"...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
WebSocket.send
Send ASGI websocket messages, ensuring valid state transitions.
starlette/websockets.py
async def send(self, message: Message) -> None: """ Send ASGI websocket messages, ensuring valid state transitions. """ if self.application_state == WebSocketState.CONNECTING: message_type = message["type"] assert message_type in {"websocket.accept", "websocket.cl...
async def send(self, message: Message) -> None: """ Send ASGI websocket messages, ensuring valid state transitions. """ if self.application_state == WebSocketState.CONNECTING: message_type = message["type"] assert message_type in {"websocket.accept", "websocket.cl...
[ "Send", "ASGI", "websocket", "messages", "ensuring", "valid", "state", "transitions", "." ]
encode/starlette
python
https://github.com/encode/starlette/blob/d23bfd0d8ff68d535d0283aa4099e5055da88bb9/starlette/websockets.py#L51-L70
[ "async", "def", "send", "(", "self", ",", "message", ":", "Message", ")", "->", "None", ":", "if", "self", ".", "application_state", "==", "WebSocketState", ".", "CONNECTING", ":", "message_type", "=", "message", "[", "\"type\"", "]", "assert", "message_type...
d23bfd0d8ff68d535d0283aa4099e5055da88bb9
valid
get_top_long_short_abs
Finds the top long, short, and absolute positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. top : int, optional How many of each to find (default 10). Returns ------- df_top_long : pd.DataFrame Top long position...
pyfolio/pos.py
def get_top_long_short_abs(positions, top=10): """ Finds the top long, short, and absolute positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. top : int, optional How many of each to find (default 10). Returns -----...
def get_top_long_short_abs(positions, top=10): """ Finds the top long, short, and absolute positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. top : int, optional How many of each to find (default 10). Returns -----...
[ "Finds", "the", "top", "long", "short", "and", "absolute", "positions", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/pos.py#L53-L81
[ "def", "get_top_long_short_abs", "(", "positions", ",", "top", "=", "10", ")", ":", "positions", "=", "positions", ".", "drop", "(", "'cash'", ",", "axis", "=", "'columns'", ")", "df_max", "=", "positions", ".", "max", "(", ")", "df_min", "=", "positions...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_max_median_position_concentration
Finds the max and median long and short position concentrations in each time period specified by the index of positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns ------- pd.DataFrame Columns are max long, max sh...
pyfolio/pos.py
def get_max_median_position_concentration(positions): """ Finds the max and median long and short position concentrations in each time period specified by the index of positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns...
def get_max_median_position_concentration(positions): """ Finds the max and median long and short position concentrations in each time period specified by the index of positions. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns...
[ "Finds", "the", "max", "and", "median", "long", "and", "short", "position", "concentrations", "in", "each", "time", "period", "specified", "by", "the", "index", "of", "positions", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/pos.py#L84-L113
[ "def", "get_max_median_position_concentration", "(", "positions", ")", ":", "expos", "=", "get_percent_alloc", "(", "positions", ")", "expos", "=", "expos", ".", "drop", "(", "'cash'", ",", "axis", "=", "1", ")", "longs", "=", "expos", ".", "where", "(", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
extract_pos
Extract position values from backtest object as returned by get_backtest() on the Quantopian research platform. Parameters ---------- positions : pd.DataFrame timeseries containing one row per symbol (and potentially duplicate datetime indices) and columns for amount and last_sa...
pyfolio/pos.py
def extract_pos(positions, cash): """ Extract position values from backtest object as returned by get_backtest() on the Quantopian research platform. Parameters ---------- positions : pd.DataFrame timeseries containing one row per symbol (and potentially duplicate datetime indic...
def extract_pos(positions, cash): """ Extract position values from backtest object as returned by get_backtest() on the Quantopian research platform. Parameters ---------- positions : pd.DataFrame timeseries containing one row per symbol (and potentially duplicate datetime indic...
[ "Extract", "position", "values", "from", "backtest", "object", "as", "returned", "by", "get_backtest", "()", "on", "the", "Quantopian", "research", "platform", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/pos.py#L116-L157
[ "def", "extract_pos", "(", "positions", ",", "cash", ")", ":", "positions", "=", "positions", ".", "copy", "(", ")", "positions", "[", "'values'", "]", "=", "positions", ".", "amount", "*", "positions", ".", "last_sale_price", "cash", ".", "name", "=", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_sector_exposures
Sum position exposures by sector. Parameters ---------- positions : pd.DataFrame Contains position values or amounts. - Example index 'AAPL' 'MSFT' 'CHK' cash 2004-01-09 13939.380 -15012.993 -403.870 1477.483 2...
pyfolio/pos.py
def get_sector_exposures(positions, symbol_sector_map): """ Sum position exposures by sector. Parameters ---------- positions : pd.DataFrame Contains position values or amounts. - Example index 'AAPL' 'MSFT' 'CHK' cash 2004-01-09...
def get_sector_exposures(positions, symbol_sector_map): """ Sum position exposures by sector. Parameters ---------- positions : pd.DataFrame Contains position values or amounts. - Example index 'AAPL' 'MSFT' 'CHK' cash 2004-01-09...
[ "Sum", "position", "exposures", "by", "sector", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/pos.py#L160-L208
[ "def", "get_sector_exposures", "(", "positions", ",", "symbol_sector_map", ")", ":", "cash", "=", "positions", "[", "'cash'", "]", "positions", "=", "positions", ".", "drop", "(", "'cash'", ",", "axis", "=", "1", ")", "unmapped_pos", "=", "np", ".", "setdi...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_long_short_pos
Determines the long and short allocations in a portfolio. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns ------- df_long_short : pd.DataFrame Long and short allocations as a decimal percentage of the total net liq...
pyfolio/pos.py
def get_long_short_pos(positions): """ Determines the long and short allocations in a portfolio. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns ------- df_long_short : pd.DataFrame Long and short allocations as a ...
def get_long_short_pos(positions): """ Determines the long and short allocations in a portfolio. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. Returns ------- df_long_short : pd.DataFrame Long and short allocations as a ...
[ "Determines", "the", "long", "and", "short", "allocations", "in", "a", "portfolio", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/pos.py#L211-L236
[ "def", "get_long_short_pos", "(", "positions", ")", ":", "pos_wo_cash", "=", "positions", ".", "drop", "(", "'cash'", ",", "axis", "=", "1", ")", "longs", "=", "pos_wo_cash", "[", "pos_wo_cash", ">", "0", "]", ".", "sum", "(", "axis", "=", "1", ")", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
compute_style_factor_exposures
Returns style factor exposure of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in create_risk_tear_sheet risk_factor : pd.DataFrame Daily risk factor per asset. - DataFrame...
pyfolio/risk.py
def compute_style_factor_exposures(positions, risk_factor): """ Returns style factor exposure of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in create_risk_tear_sheet risk_factor...
def compute_style_factor_exposures(positions, risk_factor): """ Returns style factor exposure of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in create_risk_tear_sheet risk_factor...
[ "Returns", "style", "factor", "exposure", "of", "an", "algorithm", "s", "positions" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L45-L74
[ "def", "compute_style_factor_exposures", "(", "positions", ",", "risk_factor", ")", ":", "positions_wo_cash", "=", "positions", ".", "drop", "(", "'cash'", ",", "axis", "=", "'columns'", ")", "gross_exposure", "=", "positions_wo_cash", ".", "abs", "(", ")", ".",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_style_factor_exposures
Plots DataFrame output of compute_style_factor_exposures as a line graph Parameters ---------- tot_style_factor_exposure : pd.Series Daily style factor exposures (output of compute_style_factor_exposures) - Time series with decimal style factor exposures - Example: 2017-...
pyfolio/risk.py
def plot_style_factor_exposures(tot_style_factor_exposure, factor_name=None, ax=None): """ Plots DataFrame output of compute_style_factor_exposures as a line graph Parameters ---------- tot_style_factor_exposure : pd.Series Daily style factor exposures (outpu...
def plot_style_factor_exposures(tot_style_factor_exposure, factor_name=None, ax=None): """ Plots DataFrame output of compute_style_factor_exposures as a line graph Parameters ---------- tot_style_factor_exposure : pd.Series Daily style factor exposures (outpu...
[ "Plots", "DataFrame", "output", "of", "compute_style_factor_exposures", "as", "a", "line", "graph" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L77-L116
[ "def", "plot_style_factor_exposures", "(", "tot_style_factor_exposure", ",", "factor_name", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "if", "factor_name", "is", "None", ":", "fac...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
compute_sector_exposures
Returns arrays of long, short and gross sector exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in compute_style_factor_exposures. sectors : pd.DataFrame Daily Mornin...
pyfolio/risk.py
def compute_sector_exposures(positions, sectors, sector_dict=SECTORS): """ Returns arrays of long, short and gross sector exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation ...
def compute_sector_exposures(positions, sectors, sector_dict=SECTORS): """ Returns arrays of long, short and gross sector exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation ...
[ "Returns", "arrays", "of", "long", "short", "and", "gross", "sector", "exposures", "of", "an", "algorithm", "s", "positions" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L119-L171
[ "def", "compute_sector_exposures", "(", "positions", ",", "sectors", ",", "sector_dict", "=", "SECTORS", ")", ":", "sector_ids", "=", "sector_dict", ".", "keys", "(", ")", "long_exposures", "=", "[", "]", "short_exposures", "=", "[", "]", "gross_exposures", "=...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_sector_exposures_longshort
Plots outputs of compute_sector_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDict Dictionary of all sectors - See full...
pyfolio/risk.py
def plot_sector_exposures_longshort(long_exposures, short_exposures, sector_dict=SECTORS, ax=None): """ Plots outputs of compute_sector_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short sector...
def plot_sector_exposures_longshort(long_exposures, short_exposures, sector_dict=SECTORS, ax=None): """ Plots outputs of compute_sector_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short sector...
[ "Plots", "outputs", "of", "compute_sector_exposures", "as", "area", "charts" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L174-L210
[ "def", "plot_sector_exposures_longshort", "(", "long_exposures", ",", "short_exposures", ",", "sector_dict", "=", "SECTORS", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "if", "sector_dict", "is",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_sector_exposures_gross
Plots output of compute_sector_exposures as area charts Parameters ---------- gross_exposures : arrays Arrays of gross sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDict Dictionary of all sectors - See full description in compute_sector_exp...
pyfolio/risk.py
def plot_sector_exposures_gross(gross_exposures, sector_dict=None, ax=None): """ Plots output of compute_sector_exposures as area charts Parameters ---------- gross_exposures : arrays Arrays of gross sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDi...
def plot_sector_exposures_gross(gross_exposures, sector_dict=None, ax=None): """ Plots output of compute_sector_exposures as area charts Parameters ---------- gross_exposures : arrays Arrays of gross sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDi...
[ "Plots", "output", "of", "compute_sector_exposures", "as", "area", "charts" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L213-L244
[ "def", "plot_sector_exposures_gross", "(", "gross_exposures", ",", "sector_dict", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "if", "sector_dict", "is", "None", ":", "sector_names"...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_sector_exposures_net
Plots output of compute_sector_exposures as line graphs Parameters ---------- net_exposures : arrays Arrays of net sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDict Dictionary of all sectors - See full description in compute_sector_exposur...
pyfolio/risk.py
def plot_sector_exposures_net(net_exposures, sector_dict=None, ax=None): """ Plots output of compute_sector_exposures as line graphs Parameters ---------- net_exposures : arrays Arrays of net sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDict ...
def plot_sector_exposures_net(net_exposures, sector_dict=None, ax=None): """ Plots output of compute_sector_exposures as line graphs Parameters ---------- net_exposures : arrays Arrays of net sector exposures (output of compute_sector_exposures). sector_dict : dict or OrderedDict ...
[ "Plots", "output", "of", "compute_sector_exposures", "as", "line", "graphs" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L247-L277
[ "def", "plot_sector_exposures_net", "(", "net_exposures", ",", "sector_dict", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "if", "sector_dict", "is", "None", ":", "sector_names", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
compute_cap_exposures
Returns arrays of long, short and gross market cap exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in compute_style_factor_exposures. caps : pd.DataFrame Daily Morni...
pyfolio/risk.py
def compute_cap_exposures(positions, caps): """ Returns arrays of long, short and gross market cap exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in compute_style_factor...
def compute_cap_exposures(positions, caps): """ Returns arrays of long, short and gross market cap exposures of an algorithm's positions Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - See full explanation in compute_style_factor...
[ "Returns", "arrays", "of", "long", "short", "and", "gross", "market", "cap", "exposures", "of", "an", "algorithm", "s", "positions" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L280-L325
[ "def", "compute_cap_exposures", "(", "positions", ",", "caps", ")", ":", "long_exposures", "=", "[", "]", "short_exposures", "=", "[", "]", "gross_exposures", "=", "[", "]", "net_exposures", "=", "[", "]", "positions_wo_cash", "=", "positions", ".", "drop", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_cap_exposures_longshort
Plots outputs of compute_cap_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short market cap exposures (output of compute_cap_exposures).
pyfolio/risk.py
def plot_cap_exposures_longshort(long_exposures, short_exposures, ax=None): """ Plots outputs of compute_cap_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short market cap exposures (output of compute_cap_exposures). "...
def plot_cap_exposures_longshort(long_exposures, short_exposures, ax=None): """ Plots outputs of compute_cap_exposures as area charts Parameters ---------- long_exposures, short_exposures : arrays Arrays of long and short market cap exposures (output of compute_cap_exposures). "...
[ "Plots", "outputs", "of", "compute_cap_exposures", "as", "area", "charts" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L328-L354
[ "def", "plot_cap_exposures_longshort", "(", "long_exposures", ",", "short_exposures", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "color_list", "=", "plt", ".", "cm", ".", "gist_rainbow", "(", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_cap_exposures_gross
Plots outputs of compute_cap_exposures as area charts Parameters ---------- gross_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures).
pyfolio/risk.py
def plot_cap_exposures_gross(gross_exposures, ax=None): """ Plots outputs of compute_cap_exposures as area charts Parameters ---------- gross_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures). """ if ax is None: ax = plt.gca() col...
def plot_cap_exposures_gross(gross_exposures, ax=None): """ Plots outputs of compute_cap_exposures as area charts Parameters ---------- gross_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures). """ if ax is None: ax = plt.gca() col...
[ "Plots", "outputs", "of", "compute_cap_exposures", "as", "area", "charts" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L357-L379
[ "def", "plot_cap_exposures_gross", "(", "gross_exposures", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "color_list", "=", "plt", ".", "cm", ".", "gist_rainbow", "(", "np", ".", "linspace", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_cap_exposures_net
Plots outputs of compute_cap_exposures as line graphs Parameters ---------- net_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures).
pyfolio/risk.py
def plot_cap_exposures_net(net_exposures, ax=None): """ Plots outputs of compute_cap_exposures as line graphs Parameters ---------- net_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures). """ if ax is None: ax = plt.gca() color_lis...
def plot_cap_exposures_net(net_exposures, ax=None): """ Plots outputs of compute_cap_exposures as line graphs Parameters ---------- net_exposures : array Arrays of gross market cap exposures (output of compute_cap_exposures). """ if ax is None: ax = plt.gca() color_lis...
[ "Plots", "outputs", "of", "compute_cap_exposures", "as", "line", "graphs" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L382-L405
[ "def", "plot_cap_exposures_net", "(", "net_exposures", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "color_list", "=", "plt", ".", "cm", ".", "gist_rainbow", "(", "np", ".", "linspace", "(",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
compute_volume_exposures
Returns arrays of pth percentile of long, short and gross volume exposures of an algorithm's held shares Parameters ---------- shares_held : pd.DataFrame Daily number of shares held by an algorithm. - See full explanation in create_risk_tear_sheet volume : pd.DataFrame Dail...
pyfolio/risk.py
def compute_volume_exposures(shares_held, volumes, percentile): """ Returns arrays of pth percentile of long, short and gross volume exposures of an algorithm's held shares Parameters ---------- shares_held : pd.DataFrame Daily number of shares held by an algorithm. - See full e...
def compute_volume_exposures(shares_held, volumes, percentile): """ Returns arrays of pth percentile of long, short and gross volume exposures of an algorithm's held shares Parameters ---------- shares_held : pd.DataFrame Daily number of shares held by an algorithm. - See full e...
[ "Returns", "arrays", "of", "pth", "percentile", "of", "long", "short", "and", "gross", "volume", "exposures", "of", "an", "algorithm", "s", "held", "shares" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L408-L459
[ "def", "compute_volume_exposures", "(", "shares_held", ",", "volumes", ",", "percentile", ")", ":", "shares_held", "=", "shares_held", ".", "replace", "(", "0", ",", "np", ".", "nan", ")", "shares_longed", "=", "shares_held", "[", "shares_held", ">", "0", "]...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_volume_exposures_longshort
Plots outputs of compute_volume_exposures as line graphs Parameters ---------- longed_threshold, shorted_threshold : pd.Series Series of longed and shorted volume exposures (output of compute_volume_exposures). percentile : float Percentile to use when computing and plotting vo...
pyfolio/risk.py
def plot_volume_exposures_longshort(longed_threshold, shorted_threshold, percentile, ax=None): """ Plots outputs of compute_volume_exposures as line graphs Parameters ---------- longed_threshold, shorted_threshold : pd.Series Series of longed and shorted ...
def plot_volume_exposures_longshort(longed_threshold, shorted_threshold, percentile, ax=None): """ Plots outputs of compute_volume_exposures as line graphs Parameters ---------- longed_threshold, shorted_threshold : pd.Series Series of longed and shorted ...
[ "Plots", "outputs", "of", "compute_volume_exposures", "as", "line", "graphs" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L462-L491
[ "def", "plot_volume_exposures_longshort", "(", "longed_threshold", ",", "shorted_threshold", ",", "percentile", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "ax", ".", "plot", "(", "longed_thresho...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_volume_exposures_gross
Plots outputs of compute_volume_exposures as line graphs Parameters ---------- grossed_threshold : pd.Series Series of grossed volume exposures (output of compute_volume_exposures). percentile : float Percentile to use when computing and plotting volume exposures - See ...
pyfolio/risk.py
def plot_volume_exposures_gross(grossed_threshold, percentile, ax=None): """ Plots outputs of compute_volume_exposures as line graphs Parameters ---------- grossed_threshold : pd.Series Series of grossed volume exposures (output of compute_volume_exposures). percentile : float ...
def plot_volume_exposures_gross(grossed_threshold, percentile, ax=None): """ Plots outputs of compute_volume_exposures as line graphs Parameters ---------- grossed_threshold : pd.Series Series of grossed volume exposures (output of compute_volume_exposures). percentile : float ...
[ "Plots", "outputs", "of", "compute_volume_exposures", "as", "line", "graphs" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/risk.py#L494-L520
[ "def", "plot_volume_exposures_gross", "(", "grossed_threshold", ",", "percentile", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "ax", ".", "plot", "(", "grossed_threshold", ".", "index", ",", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_full_tear_sheet
Generate a number of tear sheets that are useful for analyzing a strategy's performance. - Fetches benchmarks if needed. - Creates tear sheets for returns, and significant events. If possible, also creates tear sheets for position analysis, transaction analysis, and Bayesian analysis. ...
pyfolio/tears.py
def create_full_tear_sheet(returns, positions=None, transactions=None, market_data=None, benchmark_rets=None, slippage=None, live_start_date=None, ...
def create_full_tear_sheet(returns, positions=None, transactions=None, market_data=None, benchmark_rets=None, slippage=None, live_start_date=None, ...
[ "Generate", "a", "number", "of", "tear", "sheets", "that", "are", "useful", "for", "analyzing", "a", "strategy", "s", "performance", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L67-L258
[ "def", "create_full_tear_sheet", "(", "returns", ",", "positions", "=", "None", ",", "transactions", "=", "None", ",", "market_data", "=", "None", ",", "benchmark_rets", "=", "None", ",", "slippage", "=", "None", ",", "live_start_date", "=", "None", ",", "se...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_simple_tear_sheet
Simpler version of create_full_tear_sheet; generates summary performance statistics and important plots as a single image. - Plots: cumulative returns, rolling beta, rolling Sharpe, underwater, exposure, top 10 holdings, total holdings, long/short holdings, daily turnover, transaction time dist...
pyfolio/tears.py
def create_simple_tear_sheet(returns, positions=None, transactions=None, benchmark_rets=None, slippage=None, estimate_intraday='infer', live_start...
def create_simple_tear_sheet(returns, positions=None, transactions=None, benchmark_rets=None, slippage=None, estimate_intraday='infer', live_start...
[ "Simpler", "version", "of", "create_full_tear_sheet", ";", "generates", "summary", "performance", "statistics", "and", "important", "plots", "as", "a", "single", "image", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L262-L435
[ "def", "create_simple_tear_sheet", "(", "returns", ",", "positions", "=", "None", ",", "transactions", "=", "None", ",", "benchmark_rets", "=", "None", ",", "slippage", "=", "None", ",", "estimate_intraday", "=", "'infer'", ",", "live_start_date", "=", "None", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_returns_tear_sheet
Generate a number of plots for analyzing a strategy's returns. - Fetches benchmarks, then creates the plots on a single figure. - Plots: rolling returns (with cone), rolling beta, rolling sharpe, rolling Fama-French risk factors, drawdowns, underwater plot, monthly and annual return plots, dail...
pyfolio/tears.py
def create_returns_tear_sheet(returns, positions=None, transactions=None, live_start_date=None, cone_std=(1.0, 1.5, 2.0), benchmark_rets=None, bootstrap=False, ...
def create_returns_tear_sheet(returns, positions=None, transactions=None, live_start_date=None, cone_std=(1.0, 1.5, 2.0), benchmark_rets=None, bootstrap=False, ...
[ "Generate", "a", "number", "of", "plots", "for", "analyzing", "a", "strategy", "s", "returns", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L439-L625
[ "def", "create_returns_tear_sheet", "(", "returns", ",", "positions", "=", "None", ",", "transactions", "=", "None", ",", "live_start_date", "=", "None", ",", "cone_std", "=", "(", "1.0", ",", "1.5", ",", "2.0", ")", ",", "benchmark_rets", "=", "None", ","...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_position_tear_sheet
Generate a number of plots for analyzing a strategy's positions and holdings. - Plots: gross leverage, exposures, top positions, and holdings. - Will also print the top positions held. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - Se...
pyfolio/tears.py
def create_position_tear_sheet(returns, positions, show_and_plot_top_pos=2, hide_positions=False, return_fig=False, sector_mappings=None, transactions=None, estimate_intraday='infer'): """ Generate a number of plots for...
def create_position_tear_sheet(returns, positions, show_and_plot_top_pos=2, hide_positions=False, return_fig=False, sector_mappings=None, transactions=None, estimate_intraday='infer'): """ Generate a number of plots for...
[ "Generate", "a", "number", "of", "plots", "for", "analyzing", "a", "strategy", "s", "positions", "and", "holdings", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L629-L720
[ "def", "create_position_tear_sheet", "(", "returns", ",", "positions", ",", "show_and_plot_top_pos", "=", "2", ",", "hide_positions", "=", "False", ",", "return_fig", "=", "False", ",", "sector_mappings", "=", "None", ",", "transactions", "=", "None", ",", "esti...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_txn_tear_sheet
Generate a number of plots for analyzing a strategy's transactions. Plots: turnover, daily volume, and a histogram of daily volume. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in create_full_tear_sheet. positions :...
pyfolio/tears.py
def create_txn_tear_sheet(returns, positions, transactions, unadjusted_returns=None, estimate_intraday='infer', return_fig=False): """ Generate a number of plots for analyzing a strategy's transactions. Plots: turnover, daily volume, and a histogram of da...
def create_txn_tear_sheet(returns, positions, transactions, unadjusted_returns=None, estimate_intraday='infer', return_fig=False): """ Generate a number of plots for analyzing a strategy's transactions. Plots: turnover, daily volume, and a histogram of da...
[ "Generate", "a", "number", "of", "plots", "for", "analyzing", "a", "strategy", "s", "transactions", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L724-L800
[ "def", "create_txn_tear_sheet", "(", "returns", ",", "positions", ",", "transactions", ",", "unadjusted_returns", "=", "None", ",", "estimate_intraday", "=", "'infer'", ",", "return_fig", "=", "False", ")", ":", "positions", "=", "utils", ".", "check_intraday", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_round_trip_tear_sheet
Generate a number of figures and plots describing the duration, frequency, and profitability of trade "round trips." A round trip is started when a new long or short position is opened and is only completed when the number of shares in that position returns to or crosses zero. Parameters ------...
pyfolio/tears.py
def create_round_trip_tear_sheet(returns, positions, transactions, sector_mappings=None, estimate_intraday='infer', return_fig=False): """ Generate a number of figures and plots describing the duration, frequency, and profitability of trade "...
def create_round_trip_tear_sheet(returns, positions, transactions, sector_mappings=None, estimate_intraday='infer', return_fig=False): """ Generate a number of figures and plots describing the duration, frequency, and profitability of trade "...
[ "Generate", "a", "number", "of", "figures", "and", "plots", "describing", "the", "duration", "frequency", "and", "profitability", "of", "trade", "round", "trips", ".", "A", "round", "trip", "is", "started", "when", "a", "new", "long", "or", "short", "positio...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L804-L890
[ "def", "create_round_trip_tear_sheet", "(", "returns", ",", "positions", ",", "transactions", ",", "sector_mappings", "=", "None", ",", "estimate_intraday", "=", "'infer'", ",", "return_fig", "=", "False", ")", ":", "positions", "=", "utils", ".", "check_intraday"...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_interesting_times_tear_sheet
Generate a number of returns plots around interesting points in time, like the flash crash and 9/11. Plots: returns around the dotcom bubble burst, Lehmann Brothers' failure, 9/11, US downgrade and EU debt crisis, Fukushima meltdown, US housing bubble burst, EZB IR, Great Recession (August 2007, March ...
pyfolio/tears.py
def create_interesting_times_tear_sheet( returns, benchmark_rets=None, legend_loc='best', return_fig=False): """ Generate a number of returns plots around interesting points in time, like the flash crash and 9/11. Plots: returns around the dotcom bubble burst, Lehmann Brothers' failure, 9/1...
def create_interesting_times_tear_sheet( returns, benchmark_rets=None, legend_loc='best', return_fig=False): """ Generate a number of returns plots around interesting points in time, like the flash crash and 9/11. Plots: returns around the dotcom bubble burst, Lehmann Brothers' failure, 9/1...
[ "Generate", "a", "number", "of", "returns", "plots", "around", "interesting", "points", "in", "time", "like", "the", "flash", "crash", "and", "9", "/", "11", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L894-L969
[ "def", "create_interesting_times_tear_sheet", "(", "returns", ",", "benchmark_rets", "=", "None", ",", "legend_loc", "=", "'best'", ",", "return_fig", "=", "False", ")", ":", "rets_interesting", "=", "timeseries", ".", "extract_interesting_date_ranges", "(", "returns"...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_capacity_tear_sheet
Generates a report detailing portfolio size constraints set by least liquid tickers. Plots a "capacity sweep," a curve describing projected sharpe ratio given the slippage penalties that are applied at various capital bases. Parameters ---------- returns : pd.Series Daily returns of the...
pyfolio/tears.py
def create_capacity_tear_sheet(returns, positions, transactions, market_data, liquidation_daily_vol_limit=0.2, trade_daily_vol_limit=0.05, last_n_days=utils.APPROX_BDAYS_PER_MONTH * 6, ...
def create_capacity_tear_sheet(returns, positions, transactions, market_data, liquidation_daily_vol_limit=0.2, trade_daily_vol_limit=0.05, last_n_days=utils.APPROX_BDAYS_PER_MONTH * 6, ...
[ "Generates", "a", "report", "detailing", "portfolio", "size", "constraints", "set", "by", "least", "liquid", "tickers", ".", "Plots", "a", "capacity", "sweep", "a", "curve", "describing", "projected", "sharpe", "ratio", "given", "the", "slippage", "penalties", "...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L973-L1075
[ "def", "create_capacity_tear_sheet", "(", "returns", ",", "positions", ",", "transactions", ",", "market_data", ",", "liquidation_daily_vol_limit", "=", "0.2", ",", "trade_daily_vol_limit", "=", "0.05", ",", "last_n_days", "=", "utils", ".", "APPROX_BDAYS_PER_MONTH", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_bayesian_tear_sheet
Generate a number of Bayesian distributions and a Bayesian cone plot of returns. Plots: Sharpe distribution, annual volatility distribution, annual alpha distribution, beta distribution, predicted 1 and 5 day returns distributions, and a cumulative returns cone plot. Parameters ---------- ...
pyfolio/tears.py
def create_bayesian_tear_sheet(returns, benchmark_rets=None, live_start_date=None, samples=2000, return_fig=False, stoch_vol=False, progressbar=True): """ Generate a number of Bayesian distributions and a Bayesian c...
def create_bayesian_tear_sheet(returns, benchmark_rets=None, live_start_date=None, samples=2000, return_fig=False, stoch_vol=False, progressbar=True): """ Generate a number of Bayesian distributions and a Bayesian c...
[ "Generate", "a", "number", "of", "Bayesian", "distributions", "and", "a", "Bayesian", "cone", "plot", "of", "returns", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L1079-L1262
[ "def", "create_bayesian_tear_sheet", "(", "returns", ",", "benchmark_rets", "=", "None", ",", "live_start_date", "=", "None", ",", "samples", "=", "2000", ",", "return_fig", "=", "False", ",", "stoch_vol", "=", "False", ",", "progressbar", "=", "True", ")", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_risk_tear_sheet
Creates risk tear sheet: computes and plots style factor exposures, sector exposures, market cap exposures and volume exposures. Parameters ---------- positions : pd.DataFrame Daily equity positions of algorithm, in dollars. - DataFrame with dates as index, equities as columns -...
pyfolio/tears.py
def create_risk_tear_sheet(positions, style_factor_panel=None, sectors=None, caps=None, shares_held=None, volumes=None, percentile=None, ...
def create_risk_tear_sheet(positions, style_factor_panel=None, sectors=None, caps=None, shares_held=None, volumes=None, percentile=None, ...
[ "Creates", "risk", "tear", "sheet", ":", "computes", "and", "plots", "style", "factor", "exposures", "sector", "exposures", "market", "cap", "exposures", "and", "volume", "exposures", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L1266-L1440
[ "def", "create_risk_tear_sheet", "(", "positions", ",", "style_factor_panel", "=", "None", ",", "sectors", "=", "None", ",", "caps", "=", "None", ",", "shares_held", "=", "None", ",", "volumes", "=", "None", ",", "percentile", "=", "None", ",", "returns", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_perf_attrib_tear_sheet
Generate plots and tables for analyzing a strategy's performance. Parameters ---------- returns : pd.Series Returns for each day in the date range. positions: pd.DataFrame Daily holdings (in dollars or percentages), indexed by date. Will be converted to percentages if positions...
pyfolio/tears.py
def create_perf_attrib_tear_sheet(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True, ...
def create_perf_attrib_tear_sheet(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True, ...
[ "Generate", "plots", "and", "tables", "for", "analyzing", "a", "strategy", "s", "performance", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/tears.py#L1444-L1560
[ "def", "create_perf_attrib_tear_sheet", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings", ",", "transactions", "=", "None", ",", "pos_in_dollars", "=", "True", ",", "return_fig", "=", "False", ",", "factor_partitions", "=", "FACTOR_PAR...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
daily_txns_with_bar_data
Sums the absolute value of shares traded in each name on each day. Adds columns containing the closing price and total daily volume for each day-ticker combination. Parameters ---------- transactions : pd.DataFrame Prices and amounts of executed trades. One row per trade. - See full...
pyfolio/capacity.py
def daily_txns_with_bar_data(transactions, market_data): """ Sums the absolute value of shares traded in each name on each day. Adds columns containing the closing price and total daily volume for each day-ticker combination. Parameters ---------- transactions : pd.DataFrame Prices ...
def daily_txns_with_bar_data(transactions, market_data): """ Sums the absolute value of shares traded in each name on each day. Adds columns containing the closing price and total daily volume for each day-ticker combination. Parameters ---------- transactions : pd.DataFrame Prices ...
[ "Sums", "the", "absolute", "value", "of", "shares", "traded", "in", "each", "name", "on", "each", "day", ".", "Adds", "columns", "containing", "the", "closing", "price", "and", "total", "daily", "volume", "for", "each", "day", "-", "ticker", "combination", ...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/capacity.py#L10-L42
[ "def", "daily_txns_with_bar_data", "(", "transactions", ",", "market_data", ")", ":", "transactions", ".", "index", ".", "name", "=", "'date'", "txn_daily", "=", "pd", ".", "DataFrame", "(", "transactions", ".", "assign", "(", "amount", "=", "abs", "(", "tra...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
days_to_liquidate_positions
Compute the number of days that would have been required to fully liquidate each position on each day based on the trailing n day mean daily bar volume and a limit on the proportion of a daily bar that we are allowed to consume. This analysis uses portfolio allocations and a provided capital base r...
pyfolio/capacity.py
def days_to_liquidate_positions(positions, market_data, max_bar_consumption=0.2, capital_base=1e6, mean_volume_window=5): """ Compute the number of days that would have been required to fully liquidate each posit...
def days_to_liquidate_positions(positions, market_data, max_bar_consumption=0.2, capital_base=1e6, mean_volume_window=5): """ Compute the number of days that would have been required to fully liquidate each posit...
[ "Compute", "the", "number", "of", "days", "that", "would", "have", "been", "required", "to", "fully", "liquidate", "each", "position", "on", "each", "day", "based", "on", "the", "trailing", "n", "day", "mean", "daily", "bar", "volume", "and", "a", "limit",...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/capacity.py#L45-L97
[ "def", "days_to_liquidate_positions", "(", "positions", ",", "market_data", ",", "max_bar_consumption", "=", "0.2", ",", "capital_base", "=", "1e6", ",", "mean_volume_window", "=", "5", ")", ":", "DV", "=", "market_data", "[", "'volume'", "]", "*", "market_data"...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_max_days_to_liquidate_by_ticker
Finds the longest estimated liquidation time for each traded name over the course of backtest (or last n days of the backtest). Parameters ---------- positions: pd.DataFrame Contains daily position values including cash - See full explanation in tears.create_full_tear_sheet market_d...
pyfolio/capacity.py
def get_max_days_to_liquidate_by_ticker(positions, market_data, max_bar_consumption=0.2, capital_base=1e6, mean_volume_window=5, last_n_days=None): """ ...
def get_max_days_to_liquidate_by_ticker(positions, market_data, max_bar_consumption=0.2, capital_base=1e6, mean_volume_window=5, last_n_days=None): """ ...
[ "Finds", "the", "longest", "estimated", "liquidation", "time", "for", "each", "traded", "name", "over", "the", "course", "of", "backtest", "(", "or", "last", "n", "days", "of", "the", "backtest", ")", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/capacity.py#L100-L157
[ "def", "get_max_days_to_liquidate_by_ticker", "(", "positions", ",", "market_data", ",", "max_bar_consumption", "=", "0.2", ",", "capital_base", "=", "1e6", ",", "mean_volume_window", "=", "5", ",", "last_n_days", "=", "None", ")", ":", "dtlp", "=", "days_to_liqui...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_low_liquidity_transactions
For each traded name, find the daily transaction total that consumed the greatest proportion of available daily bar volume. Parameters ---------- transactions : pd.DataFrame Prices and amounts of executed trades. One row per trade. - See full explanation in create_full_tear_sheet. ...
pyfolio/capacity.py
def get_low_liquidity_transactions(transactions, market_data, last_n_days=None): """ For each traded name, find the daily transaction total that consumed the greatest proportion of available daily bar volume. Parameters ---------- transactions : pd.DataFrame ...
def get_low_liquidity_transactions(transactions, market_data, last_n_days=None): """ For each traded name, find the daily transaction total that consumed the greatest proportion of available daily bar volume. Parameters ---------- transactions : pd.DataFrame ...
[ "For", "each", "traded", "name", "find", "the", "daily", "transaction", "total", "that", "consumed", "the", "greatest", "proportion", "of", "available", "daily", "bar", "volume", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/capacity.py#L160-L193
[ "def", "get_low_liquidity_transactions", "(", "transactions", ",", "market_data", ",", "last_n_days", "=", "None", ")", ":", "txn_daily_w_bar", "=", "daily_txns_with_bar_data", "(", "transactions", ",", "market_data", ")", "txn_daily_w_bar", ".", "index", ".", "name",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
apply_slippage_penalty
Applies quadratic volumeshare slippage model to daily returns based on the proportion of the observed historical daily bar dollar volume consumed by the strategy's trades. Scales the size of trades based on the ratio of the starting capital we wish to test to the starting capital of the passed backtest ...
pyfolio/capacity.py
def apply_slippage_penalty(returns, txn_daily, simulate_starting_capital, backtest_starting_capital, impact=0.1): """ Applies quadratic volumeshare slippage model to daily returns based on the proportion of the observed historical daily bar dollar volume consumed by the strate...
def apply_slippage_penalty(returns, txn_daily, simulate_starting_capital, backtest_starting_capital, impact=0.1): """ Applies quadratic volumeshare slippage model to daily returns based on the proportion of the observed historical daily bar dollar volume consumed by the strate...
[ "Applies", "quadratic", "volumeshare", "slippage", "model", "to", "daily", "returns", "based", "on", "the", "proportion", "of", "the", "observed", "historical", "daily", "bar", "dollar", "volume", "consumed", "by", "the", "strategy", "s", "trades", ".", "Scales"...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/capacity.py#L196-L245
[ "def", "apply_slippage_penalty", "(", "returns", ",", "txn_daily", ",", "simulate_starting_capital", ",", "backtest_starting_capital", ",", "impact", "=", "0.1", ")", ":", "mult", "=", "simulate_starting_capital", "/", "backtest_starting_capital", "simulate_traded_shares", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
map_transaction
Maps a single transaction row to a dictionary. Parameters ---------- txn : pd.DataFrame A single transaction object to convert to a dictionary. Returns ------- dict Mapped transaction.
pyfolio/txn.py
def map_transaction(txn): """ Maps a single transaction row to a dictionary. Parameters ---------- txn : pd.DataFrame A single transaction object to convert to a dictionary. Returns ------- dict Mapped transaction. """ if isinstance(txn['sid'], dict): s...
def map_transaction(txn): """ Maps a single transaction row to a dictionary. Parameters ---------- txn : pd.DataFrame A single transaction object to convert to a dictionary. Returns ------- dict Mapped transaction. """ if isinstance(txn['sid'], dict): s...
[ "Maps", "a", "single", "transaction", "row", "to", "a", "dictionary", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/txn.py#L20-L48
[ "def", "map_transaction", "(", "txn", ")", ":", "if", "isinstance", "(", "txn", "[", "'sid'", "]", ",", "dict", ")", ":", "sid", "=", "txn", "[", "'sid'", "]", "[", "'sid'", "]", "symbol", "=", "txn", "[", "'sid'", "]", "[", "'symbol'", "]", "els...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
make_transaction_frame
Formats a transaction DataFrame. Parameters ---------- transactions : pd.DataFrame Contains improperly formatted transactional data. Returns ------- df : pd.DataFrame Daily transaction volume and dollar ammount. - See full explanation in tears.create_full_tear_sheet.
pyfolio/txn.py
def make_transaction_frame(transactions): """ Formats a transaction DataFrame. Parameters ---------- transactions : pd.DataFrame Contains improperly formatted transactional data. Returns ------- df : pd.DataFrame Daily transaction volume and dollar ammount. - S...
def make_transaction_frame(transactions): """ Formats a transaction DataFrame. Parameters ---------- transactions : pd.DataFrame Contains improperly formatted transactional data. Returns ------- df : pd.DataFrame Daily transaction volume and dollar ammount. - S...
[ "Formats", "a", "transaction", "DataFrame", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/txn.py#L51-L80
[ "def", "make_transaction_frame", "(", "transactions", ")", ":", "transaction_list", "=", "[", "]", "for", "dt", "in", "transactions", ".", "index", ":", "txns", "=", "transactions", ".", "loc", "[", "dt", "]", "if", "len", "(", "txns", ")", "==", "0", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_txn_vol
Extract daily transaction data from set of transaction objects. Parameters ---------- transactions : pd.DataFrame Time series containing one row per symbol (and potentially duplicate datetime indices) and columns for amount and price. Returns ------- pd.DataFrame ...
pyfolio/txn.py
def get_txn_vol(transactions): """ Extract daily transaction data from set of transaction objects. Parameters ---------- transactions : pd.DataFrame Time series containing one row per symbol (and potentially duplicate datetime indices) and columns for amount and price. ...
def get_txn_vol(transactions): """ Extract daily transaction data from set of transaction objects. Parameters ---------- transactions : pd.DataFrame Time series containing one row per symbol (and potentially duplicate datetime indices) and columns for amount and price. ...
[ "Extract", "daily", "transaction", "data", "from", "set", "of", "transaction", "objects", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/txn.py#L83-L110
[ "def", "get_txn_vol", "(", "transactions", ")", ":", "txn_norm", "=", "transactions", ".", "copy", "(", ")", "txn_norm", ".", "index", "=", "txn_norm", ".", "index", ".", "normalize", "(", ")", "amounts", "=", "txn_norm", ".", "amount", ".", "abs", "(", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
adjust_returns_for_slippage
Apply a slippage penalty for every dollar traded. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in create_full_tear_sheet. positions : pd.DataFrame Daily net position values. - See full explanation in cre...
pyfolio/txn.py
def adjust_returns_for_slippage(returns, positions, transactions, slippage_bps): """ Apply a slippage penalty for every dollar traded. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in c...
def adjust_returns_for_slippage(returns, positions, transactions, slippage_bps): """ Apply a slippage penalty for every dollar traded. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in c...
[ "Apply", "a", "slippage", "penalty", "for", "every", "dollar", "traded", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/txn.py#L113-L146
[ "def", "adjust_returns_for_slippage", "(", "returns", ",", "positions", ",", "transactions", ",", "slippage_bps", ")", ":", "slippage", "=", "0.0001", "*", "slippage_bps", "portfolio_value", "=", "positions", ".", "sum", "(", "axis", "=", "1", ")", "pnl", "=",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_turnover
- Value of purchases and sales divided by either the actual gross book or the portfolio value for the time step. Parameters ---------- positions : pd.DataFrame Contains daily position values including cash. - See full explanation in tears.create_full_tear_sheet transactions : pd...
pyfolio/txn.py
def get_turnover(positions, transactions, denominator='AGB'): """ - Value of purchases and sales divided by either the actual gross book or the portfolio value for the time step. Parameters ---------- positions : pd.DataFrame Contains daily position values including cash. -...
def get_turnover(positions, transactions, denominator='AGB'): """ - Value of purchases and sales divided by either the actual gross book or the portfolio value for the time step. Parameters ---------- positions : pd.DataFrame Contains daily position values including cash. -...
[ "-", "Value", "of", "purchases", "and", "sales", "divided", "by", "either", "the", "actual", "gross", "book", "or", "the", "portfolio", "value", "for", "the", "time", "step", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/txn.py#L149-L206
[ "def", "get_turnover", "(", "positions", ",", "transactions", ",", "denominator", "=", "'AGB'", ")", ":", "txn_vol", "=", "get_txn_vol", "(", "transactions", ")", "traded_value", "=", "txn_vol", ".", "txn_volume", "if", "denominator", "==", "'AGB'", ":", "# Ac...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
_groupby_consecutive
Merge transactions of the same direction separated by less than max_delta time duration. Parameters ---------- transactions : pd.DataFrame Prices and amounts of executed round_trips. One row per trade. - See full explanation in tears.create_full_tear_sheet max_delta : pandas.Timede...
pyfolio/round_trips.py
def _groupby_consecutive(txn, max_delta=pd.Timedelta('8h')): """Merge transactions of the same direction separated by less than max_delta time duration. Parameters ---------- transactions : pd.DataFrame Prices and amounts of executed round_trips. One row per trade. - See full explan...
def _groupby_consecutive(txn, max_delta=pd.Timedelta('8h')): """Merge transactions of the same direction separated by less than max_delta time duration. Parameters ---------- transactions : pd.DataFrame Prices and amounts of executed round_trips. One row per trade. - See full explan...
[ "Merge", "transactions", "of", "the", "same", "direction", "separated", "by", "less", "than", "max_delta", "time", "duration", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L95-L148
[ "def", "_groupby_consecutive", "(", "txn", ",", "max_delta", "=", "pd", ".", "Timedelta", "(", "'8h'", ")", ")", ":", "def", "vwap", "(", "transaction", ")", ":", "if", "transaction", ".", "amount", ".", "sum", "(", ")", "==", "0", ":", "warnings", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
extract_round_trips
Group transactions into "round trips". First, transactions are grouped by day and directionality. Then, long and short transactions are matched to create round-trip round_trips for which PnL, duration and returns are computed. Crossings where a position changes from long to short and vice-versa are hand...
pyfolio/round_trips.py
def extract_round_trips(transactions, portfolio_value=None): """Group transactions into "round trips". First, transactions are grouped by day and directionality. Then, long and short transactions are matched to create round-trip round_trips for which PnL, duration and returns are...
def extract_round_trips(transactions, portfolio_value=None): """Group transactions into "round trips". First, transactions are grouped by day and directionality. Then, long and short transactions are matched to create round-trip round_trips for which PnL, duration and returns are...
[ "Group", "transactions", "into", "round", "trips", ".", "First", "transactions", "are", "grouped", "by", "day", "and", "directionality", ".", "Then", "long", "and", "short", "transactions", "are", "matched", "to", "create", "round", "-", "trip", "round_trips", ...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L151-L273
[ "def", "extract_round_trips", "(", "transactions", ",", "portfolio_value", "=", "None", ")", ":", "transactions", "=", "_groupby_consecutive", "(", "transactions", ")", "roundtrips", "=", "[", "]", "for", "sym", ",", "trans_sym", "in", "transactions", ".", "grou...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
add_closing_transactions
Appends transactions that close out all positions at the end of the timespan covered by positions data. Utilizes pricing information in the positions DataFrame to determine closing price. Parameters ---------- positions : pd.DataFrame The positions that the strategy takes over time. tra...
pyfolio/round_trips.py
def add_closing_transactions(positions, transactions): """ Appends transactions that close out all positions at the end of the timespan covered by positions data. Utilizes pricing information in the positions DataFrame to determine closing price. Parameters ---------- positions : pd.DataFra...
def add_closing_transactions(positions, transactions): """ Appends transactions that close out all positions at the end of the timespan covered by positions data. Utilizes pricing information in the positions DataFrame to determine closing price. Parameters ---------- positions : pd.DataFra...
[ "Appends", "transactions", "that", "close", "out", "all", "positions", "at", "the", "end", "of", "the", "timespan", "covered", "by", "positions", "data", ".", "Utilizes", "pricing", "information", "in", "the", "positions", "DataFrame", "to", "determine", "closin...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L276-L319
[ "def", "add_closing_transactions", "(", "positions", ",", "transactions", ")", ":", "closed_txns", "=", "transactions", "[", "[", "'symbol'", ",", "'amount'", ",", "'price'", "]", "]", "pos_at_end", "=", "positions", ".", "drop", "(", "'cash'", ",", "axis", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
apply_sector_mappings_to_round_trips
Translates round trip symbols to sectors. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips sector_mappings : dict or pd.Series, optional Security identifier to sector mapping. ...
pyfolio/round_trips.py
def apply_sector_mappings_to_round_trips(round_trips, sector_mappings): """ Translates round trip symbols to sectors. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips sector_ma...
def apply_sector_mappings_to_round_trips(round_trips, sector_mappings): """ Translates round trip symbols to sectors. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips sector_ma...
[ "Translates", "round", "trip", "symbols", "to", "sectors", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L322-L346
[ "def", "apply_sector_mappings_to_round_trips", "(", "round_trips", ",", "sector_mappings", ")", ":", "sector_round_trips", "=", "round_trips", ".", "copy", "(", ")", "sector_round_trips", ".", "symbol", "=", "sector_round_trips", ".", "symbol", ".", "apply", "(", "l...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
gen_round_trip_stats
Generate various round-trip statistics. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips Returns ------- stats : dict A dictionary where each value is a pandas DataFram...
pyfolio/round_trips.py
def gen_round_trip_stats(round_trips): """Generate various round-trip statistics. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips Returns ------- stats : dict A di...
def gen_round_trip_stats(round_trips): """Generate various round-trip statistics. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips Returns ------- stats : dict A di...
[ "Generate", "various", "round", "-", "trip", "statistics", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L349-L381
[ "def", "gen_round_trip_stats", "(", "round_trips", ")", ":", "stats", "=", "{", "}", "stats", "[", "'pnl'", "]", "=", "agg_all_long_short", "(", "round_trips", ",", "'pnl'", ",", "PNL_STATS", ")", "stats", "[", "'summary'", "]", "=", "agg_all_long_short", "(...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
print_round_trip_stats
Print various round-trip statistics. Tries to pretty-print tables with HTML output if run inside IPython NB. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanation in round_trips.extract_round_trips See also --------...
pyfolio/round_trips.py
def print_round_trip_stats(round_trips, hide_pos=False): """Print various round-trip statistics. Tries to pretty-print tables with HTML output if run inside IPython NB. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanati...
def print_round_trip_stats(round_trips, hide_pos=False): """Print various round-trip statistics. Tries to pretty-print tables with HTML output if run inside IPython NB. Parameters ---------- round_trips : pd.DataFrame DataFrame with one row per round trip trade. - See full explanati...
[ "Print", "various", "round", "-", "trip", "statistics", ".", "Tries", "to", "pretty", "-", "print", "tables", "with", "HTML", "output", "if", "run", "inside", "IPython", "NB", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/round_trips.py#L384-L412
[ "def", "print_round_trip_stats", "(", "round_trips", ",", "hide_pos", "=", "False", ")", ":", "stats", "=", "gen_round_trip_stats", "(", "round_trips", ")", "print_table", "(", "stats", "[", "'summary'", "]", ",", "float_format", "=", "'{:.2f}'", ".", "format", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
perf_attrib
Attributes the performance of a returns stream to a set of risk factors. Preprocesses inputs, and then calls empyrical.perf_attrib. See empyrical.perf_attrib for more info. Performance attribution determines how much each risk factor, e.g., momentum, the technology sector, etc., contributed to total r...
pyfolio/perf_attrib.py
def perf_attrib(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Attributes the performance of a returns stream to a set of risk factors. Preprocesses inputs, and then calls empy...
def perf_attrib(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Attributes the performance of a returns stream to a set of risk factors. Preprocesses inputs, and then calls empy...
[ "Attributes", "the", "performance", "of", "a", "returns", "stream", "to", "a", "set", "of", "risk", "factors", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L30-L148
[ "def", "perf_attrib", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings", ",", "transactions", "=", "None", ",", "pos_in_dollars", "=", "True", ")", ":", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings"...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
compute_exposures
Compute daily risk factor exposures. Normalizes positions (if necessary) and calls ep.compute_exposures. See empyrical.compute_exposures for more info. Parameters ---------- positions: pd.DataFrame or pd.Series Daily holdings (in dollars or percentages), indexed by date, OR a serie...
pyfolio/perf_attrib.py
def compute_exposures(positions, factor_loadings, stack_positions=True, pos_in_dollars=True): """ Compute daily risk factor exposures. Normalizes positions (if necessary) and calls ep.compute_exposures. See empyrical.compute_exposures for more info. Parameters ---------- ...
def compute_exposures(positions, factor_loadings, stack_positions=True, pos_in_dollars=True): """ Compute daily risk factor exposures. Normalizes positions (if necessary) and calls ep.compute_exposures. See empyrical.compute_exposures for more info. Parameters ---------- ...
[ "Compute", "daily", "risk", "factor", "exposures", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L151-L216
[ "def", "compute_exposures", "(", "positions", ",", "factor_loadings", ",", "stack_positions", "=", "True", ",", "pos_in_dollars", "=", "True", ")", ":", "if", "stack_positions", ":", "positions", "=", "_stack_positions", "(", "positions", ",", "pos_in_dollars", "=...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
create_perf_attrib_stats
Takes perf attribution data over a period of time and computes annualized multifactor alpha, multifactor sharpe, risk exposures.
pyfolio/perf_attrib.py
def create_perf_attrib_stats(perf_attrib, risk_exposures): """ Takes perf attribution data over a period of time and computes annualized multifactor alpha, multifactor sharpe, risk exposures. """ summary = OrderedDict() total_returns = perf_attrib['total_returns'] specific_returns = perf_att...
def create_perf_attrib_stats(perf_attrib, risk_exposures): """ Takes perf attribution data over a period of time and computes annualized multifactor alpha, multifactor sharpe, risk exposures. """ summary = OrderedDict() total_returns = perf_attrib['total_returns'] specific_returns = perf_att...
[ "Takes", "perf", "attribution", "data", "over", "a", "period", "of", "time", "and", "computes", "annualized", "multifactor", "alpha", "multifactor", "sharpe", "risk", "exposures", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L219-L265
[ "def", "create_perf_attrib_stats", "(", "perf_attrib", ",", "risk_exposures", ")", ":", "summary", "=", "OrderedDict", "(", ")", "total_returns", "=", "perf_attrib", "[", "'total_returns'", "]", "specific_returns", "=", "perf_attrib", "[", "'specific_returns'", "]", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
show_perf_attrib_stats
Calls `perf_attrib` using inputs, and displays outputs using `utils.print_table`.
pyfolio/perf_attrib.py
def show_perf_attrib_stats(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Calls `perf_attrib` using inputs, and displays outpu...
def show_perf_attrib_stats(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Calls `perf_attrib` using inputs, and displays outpu...
[ "Calls", "perf_attrib", "using", "inputs", "and", "displays", "outputs", "using", "utils", ".", "print_table", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L268-L323
[ "def", "show_perf_attrib_stats", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings", ",", "transactions", "=", "None", ",", "pos_in_dollars", "=", "True", ")", ":", "risk_exposures", ",", "perf_attrib_data", "=", "perf_attrib", "(", "r...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_returns
Plot total, specific, and common returns. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific returns as columns, and datetimes as index. Assumes the `total_returns` column is NOT cost adjusted. - Example: ...
pyfolio/perf_attrib.py
def plot_returns(perf_attrib_data, cost=None, ax=None): """ Plot total, specific, and common returns. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific returns as columns, and datetimes as index. Assumes the `total_returns` column is...
def plot_returns(perf_attrib_data, cost=None, ax=None): """ Plot total, specific, and common returns. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific returns as columns, and datetimes as index. Assumes the `total_returns` column is...
[ "Plot", "total", "specific", "and", "common", "returns", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L326-L386
[ "def", "plot_returns", "(", "perf_attrib_data", ",", "cost", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "returns", "=", "perf_attrib_data", "[", "'total_returns'", "]", "total_r...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_alpha_returns
Plot histogram of daily multi-factor alpha returns (specific returns). Parameters ---------- alpha_returns : pd.Series series of daily alpha returns indexed by datetime ax : matplotlib.axes.Axes axes on which plots are made. if None, current axes will be used Returns ------- ...
pyfolio/perf_attrib.py
def plot_alpha_returns(alpha_returns, ax=None): """ Plot histogram of daily multi-factor alpha returns (specific returns). Parameters ---------- alpha_returns : pd.Series series of daily alpha returns indexed by datetime ax : matplotlib.axes.Axes axes on which plots are made. ...
def plot_alpha_returns(alpha_returns, ax=None): """ Plot histogram of daily multi-factor alpha returns (specific returns). Parameters ---------- alpha_returns : pd.Series series of daily alpha returns indexed by datetime ax : matplotlib.axes.Axes axes on which plots are made. ...
[ "Plot", "histogram", "of", "daily", "multi", "-", "factor", "alpha", "returns", "(", "specific", "returns", ")", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L389-L416
[ "def", "plot_alpha_returns", "(", "alpha_returns", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "ax", ".", "hist", "(", "alpha_returns", ",", "color", "=", "'g'", ",", "label", "=", "'Mult...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_factor_contribution_to_perf
Plot each factor's contribution to performance. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific returns as columns, and datetimes as index - Example: momentum reversal common_returns specific_returns ...
pyfolio/perf_attrib.py
def plot_factor_contribution_to_perf( perf_attrib_data, ax=None, title='Cumulative common returns attribution', ): """ Plot each factor's contribution to performance. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific ...
def plot_factor_contribution_to_perf( perf_attrib_data, ax=None, title='Cumulative common returns attribution', ): """ Plot each factor's contribution to performance. Parameters ---------- perf_attrib_data : pd.DataFrame df with factors, common returns, and specific ...
[ "Plot", "each", "factor", "s", "contribution", "to", "performance", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L419-L468
[ "def", "plot_factor_contribution_to_perf", "(", "perf_attrib_data", ",", "ax", "=", "None", ",", "title", "=", "'Cumulative common returns attribution'", ",", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "factors_to_plot", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_risk_exposures
Parameters ---------- exposures : pd.DataFrame df indexed by datetime, with factors as columns - Example: momentum reversal dt 2017-01-01 -0.238655 0.077123 2017-01-02 0.821872 1.520515 ax : matplotlib.axes.Axes axes o...
pyfolio/perf_attrib.py
def plot_risk_exposures(exposures, ax=None, title='Daily risk factor exposures'): """ Parameters ---------- exposures : pd.DataFrame df indexed by datetime, with factors as columns - Example: momentum reversal dt 20...
def plot_risk_exposures(exposures, ax=None, title='Daily risk factor exposures'): """ Parameters ---------- exposures : pd.DataFrame df indexed by datetime, with factors as columns - Example: momentum reversal dt 20...
[ "Parameters", "----------", "exposures", ":", "pd", ".", "DataFrame", "df", "indexed", "by", "datetime", "with", "factors", "as", "columns", "-", "Example", ":", "momentum", "reversal", "dt", "2017", "-", "01", "-", "01", "-", "0", ".", "238655", "0", "....
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L471-L501
[ "def", "plot_risk_exposures", "(", "exposures", ",", "ax", "=", "None", ",", "title", "=", "'Daily risk factor exposures'", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "for", "col", "in", "exposures", ":", "ax", "."...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
_align_and_warn
Make sure that all inputs have matching dates and tickers, and raise warnings if necessary.
pyfolio/perf_attrib.py
def _align_and_warn(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Make sure that all inputs have matching dates and tickers, and raise warnings if necessary...
def _align_and_warn(returns, positions, factor_returns, factor_loadings, transactions=None, pos_in_dollars=True): """ Make sure that all inputs have matching dates and tickers, and raise warnings if necessary...
[ "Make", "sure", "that", "all", "inputs", "have", "matching", "dates", "and", "tickers", "and", "raise", "warnings", "if", "necessary", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L504-L617
[ "def", "_align_and_warn", "(", "returns", ",", "positions", ",", "factor_returns", ",", "factor_loadings", ",", "transactions", "=", "None", ",", "pos_in_dollars", "=", "True", ")", ":", "missing_stocks", "=", "positions", ".", "columns", ".", "difference", "(",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
_stack_positions
Convert positions to percentages if necessary, and change them to long format. Parameters ---------- positions: pd.DataFrame Daily holdings (in dollars or percentages), indexed by date. Will be converted to percentages if positions are in dollars. Short positions show up as cash...
pyfolio/perf_attrib.py
def _stack_positions(positions, pos_in_dollars=True): """ Convert positions to percentages if necessary, and change them to long format. Parameters ---------- positions: pd.DataFrame Daily holdings (in dollars or percentages), indexed by date. Will be converted to percentages if...
def _stack_positions(positions, pos_in_dollars=True): """ Convert positions to percentages if necessary, and change them to long format. Parameters ---------- positions: pd.DataFrame Daily holdings (in dollars or percentages), indexed by date. Will be converted to percentages if...
[ "Convert", "positions", "to", "percentages", "if", "necessary", "and", "change", "them", "to", "long", "format", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L620-L647
[ "def", "_stack_positions", "(", "positions", ",", "pos_in_dollars", "=", "True", ")", ":", "if", "pos_in_dollars", ":", "# convert holdings to percentages", "positions", "=", "get_percent_alloc", "(", "positions", ")", "# remove cash after normalizing positions", "positions...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
_cumulative_returns_less_costs
Compute cumulative returns, less costs.
pyfolio/perf_attrib.py
def _cumulative_returns_less_costs(returns, costs): """ Compute cumulative returns, less costs. """ if costs is None: return ep.cum_returns(returns) return ep.cum_returns(returns - costs)
def _cumulative_returns_less_costs(returns, costs): """ Compute cumulative returns, less costs. """ if costs is None: return ep.cum_returns(returns) return ep.cum_returns(returns - costs)
[ "Compute", "cumulative", "returns", "less", "costs", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/perf_attrib.py#L650-L656
[ "def", "_cumulative_returns_less_costs", "(", "returns", ",", "costs", ")", ":", "if", "costs", "is", "None", ":", "return", "ep", ".", "cum_returns", "(", "returns", ")", "return", "ep", ".", "cum_returns", "(", "returns", "-", "costs", ")" ]
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
format_asset
If zipline asset objects are used, we want to print them out prettily within the tear sheet. This function should only be applied directly before displaying.
pyfolio/utils.py
def format_asset(asset): """ If zipline asset objects are used, we want to print them out prettily within the tear sheet. This function should only be applied directly before displaying. """ try: import zipline.assets except ImportError: return asset if isinstance(asset...
def format_asset(asset): """ If zipline asset objects are used, we want to print them out prettily within the tear sheet. This function should only be applied directly before displaying. """ try: import zipline.assets except ImportError: return asset if isinstance(asset...
[ "If", "zipline", "asset", "objects", "are", "used", "we", "want", "to", "print", "them", "out", "prettily", "within", "the", "tear", "sheet", ".", "This", "function", "should", "only", "be", "applied", "directly", "before", "displaying", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L81-L96
[ "def", "format_asset", "(", "asset", ")", ":", "try", ":", "import", "zipline", ".", "assets", "except", "ImportError", ":", "return", "asset", "if", "isinstance", "(", "asset", ",", "zipline", ".", "assets", ".", "Asset", ")", ":", "return", "asset", "....
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
vectorize
Decorator so that functions can be written to work on Series but may still be called with DataFrames.
pyfolio/utils.py
def vectorize(func): """ Decorator so that functions can be written to work on Series but may still be called with DataFrames. """ def wrapper(df, *args, **kwargs): if df.ndim == 1: return func(df, *args, **kwargs) elif df.ndim == 2: return df.apply(func, *ar...
def vectorize(func): """ Decorator so that functions can be written to work on Series but may still be called with DataFrames. """ def wrapper(df, *args, **kwargs): if df.ndim == 1: return func(df, *args, **kwargs) elif df.ndim == 2: return df.apply(func, *ar...
[ "Decorator", "so", "that", "functions", "can", "be", "written", "to", "work", "on", "Series", "but", "may", "still", "be", "called", "with", "DataFrames", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L99-L111
[ "def", "vectorize", "(", "func", ")", ":", "def", "wrapper", "(", "df", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "df", ".", "ndim", "==", "1", ":", "return", "func", "(", "df", ",", "*", "args", ",", "*", "*", "kwargs", ")",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
extract_rets_pos_txn_from_zipline
Extract returns, positions, transactions and leverage from the backtest data structure returned by zipline.TradingAlgorithm.run(). The returned data structures are in a format compatible with the rest of pyfolio and can be directly passed to e.g. tears.create_full_tear_sheet(). Parameters ----...
pyfolio/utils.py
def extract_rets_pos_txn_from_zipline(backtest): """ Extract returns, positions, transactions and leverage from the backtest data structure returned by zipline.TradingAlgorithm.run(). The returned data structures are in a format compatible with the rest of pyfolio and can be directly passed to ...
def extract_rets_pos_txn_from_zipline(backtest): """ Extract returns, positions, transactions and leverage from the backtest data structure returned by zipline.TradingAlgorithm.run(). The returned data structures are in a format compatible with the rest of pyfolio and can be directly passed to ...
[ "Extract", "returns", "positions", "transactions", "and", "leverage", "from", "the", "backtest", "data", "structure", "returned", "by", "zipline", ".", "TradingAlgorithm", ".", "run", "()", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L114-L167
[ "def", "extract_rets_pos_txn_from_zipline", "(", "backtest", ")", ":", "backtest", ".", "index", "=", "backtest", ".", "index", ".", "normalize", "(", ")", "if", "backtest", ".", "index", ".", "tzinfo", "is", "None", ":", "backtest", ".", "index", "=", "ba...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
print_table
Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters ---------- table : pandas.Series or pandas.DataFrame Table to pretty-print. name : str, optional Table name to display in upper left corner. flo...
pyfolio/utils.py
def print_table(table, name=None, float_format=None, formatters=None, header_rows=None): """ Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters -------...
def print_table(table, name=None, float_format=None, formatters=None, header_rows=None): """ Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters -------...
[ "Pretty", "print", "a", "pandas", "DataFrame", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L170-L219
[ "def", "print_table", "(", "table", ",", "name", "=", "None", ",", "float_format", "=", "None", ",", "formatters", "=", "None", ",", "header_rows", "=", "None", ")", ":", "if", "isinstance", "(", "table", ",", "pd", ".", "Series", ")", ":", "table", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
detect_intraday
Attempt to detect an intraday strategy. Get the number of positions held at the end of the day, and divide that by the number of unique stocks transacted every day. If the average quotient is below a threshold, then an intraday strategy is detected. Parameters ---------- positions : pd.DataFram...
pyfolio/utils.py
def detect_intraday(positions, transactions, threshold=0.25): """ Attempt to detect an intraday strategy. Get the number of positions held at the end of the day, and divide that by the number of unique stocks transacted every day. If the average quotient is below a threshold, then an intraday strate...
def detect_intraday(positions, transactions, threshold=0.25): """ Attempt to detect an intraday strategy. Get the number of positions held at the end of the day, and divide that by the number of unique stocks transacted every day. If the average quotient is below a threshold, then an intraday strate...
[ "Attempt", "to", "detect", "an", "intraday", "strategy", ".", "Get", "the", "number", "of", "positions", "held", "at", "the", "end", "of", "the", "day", "and", "divide", "that", "by", "the", "number", "of", "unique", "stocks", "transacted", "every", "day",...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L240-L266
[ "def", "detect_intraday", "(", "positions", ",", "transactions", ",", "threshold", "=", "0.25", ")", ":", "daily_txn", "=", "transactions", ".", "copy", "(", ")", "daily_txn", ".", "index", "=", "daily_txn", ".", "index", ".", "date", "txn_count", "=", "da...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
check_intraday
Logic for checking if a strategy is intraday and processing it. Parameters ---------- estimate: boolean or str, optional Approximate returns for intraday strategies. See description in tears.create_full_tear_sheet. returns : pd.Series Daily returns of the strategy, noncumulative...
pyfolio/utils.py
def check_intraday(estimate, returns, positions, transactions): """ Logic for checking if a strategy is intraday and processing it. Parameters ---------- estimate: boolean or str, optional Approximate returns for intraday strategies. See description in tears.create_full_tear_sheet. ...
def check_intraday(estimate, returns, positions, transactions): """ Logic for checking if a strategy is intraday and processing it. Parameters ---------- estimate: boolean or str, optional Approximate returns for intraday strategies. See description in tears.create_full_tear_sheet. ...
[ "Logic", "for", "checking", "if", "a", "strategy", "is", "intraday", "and", "processing", "it", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L269-L312
[ "def", "check_intraday", "(", "estimate", ",", "returns", ",", "positions", ",", "transactions", ")", ":", "if", "estimate", "==", "'infer'", ":", "if", "positions", "is", "not", "None", "and", "transactions", "is", "not", "None", ":", "if", "detect_intraday...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
estimate_intraday
Intraday strategies will often not hold positions at the day end. This attempts to find the point in the day that best represents the activity of the strategy on that day, and effectively resamples the end-of-day positions with the positions at this point of day. The point of day is found by detecting w...
pyfolio/utils.py
def estimate_intraday(returns, positions, transactions, EOD_hour=23): """ Intraday strategies will often not hold positions at the day end. This attempts to find the point in the day that best represents the activity of the strategy on that day, and effectively resamples the end-of-day positions wit...
def estimate_intraday(returns, positions, transactions, EOD_hour=23): """ Intraday strategies will often not hold positions at the day end. This attempts to find the point in the day that best represents the activity of the strategy on that day, and effectively resamples the end-of-day positions wit...
[ "Intraday", "strategies", "will", "often", "not", "hold", "positions", "at", "the", "day", "end", ".", "This", "attempts", "to", "find", "the", "point", "in", "the", "day", "that", "best", "represents", "the", "activity", "of", "the", "strategy", "on", "th...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L315-L374
[ "def", "estimate_intraday", "(", "returns", ",", "positions", ",", "transactions", ",", "EOD_hour", "=", "23", ")", ":", "# Construct DataFrame of transaction amounts", "txn_val", "=", "transactions", ".", "copy", "(", ")", "txn_val", ".", "index", ".", "names", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
clip_returns_to_benchmark
Drop entries from rets so that the start and end dates of rets match those of benchmark_rets. Parameters ---------- rets : pd.Series Daily returns of the strategy, noncumulative. - See pf.tears.create_full_tear_sheet for more details benchmark_rets : pd.Series Daily return...
pyfolio/utils.py
def clip_returns_to_benchmark(rets, benchmark_rets): """ Drop entries from rets so that the start and end dates of rets match those of benchmark_rets. Parameters ---------- rets : pd.Series Daily returns of the strategy, noncumulative. - See pf.tears.create_full_tear_sheet for ...
def clip_returns_to_benchmark(rets, benchmark_rets): """ Drop entries from rets so that the start and end dates of rets match those of benchmark_rets. Parameters ---------- rets : pd.Series Daily returns of the strategy, noncumulative. - See pf.tears.create_full_tear_sheet for ...
[ "Drop", "entries", "from", "rets", "so", "that", "the", "start", "and", "end", "dates", "of", "rets", "match", "those", "of", "benchmark_rets", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L377-L404
[ "def", "clip_returns_to_benchmark", "(", "rets", ",", "benchmark_rets", ")", ":", "if", "(", "rets", ".", "index", "[", "0", "]", "<", "benchmark_rets", ".", "index", "[", "0", "]", ")", "or", "(", "rets", ".", "index", "[", "-", "1", "]", ">", "be...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
to_utc
For use in tests; applied UTC timestamp to DataFrame.
pyfolio/utils.py
def to_utc(df): """ For use in tests; applied UTC timestamp to DataFrame. """ try: df.index = df.index.tz_localize('UTC') except TypeError: df.index = df.index.tz_convert('UTC') return df
def to_utc(df): """ For use in tests; applied UTC timestamp to DataFrame. """ try: df.index = df.index.tz_localize('UTC') except TypeError: df.index = df.index.tz_convert('UTC') return df
[ "For", "use", "in", "tests", ";", "applied", "UTC", "timestamp", "to", "DataFrame", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L407-L417
[ "def", "to_utc", "(", "df", ")", ":", "try", ":", "df", ".", "index", "=", "df", ".", "index", ".", "tz_localize", "(", "'UTC'", ")", "except", "TypeError", ":", "df", ".", "index", "=", "df", ".", "index", ".", "tz_convert", "(", "'UTC'", ")", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
get_symbol_rets
Calls the currently registered 'returns_func' Parameters ---------- symbol : object An identifier for the asset whose return series is desired. e.g. ticker symbol or database ID start : date, optional Earliest date to fetch data for. Defaults to earliest date ava...
pyfolio/utils.py
def get_symbol_rets(symbol, start=None, end=None): """ Calls the currently registered 'returns_func' Parameters ---------- symbol : object An identifier for the asset whose return series is desired. e.g. ticker symbol or database ID start : date, optional Earlies...
def get_symbol_rets(symbol, start=None, end=None): """ Calls the currently registered 'returns_func' Parameters ---------- symbol : object An identifier for the asset whose return series is desired. e.g. ticker symbol or database ID start : date, optional Earlies...
[ "Calls", "the", "currently", "registered", "returns_func" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L462-L487
[ "def", "get_symbol_rets", "(", "symbol", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "return", "SETTINGS", "[", "'returns_func'", "]", "(", "symbol", ",", "start", "=", "start", ",", "end", "=", "end", ")" ]
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
configure_legend
Format legend for perf attribution plots: - put legend to the right of plot instead of overlapping with it - make legend order match up with graph lines - set colors according to colormap
pyfolio/utils.py
def configure_legend(ax, autofmt_xdate=True, change_colors=False, rotation=30, ha='right'): """ Format legend for perf attribution plots: - put legend to the right of plot instead of overlapping with it - make legend order match up with graph lines - set colors according to colo...
def configure_legend(ax, autofmt_xdate=True, change_colors=False, rotation=30, ha='right'): """ Format legend for perf attribution plots: - put legend to the right of plot instead of overlapping with it - make legend order match up with graph lines - set colors according to colo...
[ "Format", "legend", "for", "perf", "attribution", "plots", ":", "-", "put", "legend", "to", "the", "right", "of", "plot", "instead", "of", "overlapping", "with", "it", "-", "make", "legend", "order", "match", "up", "with", "graph", "lines", "-", "set", "...
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L490-L530
[ "def", "configure_legend", "(", "ax", ",", "autofmt_xdate", "=", "True", ",", "change_colors", "=", "False", ",", "rotation", "=", "30", ",", "ha", "=", "'right'", ")", ":", "chartBox", "=", "ax", ".", "get_position", "(", ")", "ax", ".", "set_position",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
sample_colormap
Sample a colormap from matplotlib
pyfolio/utils.py
def sample_colormap(cmap_name, n_samples): """ Sample a colormap from matplotlib """ colors = [] colormap = cm.cmap_d[cmap_name] for i in np.linspace(0, 1, n_samples): colors.append(colormap(i)) return colors
def sample_colormap(cmap_name, n_samples): """ Sample a colormap from matplotlib """ colors = [] colormap = cm.cmap_d[cmap_name] for i in np.linspace(0, 1, n_samples): colors.append(colormap(i)) return colors
[ "Sample", "a", "colormap", "from", "matplotlib" ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/utils.py#L533-L542
[ "def", "sample_colormap", "(", "cmap_name", ",", "n_samples", ")", ":", "colors", "=", "[", "]", "colormap", "=", "cm", ".", "cmap_d", "[", "cmap_name", "]", "for", "i", "in", "np", ".", "linspace", "(", "0", ",", "1", ",", "n_samples", ")", ":", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
customize
Decorator to set plotting context and axes style during function call.
pyfolio/plotting.py
def customize(func): """ Decorator to set plotting context and axes style during function call. """ @wraps(func) def call_w_context(*args, **kwargs): set_context = kwargs.pop('set_context', True) if set_context: with plotting_context(), axes_style(): retur...
def customize(func): """ Decorator to set plotting context and axes style during function call. """ @wraps(func) def call_w_context(*args, **kwargs): set_context = kwargs.pop('set_context', True) if set_context: with plotting_context(), axes_style(): retur...
[ "Decorator", "to", "set", "plotting", "context", "and", "axes", "style", "during", "function", "call", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L43-L55
[ "def", "customize", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "call_w_context", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "set_context", "=", "kwargs", ".", "pop", "(", "'set_context'", ",", "True", ")", "if", "set_cont...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plotting_context
Create pyfolio default plotting style context. Under the hood, calls and returns seaborn.plotting_context() with some custom settings. Usually you would use in a with-context. Parameters ---------- context : str, optional Name of seaborn context. font_scale : float, optional Sc...
pyfolio/plotting.py
def plotting_context(context='notebook', font_scale=1.5, rc=None): """ Create pyfolio default plotting style context. Under the hood, calls and returns seaborn.plotting_context() with some custom settings. Usually you would use in a with-context. Parameters ---------- context : str, option...
def plotting_context(context='notebook', font_scale=1.5, rc=None): """ Create pyfolio default plotting style context. Under the hood, calls and returns seaborn.plotting_context() with some custom settings. Usually you would use in a with-context. Parameters ---------- context : str, option...
[ "Create", "pyfolio", "default", "plotting", "style", "context", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L58-L100
[ "def", "plotting_context", "(", "context", "=", "'notebook'", ",", "font_scale", "=", "1.5", ",", "rc", "=", "None", ")", ":", "if", "rc", "is", "None", ":", "rc", "=", "{", "}", "rc_default", "=", "{", "'lines.linewidth'", ":", "1.5", "}", "# Add defa...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
axes_style
Create pyfolio default axes style context. Under the hood, calls and returns seaborn.axes_style() with some custom settings. Usually you would use in a with-context. Parameters ---------- style : str, optional Name of seaborn style. rc : dict, optional Config flags. Return...
pyfolio/plotting.py
def axes_style(style='darkgrid', rc=None): """ Create pyfolio default axes style context. Under the hood, calls and returns seaborn.axes_style() with some custom settings. Usually you would use in a with-context. Parameters ---------- style : str, optional Name of seaborn style. ...
def axes_style(style='darkgrid', rc=None): """ Create pyfolio default axes style context. Under the hood, calls and returns seaborn.axes_style() with some custom settings. Usually you would use in a with-context. Parameters ---------- style : str, optional Name of seaborn style. ...
[ "Create", "pyfolio", "default", "axes", "style", "context", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L103-L140
[ "def", "axes_style", "(", "style", "=", "'darkgrid'", ",", "rc", "=", "None", ")", ":", "if", "rc", "is", "None", ":", "rc", "=", "{", "}", "rc_default", "=", "{", "}", "# Add defaults if they do not exist", "for", "name", ",", "val", "in", "rc_default",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_monthly_returns_heatmap
Plots a heatmap of returns by month. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional Axes upon which to plot. **kwargs, optional Passed to ...
pyfolio/plotting.py
def plot_monthly_returns_heatmap(returns, ax=None, **kwargs): """ Plots a heatmap of returns by month. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional ...
def plot_monthly_returns_heatmap(returns, ax=None, **kwargs): """ Plots a heatmap of returns by month. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional ...
[ "Plots", "a", "heatmap", "of", "returns", "by", "month", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L143-L182
[ "def", "plot_monthly_returns_heatmap", "(", "returns", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "monthly_ret_table", "=", "ep", ".", "aggregate_returns", "(", "ret...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_annual_returns
Plots a bar graph of returns by year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional Axes upon which to plot. **kwargs, optional Passed to...
pyfolio/plotting.py
def plot_annual_returns(returns, ax=None, **kwargs): """ Plots a bar graph of returns by year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional ...
def plot_annual_returns(returns, ax=None, **kwargs): """ Plots a bar graph of returns by year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional ...
[ "Plots", "a", "bar", "graph", "of", "returns", "by", "year", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L185-L232
[ "def", "plot_annual_returns", "(", "returns", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "x_axis_formatter", "=", "FuncFormatter", "(", "utils", ".", "percentage", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_monthly_returns_dist
Plots a distribution of monthly returns. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional Axes upon which to plot. **kwargs, optional Passed...
pyfolio/plotting.py
def plot_monthly_returns_dist(returns, ax=None, **kwargs): """ Plots a distribution of monthly returns. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional...
def plot_monthly_returns_dist(returns, ax=None, **kwargs): """ Plots a distribution of monthly returns. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional...
[ "Plots", "a", "distribution", "of", "monthly", "returns", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L235-L283
[ "def", "plot_monthly_returns_dist", "(", "returns", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "x_axis_formatter", "=", "FuncFormatter", "(", "utils", ".", "percenta...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_holdings
Plots total amount of stocks with an active position, either short or long. Displays daily total, daily average per month, and all-time daily average. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full...
pyfolio/plotting.py
def plot_holdings(returns, positions, legend_loc='best', ax=None, **kwargs): """ Plots total amount of stocks with an active position, either short or long. Displays daily total, daily average per month, and all-time daily average. Parameters ---------- returns : pd.Series Daily ret...
def plot_holdings(returns, positions, legend_loc='best', ax=None, **kwargs): """ Plots total amount of stocks with an active position, either short or long. Displays daily total, daily average per month, and all-time daily average. Parameters ---------- returns : pd.Series Daily ret...
[ "Plots", "total", "amount", "of", "stocks", "with", "an", "active", "position", "either", "short", "or", "long", ".", "Displays", "daily", "total", "daily", "average", "per", "month", "and", "all", "-", "time", "daily", "average", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L286-L343
[ "def", "plot_holdings", "(", "returns", ",", "positions", ",", "legend_loc", "=", "'best'", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "positions", "=", "positio...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_long_short_holdings
Plots total amount of stocks with an active position, breaking out short and long into transparent filled regions. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. positions : pd.DataFram...
pyfolio/plotting.py
def plot_long_short_holdings(returns, positions, legend_loc='upper left', ax=None, **kwargs): """ Plots total amount of stocks with an active position, breaking out short and long into transparent filled regions. Parameters ---------- returns : pd.Series Dai...
def plot_long_short_holdings(returns, positions, legend_loc='upper left', ax=None, **kwargs): """ Plots total amount of stocks with an active position, breaking out short and long into transparent filled regions. Parameters ---------- returns : pd.Series Dai...
[ "Plots", "total", "amount", "of", "stocks", "with", "an", "active", "position", "breaking", "out", "short", "and", "long", "into", "transparent", "filled", "regions", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L346-L400
[ "def", "plot_long_short_holdings", "(", "returns", ",", "positions", ",", "legend_loc", "=", "'upper left'", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "positions", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_drawdown_periods
Plots cumulative returns highlighting top drawdown periods. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. top : int, optional Amount of top drawdowns periods to plot (default 10). ...
pyfolio/plotting.py
def plot_drawdown_periods(returns, top=10, ax=None, **kwargs): """ Plots cumulative returns highlighting top drawdown periods. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. top : i...
def plot_drawdown_periods(returns, top=10, ax=None, **kwargs): """ Plots cumulative returns highlighting top drawdown periods. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. top : i...
[ "Plots", "cumulative", "returns", "highlighting", "top", "drawdown", "periods", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L403-L453
[ "def", "plot_drawdown_periods", "(", "returns", ",", "top", "=", "10", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "y_axis_formatter", "=", "FuncFormatter", "(", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_drawdown_underwater
Plots how far underwaterr returns are over time, or plots current drawdown vs. date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. ax : matplotlib.Axes, optional Axes upon whic...
pyfolio/plotting.py
def plot_drawdown_underwater(returns, ax=None, **kwargs): """ Plots how far underwaterr returns are over time, or plots current drawdown vs. date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full...
def plot_drawdown_underwater(returns, ax=None, **kwargs): """ Plots how far underwaterr returns are over time, or plots current drawdown vs. date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full...
[ "Plots", "how", "far", "underwaterr", "returns", "are", "over", "time", "or", "plots", "current", "drawdown", "vs", ".", "date", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L456-L490
[ "def", "plot_drawdown_underwater", "(", "returns", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "y_axis_formatter", "=", "FuncFormatter", "(", "utils", ".", "percentag...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_perf_stats
Create box plot of some performance metrics of the strategy. The width of the box whiskers is determined by a bootstrap. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. factor_returns : ...
pyfolio/plotting.py
def plot_perf_stats(returns, factor_returns, ax=None): """ Create box plot of some performance metrics of the strategy. The width of the box whiskers is determined by a bootstrap. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full...
def plot_perf_stats(returns, factor_returns, ax=None): """ Create box plot of some performance metrics of the strategy. The width of the box whiskers is determined by a bootstrap. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full...
[ "Create", "box", "plot", "of", "some", "performance", "metrics", "of", "the", "strategy", ".", "The", "width", "of", "the", "box", "whiskers", "is", "determined", "by", "a", "bootstrap", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L493-L526
[ "def", "plot_perf_stats", "(", "returns", ",", "factor_returns", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "bootstrap_values", "=", "timeseries", ".", "perf_stats_bootstrap", "(", "returns", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
show_perf_stats
Prints some performance metrics of the strategy. - Shows amount of time the strategy has been run in backtest and out-of-sample (in live trading). - Shows Omega ratio, max drawdown, Calmar ratio, annual return, stability, Sharpe ratio, annual volatility, alpha, and beta. Parameters ------...
pyfolio/plotting.py
def show_perf_stats(returns, factor_returns=None, positions=None, transactions=None, turnover_denom='AGB', live_start_date=None, bootstrap=False, header_rows=None): """ Prints some performance metrics of the strategy. - Shows amount of time the st...
def show_perf_stats(returns, factor_returns=None, positions=None, transactions=None, turnover_denom='AGB', live_start_date=None, bootstrap=False, header_rows=None): """ Prints some performance metrics of the strategy. - Shows amount of time the st...
[ "Prints", "some", "performance", "metrics", "of", "the", "strategy", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L539-L662
[ "def", "show_perf_stats", "(", "returns", ",", "factor_returns", "=", "None", ",", "positions", "=", "None", ",", "transactions", "=", "None", ",", "turnover_denom", "=", "'AGB'", ",", "live_start_date", "=", "None", ",", "bootstrap", "=", "False", ",", "hea...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_returns
Plots raw returns over time. Backtest returns are in green, and out-of-sample (live trading) returns are in red. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. live_start_date : da...
pyfolio/plotting.py
def plot_returns(returns, live_start_date=None, ax=None): """ Plots raw returns over time. Backtest returns are in green, and out-of-sample (live trading) returns are in red. Parameters ---------- returns : pd.Series Daily returns of the strategy, ...
def plot_returns(returns, live_start_date=None, ax=None): """ Plots raw returns over time. Backtest returns are in green, and out-of-sample (live trading) returns are in red. Parameters ---------- returns : pd.Series Daily returns of the strategy, ...
[ "Plots", "raw", "returns", "over", "time", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L665-L709
[ "def", "plot_returns", "(", "returns", ",", "live_start_date", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "ax", ".", "set_label", "(", "''", ")", "ax", ".", "set_ylabel", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_rolling_returns
Plots cumulative rolling returns versus some benchmarks'. Backtest returns are in green, and out-of-sample (live trading) returns are in red. Additionally, a non-parametric cone plot may be added to the out-of-sample returns region. Parameters ---------- returns : pd.Series Daily ...
pyfolio/plotting.py
def plot_rolling_returns(returns, factor_returns=None, live_start_date=None, logy=False, cone_std=None, legend_loc='best', volatility_match=False, ...
def plot_rolling_returns(returns, factor_returns=None, live_start_date=None, logy=False, cone_std=None, legend_loc='best', volatility_match=False, ...
[ "Plots", "cumulative", "rolling", "returns", "versus", "some", "benchmarks", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L712-L836
[ "def", "plot_rolling_returns", "(", "returns", ",", "factor_returns", "=", "None", ",", "live_start_date", "=", "None", ",", "logy", "=", "False", ",", "cone_std", "=", "None", ",", "legend_loc", "=", "'best'", ",", "volatility_match", "=", "False", ",", "co...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_rolling_beta
Plots the rolling 6-month and 12-month beta versus date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. factor_returns : pd.Series Daily noncumulative returns of the benchmark facto...
pyfolio/plotting.py
def plot_rolling_beta(returns, factor_returns, legend_loc='best', ax=None, **kwargs): """ Plots the rolling 6-month and 12-month beta versus date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in...
def plot_rolling_beta(returns, factor_returns, legend_loc='best', ax=None, **kwargs): """ Plots the rolling 6-month and 12-month beta versus date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in...
[ "Plots", "the", "rolling", "6", "-", "month", "and", "12", "-", "month", "beta", "versus", "date", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L839-L888
[ "def", "plot_rolling_beta", "(", "returns", ",", "factor_returns", ",", "legend_loc", "=", "'best'", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "y_axis_formatter", ...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_rolling_volatility
Plots the rolling volatility versus date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. factor_returns : pd.Series, optional Daily noncumulative returns of the benchmark factor to ...
pyfolio/plotting.py
def plot_rolling_volatility(returns, factor_returns=None, rolling_window=APPROX_BDAYS_PER_MONTH * 6, legend_loc='best', ax=None, **kwargs): """ Plots the rolling volatility versus date. Parameters ---------- returns : pd.Series Daily r...
def plot_rolling_volatility(returns, factor_returns=None, rolling_window=APPROX_BDAYS_PER_MONTH * 6, legend_loc='best', ax=None, **kwargs): """ Plots the rolling volatility versus date. Parameters ---------- returns : pd.Series Daily r...
[ "Plots", "the", "rolling", "volatility", "versus", "date", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L891-L954
[ "def", "plot_rolling_volatility", "(", "returns", ",", "factor_returns", "=", "None", ",", "rolling_window", "=", "APPROX_BDAYS_PER_MONTH", "*", "6", ",", "legend_loc", "=", "'best'", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_rolling_sharpe
Plots the rolling Sharpe ratio versus date. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. factor_returns : pd.Series, optional Daily noncumulative returns of the benchmark factor f...
pyfolio/plotting.py
def plot_rolling_sharpe(returns, factor_returns=None, rolling_window=APPROX_BDAYS_PER_MONTH * 6, legend_loc='best', ax=None, **kwargs): """ Plots the rolling Sharpe ratio versus date. Parameters ---------- returns : pd.Series Daily returns of ...
def plot_rolling_sharpe(returns, factor_returns=None, rolling_window=APPROX_BDAYS_PER_MONTH * 6, legend_loc='best', ax=None, **kwargs): """ Plots the rolling Sharpe ratio versus date. Parameters ---------- returns : pd.Series Daily returns of ...
[ "Plots", "the", "rolling", "Sharpe", "ratio", "versus", "date", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L957-L1022
[ "def", "plot_rolling_sharpe", "(", "returns", ",", "factor_returns", "=", "None", ",", "rolling_window", "=", "APPROX_BDAYS_PER_MONTH", "*", "6", ",", "legend_loc", "=", "'best'", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is",...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_gross_leverage
Plots gross leverage versus date. Gross leverage is the sum of long and short exposure per share divided by net asset value. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. position...
pyfolio/plotting.py
def plot_gross_leverage(returns, positions, ax=None, **kwargs): """ Plots gross leverage versus date. Gross leverage is the sum of long and short exposure per share divided by net asset value. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. ...
def plot_gross_leverage(returns, positions, ax=None, **kwargs): """ Plots gross leverage versus date. Gross leverage is the sum of long and short exposure per share divided by net asset value. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. ...
[ "Plots", "gross", "leverage", "versus", "date", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L1025-L1061
[ "def", "plot_gross_leverage", "(", "returns", ",", "positions", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "gl", "=", "timeseries", ".", "gross_lev", "(", "posit...
712716ab0cdebbec9fabb25eea3bf40e4354749d
valid
plot_exposures
Plots a cake chart of the long and short exposure. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. positions_alloc : pd.DataFrame Portfolio allocation of positions. See pos.g...
pyfolio/plotting.py
def plot_exposures(returns, positions, ax=None, **kwargs): """ Plots a cake chart of the long and short exposure. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. positions_alloc : pd...
def plot_exposures(returns, positions, ax=None, **kwargs): """ Plots a cake chart of the long and short exposure. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in tears.create_full_tear_sheet. positions_alloc : pd...
[ "Plots", "a", "cake", "chart", "of", "the", "long", "and", "short", "exposure", "." ]
quantopian/pyfolio
python
https://github.com/quantopian/pyfolio/blob/712716ab0cdebbec9fabb25eea3bf40e4354749d/pyfolio/plotting.py#L1064-L1111
[ "def", "plot_exposures", "(", "returns", ",", "positions", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax", "is", "None", ":", "ax", "=", "plt", ".", "gca", "(", ")", "pos_no_cash", "=", "positions", ".", "drop", "(", "'cash'"...
712716ab0cdebbec9fabb25eea3bf40e4354749d