使用交互式经纪人从 python 3 中的特定标签中提取基本数据
Extract fundamental data with interactive broker from specific tags in python 3
全部。我想从 Interactive Broker API (Python 3) 中提取特定的基本面数据,但是,它显示的是 xml 版本。我无法获得例如市值(通过'打印(callback.fundamental_Data_data.find("MKTCAP"))')
import pandas as pd
import time
from IBWrapper import IBWrapper, contract
from ib.ext.EClientSocket import EClientSocket
from ib.ext.ScannerSubscription import ScannerSubscription
import re
stocks=[
'5'
]
for x in stocks:
callback = IBWrapper()
tws = EClientSocket(callback)
host = "127.0.0.1"
port = 7496
clientId = 25
tws.eConnect(host, port, clientId)
create = contract()
callback.initiate_variables()
contract_Details = create.create_contract(x, 'STK', 'SEHK', 'HKD')
tickerId = 8001
tws.reqFundamentalData(tickerId,
contract_Details,
"ReportSnapshot"
)
time.sleep(5)
print(callback.fundamental_Data_data)
print(callback.fundamental_Data_data.find("AATCA"))
print(callback.fundamental_Data_data.find("ACFSHR"))
print(callback.fundamental_Data_data.find("ADIV5YAVG"))
print(callback.fundamental_Data_data.find("MKTCAP"))
print(callback.fundamental_Data_data.find("QTANBVPS"))
print(callback.fundamental_Data_data.find("REVCHNGYR"))
print(callback.fundamental_Data_data.find("REVTRENDGR"))
tws.eDisconnect()
time.sleep(5)
tws.eDisconnect()
输出:
都是xml格式,可以显示最基本的数据。
<?xml version="1.0" encoding="UTF-8"?>
<RepportSnapshot Major="1" Minor="0" Revision="1">
<CoIDs>
<CoID Type="RepNo">AC317</CoID>
<CoID Type="CompanyName">HSBC Holdings plc (Hong Kong)</CoID>
</CoIDs>
<Issues>
<Issue ID="1" Type="C" Desc="Common Stock" Order="1">
<IssueID Type="Name">Ordinary Shares</IssueID>
<IssueID Type="Ticker">5</IssueID>
<IssueID Type="CUSIP">G4634U169</IssueID>
<IssueID Type="ISIN">GB0005405286</IssueID>
<IssueID Type="RIC">0005.HK</IssueID>
<IssueID Type="SEDOL">6158163</IssueID>
<IssueID Type="DisplayRIC">0005.HK</IssueID>
<IssueID Type="InstrumentPI">312270</IssueID>
<IssueID Type="QuotePI">1049324</IssueID>
<Exchange Code="HKG" Country="HKG">Hong Kong Stock
Exchange</Exchange>
<MostRecentSplit Date="2009-03-
12">1.14753</MostRecentSplit>
</Issue>
</Issues>
<CoGeneralInfo>
<CoStatus Code="1">Active</CoStatus>
<CoType Code="EQU">Equity Issue</CoType>
<LastModified>2018-07-20</LastModified>
<LatestAvailableAnnual>2017-12-31</LatestAvailableAnnual>
<LatestAvailableInterim>2018-03-31</LatestAvailableInterim>
<Employees LastUpdated="2018-03-31">228899</Employees>
<SharesOut Date="2018-07-24"
TotalFloat="19882952713.0">19952507521.0</SharesOut>
<ReportingCurrency Code="USD">U.S. Dollars</ReportingCurrency>
<MostRecentExchange Date="2018-07-24">1.0</MostRecentExchange>
</CoGeneralInfo>
<TextInfo>
<Text Type="Business Summary" lastModified="2017-03-
06T22:03:17">HSBC Holdings plc (HSBC) is the banking and financial services
company. The Company manages its products and services through four
businesses: Retail Banking and Wealth Management (RBWM), Commercial Banking
(CMB), Global Banking and Markets (GB&M), and Global Private Banking
(GPB). It operates across various geographical regions, which include
Europe, Asia, Middle East and North Africa, North America and Latin America.
RBWM business offers Retail Banking, Wealth Management, Asset Management and
Insurance. CMB services include working capital, term loans, payment
services and international trade facilitation, among other services, as well
as expertise in mergers and acquisitions, and access to financial markets.
GB&M supports government, corporate and institutional clients across the
world. GPB's products and services include Investment Management, Private
Wealth Solutions, and a range of Private Banking services.</Text>
<Text Type="Financial Summary" lastModified="2018-07-
20T09:20:11">BRIEF: For the three months ended 31 March 2018, HSBC Holdings
plc (Hong Kong) interest income increased 10% to .46B. Net interest income
after loan loss provision increased 11% to .29B. Net income applicable to
common stockholders decreased 1% to .09B. Net interest income after loan
loss provision reflects Asia segment increase of 22% to .86B, Net Interest
Margin, Total -% increase of 2% to 1.67%, Net Interest Spread.</Text>
</TextInfo>
<contactInfo lastUpdated="2018-07-20T09:20:26">
<streetAddress line="1">8 Canada Square</streetAddress>
<streetAddress line="2"></streetAddress>
<streetAddress line="3"></streetAddress>
<city>LONDON</city>
<state-region></state-region>
<postalCode>E14 5HQ</postalCode>
<country code="GBR">United Kingdom</country>
<contactName></contactName>
<contactTitle></contactTitle>
<phone>
<phone type="mainphone">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79918888</number>
</phone>
<phone type="mainfax">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79924880</number>
</phone>
</phone>
</contactInfo>
<webLinks lastUpdated="2016-11-07T05:00:04"><webSite mainCategory="Home
Page">http://www.hsbc.com/</webSite><eMail mainCategory="Company Contact/E-
mail"></eMail></webLinks>
<peerInfo lastUpdated="2018-07-20T09:20:26">
<IndustryInfo>
<Industry type="TRBC" order="1" reported="0"
code="5510101010" mnem="">Banks - NEC</Industry>
<Industry type="NAICS" order="1" reported="0"
code="52211" mnem="">Commercial Banking</Industry>
<Industry type="NAICS" order="2" reported="0"
code="52393" mnem="">Investment Advice</Industry>
<Industry type="NAICS" order="3" reported="0"
code="52392" mnem="">Portfolio Management</Industry>
<Industry type="SIC" order="0" reported="1" code="6035"
mnem="">Federal Savings Institutions</Industry>
<Industry type="SIC" order="1" reported="0" code="6029"
mnem="">Commercial Banks, Nec</Industry>
<Industry type="SIC" order="2" reported="0" code="6282"
mnem="">Investment Advice</Industry>
</IndustryInfo>
</peerInfo>
<officers>
<officer rank="1" since="01/01/2013">
<firstName>John</firstName>
<mI>Michael</mI>
<lastName>Flint</lastName>
<age>48 </age>
<title startYear="2018" startMonth="02" startDay="21"
iD1="CEO" abbr1="CEO" iD2="EDR" abbr2="Exec. Dir.">Chief Executive,
Executive Director</title>
</officer>
<officer rank="2" since="09/24/2010">
<firstName>Iain</firstName>
<mI>J.</mI>
<lastName>Mackay</lastName>
<age>56 </age>
<title startYear="2010" startMonth="12" startDay="03"
iD1="FID" abbr1="Fin. Dir." iD2="EDR" abbr2="Exec. Dir.">Group Finance
Director, Executive Director</title>
</officer>
<officer rank="3" since="08/01/2015">
<firstName>Andy</firstName>
<mI></mI>
<lastName>Maguire</lastName>
<age>51 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="COO" abbr1="COO" iD2="MDR" abbr2="Mgng.Dir.">Group Chief Operating
Officer, Group Managing Director</title>
</officer>
<officer rank="4" since="11/26/2010">
<firstName>Marc</firstName>
<mI>M.</mI>
<lastName>Moses</lastName>
<age>60 </age>
<title startYear="2014" startMonth="01" startDay="01"
iD1="CRO" abbr1="CRO" iD2="EDR" abbr2="Exec. Dir.">Group Chief Risk
Officer, Executive Director</title>
</officer>
<officer rank="5" since="NA">
<firstName>Elaine</firstName>
<mI></mI>
<lastName>Arden</lastName>
<age>49 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of Human
Resources</title>
</officer>
<officer rank="6" since="01/01/2011">
<firstName>Samir</firstName>
<mI></mI>
<lastName>Assaf</lastName>
<age>57 </age>
<title startYear="2011" startMonth="01" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Chief
Executive - Global Banking & Markets</title>
</officer>
<officer rank="7" since="NA">
<firstName>Colin</firstName>
<mI></mI>
<lastName>Bell</lastName>
<age>50 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of
Financial Crime Risk</title>
</officer>
<officer rank="8" since="10/01/2013">
<firstName>Peter</firstName>
<mI>W.</mI>
<lastName>Boyles</lastName>
<age>62 </age>
<title startYear="2013" startMonth="10" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director; Chief
Executive of Global Private Banking</title>
</officer>
<officer rank="9" since="08/01/2015">
<firstName>Patrick</firstName>
<mI>J.</mI>
<lastName>Burke</lastName>
<age>56 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director;
President and Chief Executive of HSBC USA</title>
</officer>
<officer rank="10" since="08/01/2015">
<firstName>Pierre</firstName>
<mI></mI>
<lastName>Goad</lastName>
<age>56 </age>
<title startYear="2016" startMonth="" startDay=""
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Group
Head of Employee Insight and Communications</title>
</officer>
</officers>
<Ratios PriceCurrency="HKD" ReportingCurrency="USD"
ExchangeRate="7.84640" LatestAvailableDate="2017-12-31">
<Group ID="Price and Volume">
<Ratio FieldName="NPRICE" Type="N">75.05000</Ratio>
<Ratio FieldName="NHIG" Type="N">86.00000</Ratio>
<Ratio FieldName="NLOW" Type="N">71.45000</Ratio>
<Ratio FieldName="PDATE" Type="D">2018-07-
25T00:00:00</Ratio>
<Ratio FieldName="VOL10DAVG" Type="N">12.50806</Ratio>
<Ratio FieldName="EV" Type="N">2466752.00000</Ratio>
</Group>
<Group ID="Income Statement">
<Ratio FieldName="MKTCAP" Type="N">1505191.00000</Ratio>
<Ratio FieldName="AREV" Type="N">321663.20000</Ratio>
<Ratio FieldName="AEBITD" Type="N">177752.30000</Ratio>
<Ratio FieldName="ANIAC" Type="N">86082.85000</Ratio>
</Group>
<Group ID="Per share data">
<Ratio FieldName="AEPSXCLXOR" Type="N">4.28869</Ratio>
<Ratio FieldName="AREVPS" Type="N">27.04842</Ratio>
<Ratio FieldName="ABVPS" Type="N">74.66691</Ratio>
<Ratio FieldName="ACSHPS" Type="N">108.96660</Ratio>
<Ratio FieldName="ACFSHR" Type="N">5.83985</Ratio>
<Ratio FieldName="ADIVSHR" Type="N">4.01226</Ratio>
</Group>
<Group ID="Other Ratios">
<Ratio FieldName="AGROSMGN" Type="N">-99999.99000</Ratio>
<Ratio FieldName="AROEPCT" Type="N">6.72498</Ratio>
<Ratio FieldName="APR2REV" Type="N">2.77242</Ratio>
<Ratio FieldName="APEEXCLXOR" Type="N">17.49954</Ratio>
<Ratio FieldName="APRICE2BK" Type="N">1.13825</Ratio>
<Ratio FieldName="Employees" Type="N">228899</Ratio>
</Group>
</Ratios>
<ForecastData ConsensusType="Mean" CurFiscalYear="2018"
CurFiscalYearEndMonth="12" CurInterimEndCalYear="2018"
CurInterimEndMonth="3" EarningsBasis="PRX">
<Ratio FieldName="ConsRecom" Type="N">
<Value PeriodType="CURR">1.9167</Value>
</Ratio>
<Ratio FieldName="TargetPrice" Type="N">
<Value PeriodType="CURR">86.00753</Value>
</Ratio>
<Ratio FieldName="ProjLTGrowthRate" Type="N">
<Value PeriodType="CURR">6.9100</Value>
</Ratio>
<Ratio FieldName="ProjPE" Type="N">
<Value PeriodType="CURR">13.07573</Value>
</Ratio>
<Ratio FieldName="ProjSales" Type="N">
<Value PeriodType="CURR">433073.04033</Value>
</Ratio>
<Ratio FieldName="ProjSalesQ" Type="N">
<Value PeriodType="CURR">276091.27680</Value>
</Ratio>
<Ratio FieldName="ProjEPS" Type="N">
<Value PeriodType="CURR">5.73964</Value>
</Ratio>
<Ratio FieldName="ProjEPSQ" Type="N">
<Value PeriodType="CURR">1.64774</Value>
</Ratio>
<Ratio FieldName="ProjProfit" Type="N">
<Value PeriodType="CURR">168752.58051</Value>
</Ratio>
<Ratio FieldName="ProjDPS" Type="N">
<Value PeriodType="CURR">4.03148</Value>
</Ratio>
</ForecastData>
</ReportSnapshot>
-1
8993
-1
8486
-1
-1
-1
如果你得到 XML 然后使用 lxml 或 BeautifulSoup 从 XML 获取数据。
您可以在这段代码的末尾看到 lxml
in use:
data = b'''<?xml version="1.0" encoding="UTF-8"?>
<ReportSnapshot Major="1" Minor="0" Revision="1">
<CoIDs>
<CoID Type="RepNo">AC317</CoID>
<CoID Type="CompanyName">HSBC Holdings plc (Hong Kong)</CoID>
</CoIDs>
<Issues>
<Issue ID="1" Type="C" Desc="Common Stock" Order="1">
<IssueID Type="Name">Ordinary Shares</IssueID>
<IssueID Type="Ticker">5</IssueID>
<IssueID Type="CUSIP">G4634U169</IssueID>
<IssueID Type="ISIN">GB0005405286</IssueID>
<IssueID Type="RIC">0005.HK</IssueID>
<IssueID Type="SEDOL">6158163</IssueID>
<IssueID Type="DisplayRIC">0005.HK</IssueID>
<IssueID Type="InstrumentPI">312270</IssueID>
<IssueID Type="QuotePI">1049324</IssueID>
<Exchange Code="HKG" Country="HKG">Hong Kong Stock
Exchange</Exchange>
<MostRecentSplit Date="2009-03-
12">1.14753</MostRecentSplit>
</Issue>
</Issues>
<CoGeneralInfo>
<CoStatus Code="1">Active</CoStatus>
<CoType Code="EQU">Equity Issue</CoType>
<LastModified>2018-07-20</LastModified>
<LatestAvailableAnnual>2017-12-31</LatestAvailableAnnual>
<LatestAvailableInterim>2018-03-31</LatestAvailableInterim>
<Employees LastUpdated="2018-03-31">228899</Employees>
<SharesOut Date="2018-07-24"
TotalFloat="19882952713.0">19952507521.0</SharesOut>
<ReportingCurrency Code="USD">U.S. Dollars</ReportingCurrency>
<MostRecentExchange Date="2018-07-24">1.0</MostRecentExchange>
</CoGeneralInfo>
<TextInfo>
<Text Type="Business Summary" lastModified="2017-03-
06T22:03:17">HSBC Holdings plc (HSBC) is the banking and financial services
company. The Company manages its products and services through four
businesses: Retail Banking and Wealth Management (RBWM), Commercial Banking
(CMB), Global Banking and Markets (GB&M), and Global Private Banking
(GPB). It operates across various geographical regions, which include
Europe, Asia, Middle East and North Africa, North America and Latin America.
RBWM business offers Retail Banking, Wealth Management, Asset Management and
Insurance. CMB services include working capital, term loans, payment
services and international trade facilitation, among other services, as well
as expertise in mergers and acquisitions, and access to financial markets.
GB&M supports government, corporate and institutional clients across the
world. GPB's products and services include Investment Management, Private
Wealth Solutions, and a range of Private Banking services.</Text>
<Text Type="Financial Summary" lastModified="2018-07-
20T09:20:11">BRIEF: For the three months ended 31 March 2018, HSBC Holdings
plc (Hong Kong) interest income increased 10% to .46B. Net interest income
after loan loss provision increased 11% to .29B. Net income applicable to
common stockholders decreased 1% to .09B. Net interest income after loan
loss provision reflects Asia segment increase of 22% to .86B, Net Interest
Margin, Total -% increase of 2% to 1.67%, Net Interest Spread.</Text>
</TextInfo>
<contactInfo lastUpdated="2018-07-20T09:20:26">
<streetAddress line="1">8 Canada Square</streetAddress>
<streetAddress line="2"></streetAddress>
<streetAddress line="3"></streetAddress>
<city>LONDON</city>
<state-region></state-region>
<postalCode>E14 5HQ</postalCode>
<country code="GBR">United Kingdom</country>
<contactName></contactName>
<contactTitle></contactTitle>
<phone>
<phone type="mainphone">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79918888</number>
</phone>
<phone type="mainfax">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79924880</number>
</phone>
</phone>
</contactInfo>
<webLinks lastUpdated="2016-11-07T05:00:04"><webSite mainCategory="Home
Page">http://www.hsbc.com/</webSite><eMail mainCategory="Company Contact/E-
mail"></eMail></webLinks>
<peerInfo lastUpdated="2018-07-20T09:20:26">
<IndustryInfo>
<Industry type="TRBC" order="1" reported="0"
code="5510101010" mnem="">Banks - NEC</Industry>
<Industry type="NAICS" order="1" reported="0"
code="52211" mnem="">Commercial Banking</Industry>
<Industry type="NAICS" order="2" reported="0"
code="52393" mnem="">Investment Advice</Industry>
<Industry type="NAICS" order="3" reported="0"
code="52392" mnem="">Portfolio Management</Industry>
<Industry type="SIC" order="0" reported="1" code="6035"
mnem="">Federal Savings Institutions</Industry>
<Industry type="SIC" order="1" reported="0" code="6029"
mnem="">Commercial Banks, Nec</Industry>
<Industry type="SIC" order="2" reported="0" code="6282"
mnem="">Investment Advice</Industry>
</IndustryInfo>
</peerInfo>
<officers>
<officer rank="1" since="01/01/2013">
<firstName>John</firstName>
<mI>Michael</mI>
<lastName>Flint</lastName>
<age>48 </age>
<title startYear="2018" startMonth="02" startDay="21"
iD1="CEO" abbr1="CEO" iD2="EDR" abbr2="Exec. Dir.">Chief Executive,
Executive Director</title>
</officer>
<officer rank="2" since="09/24/2010">
<firstName>Iain</firstName>
<mI>J.</mI>
<lastName>Mackay</lastName>
<age>56 </age>
<title startYear="2010" startMonth="12" startDay="03"
iD1="FID" abbr1="Fin. Dir." iD2="EDR" abbr2="Exec. Dir.">Group Finance
Director, Executive Director</title>
</officer>
<officer rank="3" since="08/01/2015">
<firstName>Andy</firstName>
<mI></mI>
<lastName>Maguire</lastName>
<age>51 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="COO" abbr1="COO" iD2="MDR" abbr2="Mgng.Dir.">Group Chief Operating
Officer, Group Managing Director</title>
</officer>
<officer rank="4" since="11/26/2010">
<firstName>Marc</firstName>
<mI>M.</mI>
<lastName>Moses</lastName>
<age>60 </age>
<title startYear="2014" startMonth="01" startDay="01"
iD1="CRO" abbr1="CRO" iD2="EDR" abbr2="Exec. Dir.">Group Chief Risk
Officer, Executive Director</title>
</officer>
<officer rank="5" since="NA">
<firstName>Elaine</firstName>
<mI></mI>
<lastName>Arden</lastName>
<age>49 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of Human
Resources</title>
</officer>
<officer rank="6" since="01/01/2011">
<firstName>Samir</firstName>
<mI></mI>
<lastName>Assaf</lastName>
<age>57 </age>
<title startYear="2011" startMonth="01" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Chief
Executive - Global Banking & Markets</title>
</officer>
<officer rank="7" since="NA">
<firstName>Colin</firstName>
<mI></mI>
<lastName>Bell</lastName>
<age>50 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of
Financial Crime Risk</title>
</officer>
<officer rank="8" since="10/01/2013">
<firstName>Peter</firstName>
<mI>W.</mI>
<lastName>Boyles</lastName>
<age>62 </age>
<title startYear="2013" startMonth="10" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director; Chief
Executive of Global Private Banking</title>
</officer>
<officer rank="9" since="08/01/2015">
<firstName>Patrick</firstName>
<mI>J.</mI>
<lastName>Burke</lastName>
<age>56 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director;
President and Chief Executive of HSBC USA</title>
</officer>
<officer rank="10" since="08/01/2015">
<firstName>Pierre</firstName>
<mI></mI>
<lastName>Goad</lastName>
<age>56 </age>
<title startYear="2016" startMonth="" startDay=""
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Group
Head of Employee Insight and Communications</title>
</officer>
</officers>
<Ratios PriceCurrency="HKD" ReportingCurrency="USD"
ExchangeRate="7.84640" LatestAvailableDate="2017-12-31">
<Group ID="Price and Volume">
<Ratio FieldName="NPRICE" Type="N">75.05000</Ratio>
<Ratio FieldName="NHIG" Type="N">86.00000</Ratio>
<Ratio FieldName="NLOW" Type="N">71.45000</Ratio>
<Ratio FieldName="PDATE" Type="D">2018-07-
25T00:00:00</Ratio>
<Ratio FieldName="VOL10DAVG" Type="N">12.50806</Ratio>
<Ratio FieldName="EV" Type="N">2466752.00000</Ratio>
</Group>
<Group ID="Income Statement">
<Ratio FieldName="MKTCAP" Type="N">1505191.00000</Ratio>
<Ratio FieldName="AREV" Type="N">321663.20000</Ratio>
<Ratio FieldName="AEBITD" Type="N">177752.30000</Ratio>
<Ratio FieldName="ANIAC" Type="N">86082.85000</Ratio>
</Group>
<Group ID="Per share data">
<Ratio FieldName="AEPSXCLXOR" Type="N">4.28869</Ratio>
<Ratio FieldName="AREVPS" Type="N">27.04842</Ratio>
<Ratio FieldName="ABVPS" Type="N">74.66691</Ratio>
<Ratio FieldName="ACSHPS" Type="N">108.96660</Ratio>
<Ratio FieldName="ACFSHR" Type="N">5.83985</Ratio>
<Ratio FieldName="ADIVSHR" Type="N">4.01226</Ratio>
</Group>
<Group ID="Other Ratios">
<Ratio FieldName="AGROSMGN" Type="N">-99999.99000</Ratio>
<Ratio FieldName="AROEPCT" Type="N">6.72498</Ratio>
<Ratio FieldName="APR2REV" Type="N">2.77242</Ratio>
<Ratio FieldName="APEEXCLXOR" Type="N">17.49954</Ratio>
<Ratio FieldName="APRICE2BK" Type="N">1.13825</Ratio>
<Ratio FieldName="Employees" Type="N">228899</Ratio>
</Group>
</Ratios>
<ForecastData ConsensusType="Mean" CurFiscalYear="2018"
CurFiscalYearEndMonth="12" CurInterimEndCalYear="2018"
CurInterimEndMonth="3" EarningsBasis="PRX">
<Ratio FieldName="ConsRecom" Type="N">
<Value PeriodType="CURR">1.9167</Value>
</Ratio>
<Ratio FieldName="TargetPrice" Type="N">
<Value PeriodType="CURR">86.00753</Value>
</Ratio>
<Ratio FieldName="ProjLTGrowthRate" Type="N">
<Value PeriodType="CURR">6.9100</Value>
</Ratio>
<Ratio FieldName="ProjPE" Type="N">
<Value PeriodType="CURR">13.07573</Value>
</Ratio>
<Ratio FieldName="ProjSales" Type="N">
<Value PeriodType="CURR">433073.04033</Value>
</Ratio>
<Ratio FieldName="ProjSalesQ" Type="N">
<Value PeriodType="CURR">276091.27680</Value>
</Ratio>
<Ratio FieldName="ProjEPS" Type="N">
<Value PeriodType="CURR">5.73964</Value>
</Ratio>
<Ratio FieldName="ProjEPSQ" Type="N">
<Value PeriodType="CURR">1.64774</Value>
</Ratio>
<Ratio FieldName="ProjProfit" Type="N">
<Value PeriodType="CURR">168752.58051</Value>
</Ratio>
<Ratio FieldName="ProjDPS" Type="N">
<Value PeriodType="CURR">4.03148</Value>
</Ratio>
</ForecastData>
</ReportSnapshot>'''
import lxml.etree
soup = lxml.etree.fromstring(data)
for item in soup.xpath('//IssueID'):
print(item.attrib['Type'], ':', item.text)
结果:
Name : Ordinary Shares
Ticker : 5
CUSIP : G4634U169
ISIN : GB0005405286
RIC : 0005.HK
SEDOL : 6158163
DisplayRIC : 0005.HK
InstrumentPI : 312270
QuotePI : 1049324
全部。我想从 Interactive Broker API (Python 3) 中提取特定的基本面数据,但是,它显示的是 xml 版本。我无法获得例如市值(通过'打印(callback.fundamental_Data_data.find("MKTCAP"))')
import pandas as pd
import time
from IBWrapper import IBWrapper, contract
from ib.ext.EClientSocket import EClientSocket
from ib.ext.ScannerSubscription import ScannerSubscription
import re
stocks=[
'5'
]
for x in stocks:
callback = IBWrapper()
tws = EClientSocket(callback)
host = "127.0.0.1"
port = 7496
clientId = 25
tws.eConnect(host, port, clientId)
create = contract()
callback.initiate_variables()
contract_Details = create.create_contract(x, 'STK', 'SEHK', 'HKD')
tickerId = 8001
tws.reqFundamentalData(tickerId,
contract_Details,
"ReportSnapshot"
)
time.sleep(5)
print(callback.fundamental_Data_data)
print(callback.fundamental_Data_data.find("AATCA"))
print(callback.fundamental_Data_data.find("ACFSHR"))
print(callback.fundamental_Data_data.find("ADIV5YAVG"))
print(callback.fundamental_Data_data.find("MKTCAP"))
print(callback.fundamental_Data_data.find("QTANBVPS"))
print(callback.fundamental_Data_data.find("REVCHNGYR"))
print(callback.fundamental_Data_data.find("REVTRENDGR"))
tws.eDisconnect()
time.sleep(5)
tws.eDisconnect()
输出: 都是xml格式,可以显示最基本的数据。
<?xml version="1.0" encoding="UTF-8"?>
<RepportSnapshot Major="1" Minor="0" Revision="1">
<CoIDs>
<CoID Type="RepNo">AC317</CoID>
<CoID Type="CompanyName">HSBC Holdings plc (Hong Kong)</CoID>
</CoIDs>
<Issues>
<Issue ID="1" Type="C" Desc="Common Stock" Order="1">
<IssueID Type="Name">Ordinary Shares</IssueID>
<IssueID Type="Ticker">5</IssueID>
<IssueID Type="CUSIP">G4634U169</IssueID>
<IssueID Type="ISIN">GB0005405286</IssueID>
<IssueID Type="RIC">0005.HK</IssueID>
<IssueID Type="SEDOL">6158163</IssueID>
<IssueID Type="DisplayRIC">0005.HK</IssueID>
<IssueID Type="InstrumentPI">312270</IssueID>
<IssueID Type="QuotePI">1049324</IssueID>
<Exchange Code="HKG" Country="HKG">Hong Kong Stock
Exchange</Exchange>
<MostRecentSplit Date="2009-03-
12">1.14753</MostRecentSplit>
</Issue>
</Issues>
<CoGeneralInfo>
<CoStatus Code="1">Active</CoStatus>
<CoType Code="EQU">Equity Issue</CoType>
<LastModified>2018-07-20</LastModified>
<LatestAvailableAnnual>2017-12-31</LatestAvailableAnnual>
<LatestAvailableInterim>2018-03-31</LatestAvailableInterim>
<Employees LastUpdated="2018-03-31">228899</Employees>
<SharesOut Date="2018-07-24"
TotalFloat="19882952713.0">19952507521.0</SharesOut>
<ReportingCurrency Code="USD">U.S. Dollars</ReportingCurrency>
<MostRecentExchange Date="2018-07-24">1.0</MostRecentExchange>
</CoGeneralInfo>
<TextInfo>
<Text Type="Business Summary" lastModified="2017-03-
06T22:03:17">HSBC Holdings plc (HSBC) is the banking and financial services
company. The Company manages its products and services through four
businesses: Retail Banking and Wealth Management (RBWM), Commercial Banking
(CMB), Global Banking and Markets (GB&M), and Global Private Banking
(GPB). It operates across various geographical regions, which include
Europe, Asia, Middle East and North Africa, North America and Latin America.
RBWM business offers Retail Banking, Wealth Management, Asset Management and
Insurance. CMB services include working capital, term loans, payment
services and international trade facilitation, among other services, as well
as expertise in mergers and acquisitions, and access to financial markets.
GB&M supports government, corporate and institutional clients across the
world. GPB's products and services include Investment Management, Private
Wealth Solutions, and a range of Private Banking services.</Text>
<Text Type="Financial Summary" lastModified="2018-07-
20T09:20:11">BRIEF: For the three months ended 31 March 2018, HSBC Holdings
plc (Hong Kong) interest income increased 10% to .46B. Net interest income
after loan loss provision increased 11% to .29B. Net income applicable to
common stockholders decreased 1% to .09B. Net interest income after loan
loss provision reflects Asia segment increase of 22% to .86B, Net Interest
Margin, Total -% increase of 2% to 1.67%, Net Interest Spread.</Text>
</TextInfo>
<contactInfo lastUpdated="2018-07-20T09:20:26">
<streetAddress line="1">8 Canada Square</streetAddress>
<streetAddress line="2"></streetAddress>
<streetAddress line="3"></streetAddress>
<city>LONDON</city>
<state-region></state-region>
<postalCode>E14 5HQ</postalCode>
<country code="GBR">United Kingdom</country>
<contactName></contactName>
<contactTitle></contactTitle>
<phone>
<phone type="mainphone">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79918888</number>
</phone>
<phone type="mainfax">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79924880</number>
</phone>
</phone>
</contactInfo>
<webLinks lastUpdated="2016-11-07T05:00:04"><webSite mainCategory="Home
Page">http://www.hsbc.com/</webSite><eMail mainCategory="Company Contact/E-
mail"></eMail></webLinks>
<peerInfo lastUpdated="2018-07-20T09:20:26">
<IndustryInfo>
<Industry type="TRBC" order="1" reported="0"
code="5510101010" mnem="">Banks - NEC</Industry>
<Industry type="NAICS" order="1" reported="0"
code="52211" mnem="">Commercial Banking</Industry>
<Industry type="NAICS" order="2" reported="0"
code="52393" mnem="">Investment Advice</Industry>
<Industry type="NAICS" order="3" reported="0"
code="52392" mnem="">Portfolio Management</Industry>
<Industry type="SIC" order="0" reported="1" code="6035"
mnem="">Federal Savings Institutions</Industry>
<Industry type="SIC" order="1" reported="0" code="6029"
mnem="">Commercial Banks, Nec</Industry>
<Industry type="SIC" order="2" reported="0" code="6282"
mnem="">Investment Advice</Industry>
</IndustryInfo>
</peerInfo>
<officers>
<officer rank="1" since="01/01/2013">
<firstName>John</firstName>
<mI>Michael</mI>
<lastName>Flint</lastName>
<age>48 </age>
<title startYear="2018" startMonth="02" startDay="21"
iD1="CEO" abbr1="CEO" iD2="EDR" abbr2="Exec. Dir.">Chief Executive,
Executive Director</title>
</officer>
<officer rank="2" since="09/24/2010">
<firstName>Iain</firstName>
<mI>J.</mI>
<lastName>Mackay</lastName>
<age>56 </age>
<title startYear="2010" startMonth="12" startDay="03"
iD1="FID" abbr1="Fin. Dir." iD2="EDR" abbr2="Exec. Dir.">Group Finance
Director, Executive Director</title>
</officer>
<officer rank="3" since="08/01/2015">
<firstName>Andy</firstName>
<mI></mI>
<lastName>Maguire</lastName>
<age>51 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="COO" abbr1="COO" iD2="MDR" abbr2="Mgng.Dir.">Group Chief Operating
Officer, Group Managing Director</title>
</officer>
<officer rank="4" since="11/26/2010">
<firstName>Marc</firstName>
<mI>M.</mI>
<lastName>Moses</lastName>
<age>60 </age>
<title startYear="2014" startMonth="01" startDay="01"
iD1="CRO" abbr1="CRO" iD2="EDR" abbr2="Exec. Dir.">Group Chief Risk
Officer, Executive Director</title>
</officer>
<officer rank="5" since="NA">
<firstName>Elaine</firstName>
<mI></mI>
<lastName>Arden</lastName>
<age>49 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of Human
Resources</title>
</officer>
<officer rank="6" since="01/01/2011">
<firstName>Samir</firstName>
<mI></mI>
<lastName>Assaf</lastName>
<age>57 </age>
<title startYear="2011" startMonth="01" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Chief
Executive - Global Banking & Markets</title>
</officer>
<officer rank="7" since="NA">
<firstName>Colin</firstName>
<mI></mI>
<lastName>Bell</lastName>
<age>50 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of
Financial Crime Risk</title>
</officer>
<officer rank="8" since="10/01/2013">
<firstName>Peter</firstName>
<mI>W.</mI>
<lastName>Boyles</lastName>
<age>62 </age>
<title startYear="2013" startMonth="10" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director; Chief
Executive of Global Private Banking</title>
</officer>
<officer rank="9" since="08/01/2015">
<firstName>Patrick</firstName>
<mI>J.</mI>
<lastName>Burke</lastName>
<age>56 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director;
President and Chief Executive of HSBC USA</title>
</officer>
<officer rank="10" since="08/01/2015">
<firstName>Pierre</firstName>
<mI></mI>
<lastName>Goad</lastName>
<age>56 </age>
<title startYear="2016" startMonth="" startDay=""
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Group
Head of Employee Insight and Communications</title>
</officer>
</officers>
<Ratios PriceCurrency="HKD" ReportingCurrency="USD"
ExchangeRate="7.84640" LatestAvailableDate="2017-12-31">
<Group ID="Price and Volume">
<Ratio FieldName="NPRICE" Type="N">75.05000</Ratio>
<Ratio FieldName="NHIG" Type="N">86.00000</Ratio>
<Ratio FieldName="NLOW" Type="N">71.45000</Ratio>
<Ratio FieldName="PDATE" Type="D">2018-07-
25T00:00:00</Ratio>
<Ratio FieldName="VOL10DAVG" Type="N">12.50806</Ratio>
<Ratio FieldName="EV" Type="N">2466752.00000</Ratio>
</Group>
<Group ID="Income Statement">
<Ratio FieldName="MKTCAP" Type="N">1505191.00000</Ratio>
<Ratio FieldName="AREV" Type="N">321663.20000</Ratio>
<Ratio FieldName="AEBITD" Type="N">177752.30000</Ratio>
<Ratio FieldName="ANIAC" Type="N">86082.85000</Ratio>
</Group>
<Group ID="Per share data">
<Ratio FieldName="AEPSXCLXOR" Type="N">4.28869</Ratio>
<Ratio FieldName="AREVPS" Type="N">27.04842</Ratio>
<Ratio FieldName="ABVPS" Type="N">74.66691</Ratio>
<Ratio FieldName="ACSHPS" Type="N">108.96660</Ratio>
<Ratio FieldName="ACFSHR" Type="N">5.83985</Ratio>
<Ratio FieldName="ADIVSHR" Type="N">4.01226</Ratio>
</Group>
<Group ID="Other Ratios">
<Ratio FieldName="AGROSMGN" Type="N">-99999.99000</Ratio>
<Ratio FieldName="AROEPCT" Type="N">6.72498</Ratio>
<Ratio FieldName="APR2REV" Type="N">2.77242</Ratio>
<Ratio FieldName="APEEXCLXOR" Type="N">17.49954</Ratio>
<Ratio FieldName="APRICE2BK" Type="N">1.13825</Ratio>
<Ratio FieldName="Employees" Type="N">228899</Ratio>
</Group>
</Ratios>
<ForecastData ConsensusType="Mean" CurFiscalYear="2018"
CurFiscalYearEndMonth="12" CurInterimEndCalYear="2018"
CurInterimEndMonth="3" EarningsBasis="PRX">
<Ratio FieldName="ConsRecom" Type="N">
<Value PeriodType="CURR">1.9167</Value>
</Ratio>
<Ratio FieldName="TargetPrice" Type="N">
<Value PeriodType="CURR">86.00753</Value>
</Ratio>
<Ratio FieldName="ProjLTGrowthRate" Type="N">
<Value PeriodType="CURR">6.9100</Value>
</Ratio>
<Ratio FieldName="ProjPE" Type="N">
<Value PeriodType="CURR">13.07573</Value>
</Ratio>
<Ratio FieldName="ProjSales" Type="N">
<Value PeriodType="CURR">433073.04033</Value>
</Ratio>
<Ratio FieldName="ProjSalesQ" Type="N">
<Value PeriodType="CURR">276091.27680</Value>
</Ratio>
<Ratio FieldName="ProjEPS" Type="N">
<Value PeriodType="CURR">5.73964</Value>
</Ratio>
<Ratio FieldName="ProjEPSQ" Type="N">
<Value PeriodType="CURR">1.64774</Value>
</Ratio>
<Ratio FieldName="ProjProfit" Type="N">
<Value PeriodType="CURR">168752.58051</Value>
</Ratio>
<Ratio FieldName="ProjDPS" Type="N">
<Value PeriodType="CURR">4.03148</Value>
</Ratio>
</ForecastData>
</ReportSnapshot>
-1
8993
-1
8486
-1
-1
-1
如果你得到 XML 然后使用 lxml 或 BeautifulSoup 从 XML 获取数据。
您可以在这段代码的末尾看到 lxml
in use:
data = b'''<?xml version="1.0" encoding="UTF-8"?>
<ReportSnapshot Major="1" Minor="0" Revision="1">
<CoIDs>
<CoID Type="RepNo">AC317</CoID>
<CoID Type="CompanyName">HSBC Holdings plc (Hong Kong)</CoID>
</CoIDs>
<Issues>
<Issue ID="1" Type="C" Desc="Common Stock" Order="1">
<IssueID Type="Name">Ordinary Shares</IssueID>
<IssueID Type="Ticker">5</IssueID>
<IssueID Type="CUSIP">G4634U169</IssueID>
<IssueID Type="ISIN">GB0005405286</IssueID>
<IssueID Type="RIC">0005.HK</IssueID>
<IssueID Type="SEDOL">6158163</IssueID>
<IssueID Type="DisplayRIC">0005.HK</IssueID>
<IssueID Type="InstrumentPI">312270</IssueID>
<IssueID Type="QuotePI">1049324</IssueID>
<Exchange Code="HKG" Country="HKG">Hong Kong Stock
Exchange</Exchange>
<MostRecentSplit Date="2009-03-
12">1.14753</MostRecentSplit>
</Issue>
</Issues>
<CoGeneralInfo>
<CoStatus Code="1">Active</CoStatus>
<CoType Code="EQU">Equity Issue</CoType>
<LastModified>2018-07-20</LastModified>
<LatestAvailableAnnual>2017-12-31</LatestAvailableAnnual>
<LatestAvailableInterim>2018-03-31</LatestAvailableInterim>
<Employees LastUpdated="2018-03-31">228899</Employees>
<SharesOut Date="2018-07-24"
TotalFloat="19882952713.0">19952507521.0</SharesOut>
<ReportingCurrency Code="USD">U.S. Dollars</ReportingCurrency>
<MostRecentExchange Date="2018-07-24">1.0</MostRecentExchange>
</CoGeneralInfo>
<TextInfo>
<Text Type="Business Summary" lastModified="2017-03-
06T22:03:17">HSBC Holdings plc (HSBC) is the banking and financial services
company. The Company manages its products and services through four
businesses: Retail Banking and Wealth Management (RBWM), Commercial Banking
(CMB), Global Banking and Markets (GB&M), and Global Private Banking
(GPB). It operates across various geographical regions, which include
Europe, Asia, Middle East and North Africa, North America and Latin America.
RBWM business offers Retail Banking, Wealth Management, Asset Management and
Insurance. CMB services include working capital, term loans, payment
services and international trade facilitation, among other services, as well
as expertise in mergers and acquisitions, and access to financial markets.
GB&M supports government, corporate and institutional clients across the
world. GPB's products and services include Investment Management, Private
Wealth Solutions, and a range of Private Banking services.</Text>
<Text Type="Financial Summary" lastModified="2018-07-
20T09:20:11">BRIEF: For the three months ended 31 March 2018, HSBC Holdings
plc (Hong Kong) interest income increased 10% to .46B. Net interest income
after loan loss provision increased 11% to .29B. Net income applicable to
common stockholders decreased 1% to .09B. Net interest income after loan
loss provision reflects Asia segment increase of 22% to .86B, Net Interest
Margin, Total -% increase of 2% to 1.67%, Net Interest Spread.</Text>
</TextInfo>
<contactInfo lastUpdated="2018-07-20T09:20:26">
<streetAddress line="1">8 Canada Square</streetAddress>
<streetAddress line="2"></streetAddress>
<streetAddress line="3"></streetAddress>
<city>LONDON</city>
<state-region></state-region>
<postalCode>E14 5HQ</postalCode>
<country code="GBR">United Kingdom</country>
<contactName></contactName>
<contactTitle></contactTitle>
<phone>
<phone type="mainphone">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79918888</number>
</phone>
<phone type="mainfax">
<countryPhoneCode>44</countryPhoneCode>
<city-areacode>20</city-areacode>
<number>79924880</number>
</phone>
</phone>
</contactInfo>
<webLinks lastUpdated="2016-11-07T05:00:04"><webSite mainCategory="Home
Page">http://www.hsbc.com/</webSite><eMail mainCategory="Company Contact/E-
mail"></eMail></webLinks>
<peerInfo lastUpdated="2018-07-20T09:20:26">
<IndustryInfo>
<Industry type="TRBC" order="1" reported="0"
code="5510101010" mnem="">Banks - NEC</Industry>
<Industry type="NAICS" order="1" reported="0"
code="52211" mnem="">Commercial Banking</Industry>
<Industry type="NAICS" order="2" reported="0"
code="52393" mnem="">Investment Advice</Industry>
<Industry type="NAICS" order="3" reported="0"
code="52392" mnem="">Portfolio Management</Industry>
<Industry type="SIC" order="0" reported="1" code="6035"
mnem="">Federal Savings Institutions</Industry>
<Industry type="SIC" order="1" reported="0" code="6029"
mnem="">Commercial Banks, Nec</Industry>
<Industry type="SIC" order="2" reported="0" code="6282"
mnem="">Investment Advice</Industry>
</IndustryInfo>
</peerInfo>
<officers>
<officer rank="1" since="01/01/2013">
<firstName>John</firstName>
<mI>Michael</mI>
<lastName>Flint</lastName>
<age>48 </age>
<title startYear="2018" startMonth="02" startDay="21"
iD1="CEO" abbr1="CEO" iD2="EDR" abbr2="Exec. Dir.">Chief Executive,
Executive Director</title>
</officer>
<officer rank="2" since="09/24/2010">
<firstName>Iain</firstName>
<mI>J.</mI>
<lastName>Mackay</lastName>
<age>56 </age>
<title startYear="2010" startMonth="12" startDay="03"
iD1="FID" abbr1="Fin. Dir." iD2="EDR" abbr2="Exec. Dir.">Group Finance
Director, Executive Director</title>
</officer>
<officer rank="3" since="08/01/2015">
<firstName>Andy</firstName>
<mI></mI>
<lastName>Maguire</lastName>
<age>51 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="COO" abbr1="COO" iD2="MDR" abbr2="Mgng.Dir.">Group Chief Operating
Officer, Group Managing Director</title>
</officer>
<officer rank="4" since="11/26/2010">
<firstName>Marc</firstName>
<mI>M.</mI>
<lastName>Moses</lastName>
<age>60 </age>
<title startYear="2014" startMonth="01" startDay="01"
iD1="CRO" abbr1="CRO" iD2="EDR" abbr2="Exec. Dir.">Group Chief Risk
Officer, Executive Director</title>
</officer>
<officer rank="5" since="NA">
<firstName>Elaine</firstName>
<mI></mI>
<lastName>Arden</lastName>
<age>49 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of Human
Resources</title>
</officer>
<officer rank="6" since="01/01/2011">
<firstName>Samir</firstName>
<mI></mI>
<lastName>Assaf</lastName>
<age>57 </age>
<title startYear="2011" startMonth="01" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Chief
Executive - Global Banking & Markets</title>
</officer>
<officer rank="7" since="NA">
<firstName>Colin</firstName>
<mI></mI>
<lastName>Bell</lastName>
<age>50 </age>
<title startYear="NA" startMonth="" startDay="" iD1="MDR"
abbr1="Mgng.Dir." iD2="" abbr2="">Managing Director, Group Head of
Financial Crime Risk</title>
</officer>
<officer rank="8" since="10/01/2013">
<firstName>Peter</firstName>
<mI>W.</mI>
<lastName>Boyles</lastName>
<age>62 </age>
<title startYear="2013" startMonth="10" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director; Chief
Executive of Global Private Banking</title>
</officer>
<officer rank="9" since="08/01/2015">
<firstName>Patrick</firstName>
<mI>J.</mI>
<lastName>Burke</lastName>
<age>56 </age>
<title startYear="2015" startMonth="08" startDay="01"
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director;
President and Chief Executive of HSBC USA</title>
</officer>
<officer rank="10" since="08/01/2015">
<firstName>Pierre</firstName>
<mI></mI>
<lastName>Goad</lastName>
<age>56 </age>
<title startYear="2016" startMonth="" startDay=""
iD1="MDR" abbr1="Mgng.Dir." iD2="" abbr2="">Group Managing Director, Group
Head of Employee Insight and Communications</title>
</officer>
</officers>
<Ratios PriceCurrency="HKD" ReportingCurrency="USD"
ExchangeRate="7.84640" LatestAvailableDate="2017-12-31">
<Group ID="Price and Volume">
<Ratio FieldName="NPRICE" Type="N">75.05000</Ratio>
<Ratio FieldName="NHIG" Type="N">86.00000</Ratio>
<Ratio FieldName="NLOW" Type="N">71.45000</Ratio>
<Ratio FieldName="PDATE" Type="D">2018-07-
25T00:00:00</Ratio>
<Ratio FieldName="VOL10DAVG" Type="N">12.50806</Ratio>
<Ratio FieldName="EV" Type="N">2466752.00000</Ratio>
</Group>
<Group ID="Income Statement">
<Ratio FieldName="MKTCAP" Type="N">1505191.00000</Ratio>
<Ratio FieldName="AREV" Type="N">321663.20000</Ratio>
<Ratio FieldName="AEBITD" Type="N">177752.30000</Ratio>
<Ratio FieldName="ANIAC" Type="N">86082.85000</Ratio>
</Group>
<Group ID="Per share data">
<Ratio FieldName="AEPSXCLXOR" Type="N">4.28869</Ratio>
<Ratio FieldName="AREVPS" Type="N">27.04842</Ratio>
<Ratio FieldName="ABVPS" Type="N">74.66691</Ratio>
<Ratio FieldName="ACSHPS" Type="N">108.96660</Ratio>
<Ratio FieldName="ACFSHR" Type="N">5.83985</Ratio>
<Ratio FieldName="ADIVSHR" Type="N">4.01226</Ratio>
</Group>
<Group ID="Other Ratios">
<Ratio FieldName="AGROSMGN" Type="N">-99999.99000</Ratio>
<Ratio FieldName="AROEPCT" Type="N">6.72498</Ratio>
<Ratio FieldName="APR2REV" Type="N">2.77242</Ratio>
<Ratio FieldName="APEEXCLXOR" Type="N">17.49954</Ratio>
<Ratio FieldName="APRICE2BK" Type="N">1.13825</Ratio>
<Ratio FieldName="Employees" Type="N">228899</Ratio>
</Group>
</Ratios>
<ForecastData ConsensusType="Mean" CurFiscalYear="2018"
CurFiscalYearEndMonth="12" CurInterimEndCalYear="2018"
CurInterimEndMonth="3" EarningsBasis="PRX">
<Ratio FieldName="ConsRecom" Type="N">
<Value PeriodType="CURR">1.9167</Value>
</Ratio>
<Ratio FieldName="TargetPrice" Type="N">
<Value PeriodType="CURR">86.00753</Value>
</Ratio>
<Ratio FieldName="ProjLTGrowthRate" Type="N">
<Value PeriodType="CURR">6.9100</Value>
</Ratio>
<Ratio FieldName="ProjPE" Type="N">
<Value PeriodType="CURR">13.07573</Value>
</Ratio>
<Ratio FieldName="ProjSales" Type="N">
<Value PeriodType="CURR">433073.04033</Value>
</Ratio>
<Ratio FieldName="ProjSalesQ" Type="N">
<Value PeriodType="CURR">276091.27680</Value>
</Ratio>
<Ratio FieldName="ProjEPS" Type="N">
<Value PeriodType="CURR">5.73964</Value>
</Ratio>
<Ratio FieldName="ProjEPSQ" Type="N">
<Value PeriodType="CURR">1.64774</Value>
</Ratio>
<Ratio FieldName="ProjProfit" Type="N">
<Value PeriodType="CURR">168752.58051</Value>
</Ratio>
<Ratio FieldName="ProjDPS" Type="N">
<Value PeriodType="CURR">4.03148</Value>
</Ratio>
</ForecastData>
</ReportSnapshot>'''
import lxml.etree
soup = lxml.etree.fromstring(data)
for item in soup.xpath('//IssueID'):
print(item.attrib['Type'], ':', item.text)
结果:
Name : Ordinary Shares
Ticker : 5
CUSIP : G4634U169
ISIN : GB0005405286
RIC : 0005.HK
SEDOL : 6158163
DisplayRIC : 0005.HK
InstrumentPI : 312270
QuotePI : 1049324