Skip to content

Commit

Permalink
documentation for new exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
Mael-J committed Feb 19, 2024
1 parent c7bfd7f commit 4f36731
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ You can look for stocks by using the method `search_stock`. In the following exa
import mstarpy
import pandas as pd
response = mstarpy.search_stock(term="AB",field=["Name", "fundShareClassId", "SectorName"], exchange='PARIS',pageSize=20)
response = mstarpy.search_stock(term="AB",field=["Name", "fundShareClassId", "SectorName"], exchange='XPAR',pageSize=20)
df = pd.DataFrame(response)
print(df.head())
Expand All @@ -176,8 +176,7 @@ Tips : You can get different exchange by looking at the variable EXCHANGE in mst
.. code-block:: python
['NYSE', 'NASDAQ', 'LSE', 'AMSTERDAM', 'ATHENS', 'BOLSA_DE_VALORES', 'BOMBAY', 'BORSA_ITALIANA', 'BRUSSELS', 'COPENHAGEN', 'HELSINKI', 'ICELAND', 'INDIA', 'IPSX', 'IRELAND', 'ISTANBUL', 'LISBON', 'LUXEMBOURG', 'OSLO_BORS', 'PARIS', 'RIGA', 'SHANGAI', 'SHENZHEN', 'SINGAPORE', 'STOCKHOLM', 'SWISS', 'TAIWAN', 'TALLIN', 'THAILAND', 'TOKYO', 'VILNIUS', 'WARSAW', 'WIENER_BOERSE']
['ARCX', 'BATS', 'CHIA', 'E0WWE$$ALL', 'FINR', 'IPSX', 'IXUS', 'MABX', 'MSCO', 'MSTARFund', 'OTCM', 'USCO', 'XAMS', 'XASE', 'XASX', 'XATH', 'XBER', 'XBKK', 'XBOM', 'XBRU', 'XCNQ', 'XCSE', 'XDUB', 'XDUS', 'XETR', 'XEUR', 'XFRA', 'XHAM', 'XHAN', 'XHEL', 'XHKF', 'XHKG', 'XICE', 'XIST', 'XKOS', 'XLIS', 'XLIT', 'XLON', 'XLUX', 'XMEX', 'XMIL', 'XMUN', 'XNAS', 'XNSE', 'XNYS', 'XNZE', 'XOSE', 'XOSL', 'XOTC', 'XPAR', 'XRIS', 'XSES', 'XSHE', 'XSHG', 'XSTO', 'XSTU', 'XSWX', 'XTAI', 'XTAL', 'XTKS', 'XTSE', 'XWAR', 'XWBO']
Analysis of stocks
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -353,7 +352,7 @@ We want to find stocks with a 12 months return superior to 20%. The value of fil
from mstarpy import search_stock
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='PARIS', filters={"GBRReturnM12" : (">", 20)})
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='XPAR', filters={"GBRReturnM12" : (">", 20)})
df = pd.DataFrame(response)
Expand All @@ -373,7 +372,7 @@ It will work similar if we are looking for stocks with a PERatio inferior to 10.
from mstarpy import search_stock
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='PARIS', filters={"PERatio" : ("<", 10)})
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='XPAR', filters={"PERatio" : ("<", 10)})
df = pd.DataFrame(response)
Expand All @@ -395,7 +394,7 @@ We can also look like stocks with a PERatio between 10 and 20. The value of filt
from mstarpy import search_stock
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='PARIS', filters={"PERatio" : (10, 20)})
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='XPAR', filters={"PERatio" : (10, 20)})
df = pd.DataFrame(response)
Expand All @@ -418,7 +417,7 @@ Now we know how to use filters, we can combine them to find a precise securities
from mstarpy import search_stock
response = search_stock(term='',field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"],
exchange='PARIS', filters={"PERatio" : ("<", '10'), "GBRReturnM12" : (">", 20),
exchange='XPAR', filters={"PERatio" : ("<", '10'), "GBRReturnM12" : (">", 20),
"debtEquityRatio" : (0, 5), "SectorId" : ["IG000BA008", "IG000BA006"] })
df = pd.DataFrame(response)
Expand Down
76 changes: 38 additions & 38 deletions mstarpy/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def analysisData(self):
dict with general data about stock
Examples:
>>> Stock("visa", exchange="nyse").analysisData()
>>> Stock("visa", exchange="XNYS").analysisData()
"""
return self.GetData("morningstarTake/v3", url_suffix="analysisData")
Expand All @@ -61,7 +61,7 @@ def analysisReport(self):
dict with analyst overview
Examples:
>>> Stock("visa", exchange="nyse").analysisReport()
>>> Stock("visa", exchange="XNYS").analysisReport()
"""
return self.GetData("morningstarTake/v4", url_suffix="analysisReport")
Expand All @@ -78,8 +78,8 @@ def balanceSheet(self, period="annual", reportType="original"):
dict with balance sheet
Examples:
>>> Stock("visa", exchange="nyse").balanceSheet('quarterly', 'original')
>>> Stock("visa", exchange="nyse").balanceSheet('annual', 'restated')
>>> Stock("visa", exchange="XNYS").balanceSheet('quarterly', 'original')
>>> Stock("visa", exchange="XNYS").balanceSheet('annual', 'restated')
"""

Expand Down Expand Up @@ -112,8 +112,8 @@ def cashFlow(self, period="annual", reportType="original"):
dict with cash flow
Examples:
>>> Stock("visa", exchange="nyse").cashFlow('annual', 'restated')
>>> Stock("visa", exchange="nyse").cashFlow('quarterly', 'restated')
>>> Stock("visa", exchange="XNYS").cashFlow('annual', 'restated')
>>> Stock("visa", exchange="XNYS").cashFlow('quarterly', 'restated')
"""

Expand All @@ -127,7 +127,7 @@ def dividends(self):
dict with dividends
Examples:
>>> Stock("visa", exchange="nyse").dividends()
>>> Stock("visa", exchange="XNYS").dividends()
"""
return self.GetData("dividends/v4")
Expand All @@ -140,7 +140,7 @@ def esgRisk(self):
dict with esg risk
Examples:
>>> Stock("visa", exchange="nyse").esgRisk()
>>> Stock("visa", exchange="XNYS").esgRisk()
"""
return self.GetData("esgRisk")
Expand All @@ -153,7 +153,7 @@ def financialHealth(self):
dict with financial health
Examples:
>>> Stock("visa", exchange="nyse").financialHealth()
>>> Stock("visa", exchange="XNYS").financialHealth()
"""
return self.GetData("keyStats/financialHealth", url_suffix="")
Expand All @@ -173,10 +173,10 @@ def financialStatement(
dict with financial statement
Examples:
>>> Stock("visa", exchange="nyse").financialStatement('summary', 'quarterly', 'original')
>>> Stock("visa", exchange="nyse").financialStatement('cashflow', 'annual', 'restated')
>>> Stock("visa", exchange="nyse").financialStatement('balancesheet', 'annual', 'restated')
>>> Stock("visa", exchange="nyse").financialStatement('incomestatement', 'annual', 'restated')
>>> Stock("visa", exchange="XNYS").financialStatement('summary', 'quarterly', 'original')
>>> Stock("visa", exchange="XNYS").financialStatement('cashflow', 'annual', 'restated')
>>> Stock("visa", exchange="XNYS").financialStatement('balancesheet', 'annual', 'restated')
>>> Stock("visa", exchange="XNYS").financialStatement('incomestatement', 'annual', 'restated')
"""

Expand Down Expand Up @@ -241,8 +241,8 @@ def financialSummary(self, period="annual", reportType="original"):
dict with financial statement summary
Examples:
>>> Stock("visa", exchange="nyse").financialSummary('quarterly', 'original')
>>> Stock("visa", exchange="nyse").financialSummary('annual', 'restated')
>>> Stock("visa", exchange="XNYS").financialSummary('quarterly', 'original')
>>> Stock("visa", exchange="XNYS").financialSummary('annual', 'restated')
"""

Expand All @@ -256,7 +256,7 @@ def freeCashFlow(self):
dict with free cash flow
Examples:
>>> Stock("visa", exchange="nyse").freeCashFlow()
>>> Stock("visa", exchange="XNYS").freeCashFlow()
"""
return self.GetData("keyStats/cashFlow", url_suffix="")
Expand All @@ -274,7 +274,7 @@ def historical(self, start_date, end_date, frequency="daily"):
list of dict with price, volume and dividend
Examples:
>>> Stock("visa", exchange="nyse").history(datetime.datetime.today()- datetime.timedelta(30),datetime.datetime.today())
>>> Stock("visa", exchange="XNYS").history(datetime.datetime.today()- datetime.timedelta(30),datetime.datetime.today())
"""
return self.TimeSeries(
Expand All @@ -296,8 +296,8 @@ def incomeStatement(self, period="annual", reportType="original"):
dict with income statement
Examples:
>>> Stock("visa", exchange="nyse").incomeStatement('quarterly', 'original')
>>> Stock("visa", exchange="nyse").incomeStatement('annual', 'restated')
>>> Stock("visa", exchange="XNYS").incomeStatement('quarterly', 'original')
>>> Stock("visa", exchange="XNYS").incomeStatement('annual', 'restated')
"""

Expand All @@ -315,7 +315,7 @@ def institutionBuyers(self, top=20):
dict with the buyers
Examples:
>>> Stock("visa", exchange="nyse").institutionBuyers(top=50)
>>> Stock("visa", exchange="XNYS").institutionBuyers(top=50)
"""

Expand All @@ -336,7 +336,7 @@ def institutionConcentratedOwners(self, top=20):
dict with the concentarted owners
Examples:
>>> Stock("visa", exchange="nyse").institutionConcentratedOwners(top=50)
>>> Stock("visa", exchange="XNYS").institutionConcentratedOwners(top=50)
"""

Expand All @@ -357,7 +357,7 @@ def institutionOwnership(self, top=20):
dict with the main owners
Examples:
>>> Stock("visa", exchange="nyse").institutionOwnership(top=50)
>>> Stock("visa", exchange="XNYS").institutionOwnership(top=50)
"""

Expand All @@ -378,7 +378,7 @@ def institutionSellers(self, top=20):
dict with sellers
Examples:
>>> Stock("visa", exchange="nyse").institutionSellers(top=50)
>>> Stock("visa", exchange="XNYS").institutionSellers(top=50)
"""
if not isinstance(top, int):
Expand All @@ -396,7 +396,7 @@ def keyExecutives(self):
dict with key executives information
Examples:
>>> Stock("visa", exchange="nyse").keyExecutives()
>>> Stock("visa", exchange="XNYS").keyExecutives()
"""
return self.GetData("insiders/keyExecutives")
Expand All @@ -409,7 +409,7 @@ def keyRatio(self):
dict with key ratio
Examples:
>>> Stock("visa", exchange="nyse").keyRatio()
>>> Stock("visa", exchange="XNYS").keyRatio()
"""
return self.GetData("keyratios")
Expand All @@ -424,7 +424,7 @@ def mutualFundBuyers(self, top=20):
dict with the buyers
Examples:
>>> Stock("visa", exchange="nyse").mutualFundBuyers(top=50)
>>> Stock("visa", exchange="XNYS").mutualFundBuyers(top=50)
"""

Expand All @@ -443,7 +443,7 @@ def mutualFundConcentratedOwners(self, top=20):
dict with the concentarted owners
Examples:
>>> Stock("visa", exchange="nyse").mutualFundConcentratedOwners(top=50)
>>> Stock("visa", exchange="XNYS").mutualFundConcentratedOwners(top=50)
"""

Expand All @@ -464,7 +464,7 @@ def mutualFundOwnership(self, top=20):
dict with the main owners
Examples:
>>> Stock("visa", exchange="nyse").mutualFundOwnership(top=50)
>>> Stock("visa", exchange="XNYS").mutualFundOwnership(top=50)
"""

Expand All @@ -485,7 +485,7 @@ def mutualFundSellers(self, top=20):
dict with sellers
Examples:
>>> Stock("visa", exchange="nyse").mutualFundSellers(top=50)
>>> Stock("visa", exchange="XNYS").mutualFundSellers(top=50)
"""

Expand All @@ -504,7 +504,7 @@ def operatingGrowth(self):
dict with operating growth
Examples:
>>> Stock("visa", exchange="nyse").operatingGrowth()
>>> Stock("visa", exchange="XNYS").operatingGrowth()
"""
return self.GetData("keyStats/growthTable", url_suffix="")
Expand All @@ -517,7 +517,7 @@ def operatingMargin(self):
dict with operating margin
Examples:
>>> Stock("visa", exchange="nyse").operatingMargin()
>>> Stock("visa", exchange="XNYS").operatingMargin()
"""
return self.GetData("keyStats/OperatingAndEfficiency", url_suffix="")
Expand All @@ -530,7 +530,7 @@ def operatingPerformance(self):
dict with voperating performance
Examples:
>>> Stock("visa", exchange="nyse").operatingPerformance()
>>> Stock("visa", exchange="XNYS").operatingPerformance()
"""
return self.GetData("operatingPerformance/v2", url_suffix="")
Expand All @@ -543,7 +543,7 @@ def split(self):
dict with split history
Examples:
>>> Stock("visa", exchange="nyse").split()
>>> Stock("visa", exchange="XNYS").split()
"""
return self.GetData("split")
Expand All @@ -556,7 +556,7 @@ def tradingInformation(self) -> dict:
Returns:
dict with performance
Examples:
>>> Stock("visa", exchange="nyse").tradingInformation()
>>> Stock("visa", exchange="XNYS").tradingInformation()
"""
return self.RealtimeData("quotes")
Expand All @@ -569,7 +569,7 @@ def trailingTotalReturn(self):
dict with performance
Examples:
>>> Stock("visa", exchange="nyse").trailingTotalReturn()
>>> Stock("visa", exchange="XNYS").trailingTotalReturn()
"""
return self.GetData("trailingTotalReturns")
Expand All @@ -582,7 +582,7 @@ def transactionHistory(self):
list o dict of transaction of key people
Examples:
>>> Stock("visa", exchange="nyse").transactionHistory()
>>> Stock("visa", exchange="XNYS").transactionHistory()
"""
return self.GetData("insiders/transactionHistory")
Expand All @@ -595,7 +595,7 @@ def transactionSummary(self):
list of dict with transactions
Examples:
>>> Stock("visa", exchange="nyse").transactionSummary()
>>> Stock("visa", exchange="XNYS").transactionSummary()
"""
return self.GetData("insiders/transactionChart")
Expand All @@ -608,7 +608,7 @@ def valuation(self):
dict with valuation
Examples:
>>> Stock("visa", exchange="nyse").valuation()
>>> Stock("visa", exchange="XNYS").valuation()
"""
return self.GetData("valuation", url_suffix="")
5 changes: 3 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
# history = fund.nav(start_date,end_date)
# print(history)

print(search_stock("",["SecId","LegalName","Name"],exchange="XPAR"))
#print(search_stock("",["SecId","LegalName","Name"],exchange="XPAR"))


#print(Funds("myria").investmentLookup())
# print(list(EXCHANGE))
# #print(search_stock("a",field=["Name", "fundShareClassId", "GBRReturnM12", "PERatio"], exchange='HONG-KONG'))
# ms = Stock("MSFT", exchange="NASDAQ")
print(Stock("visa", exchange="XNYS").analysisData())


# top_owner = ms.mutualFundConcentratedOwners(top = 100)
# df = pd.DataFrame(top_owner["rows"])
Expand Down

0 comments on commit 4f36731

Please sign in to comment.