Skip to content

Commit

Permalink
add index composition for WLM1ke/apimoex#12
Browse files Browse the repository at this point in the history
  • Loading branch information
epogrebnyak committed Apr 20, 2022
1 parent a30d071 commit 8f75feb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@

# Market and board info
Market("stock", "shares").traded_boards()

#Index composition
Index("IMOEX").composition()
7 changes: 6 additions & 1 deletion finec/moex.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"describe",
"traded_boards",
"Stock",
"Index", # need index composition, as in https://github.com/WLM1ke/apimoex/issues/12
"Index",
"Bond",
"Currency",
"get_stocks",
Expand Down Expand Up @@ -326,6 +326,11 @@ class Index(Security):
market: str = default("index")
default_columns: ClassList = None

def composition(self):
# Implemented as in https://github.com/WLM1ke/apimoex/issues/12
endpoint = f"/iss/statistics/engines/stock/markets/index/analytics/{self.ticker}"
return get_all(endpoint)['analytics']


@dataclass
class Currency(Security):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_moex.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,6 @@ def test_usd_rur():
"WAPRICE": 31.1912,
}
]

def test_index_composition():
assert "SBER" in [d['ticker'] for d in Index("IMOEX").composition()]

0 comments on commit 8f75feb

Please sign in to comment.