xbrlware-ce 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Copying.txt +13 -0
- data/License.txt +13 -0
- data/Rakefile.rb +124 -0
- data/Readme.txt +15 -0
- data/doc/classes/Edgar.html +144 -0
- data/doc/classes/Edgar/HTMLFeedDownloader.html +199 -0
- data/doc/classes/Edgar/RSSFeedDownloader.html +225 -0
- data/doc/classes/Xbrlware.html +350 -0
- data/doc/classes/Xbrlware/Context.html +429 -0
- data/doc/classes/Xbrlware/Entity.html +323 -0
- data/doc/classes/Xbrlware/Identifier.html +191 -0
- data/doc/classes/Xbrlware/Instance.html +742 -0
- data/doc/classes/Xbrlware/Item.html +278 -0
- data/doc/classes/Xbrlware/LBConstants.html +144 -0
- data/doc/classes/Xbrlware/Linkbase.html +131 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase.html +212 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase/Calculation.html +172 -0
- data/doc/classes/Xbrlware/Linkbase/CalculationLinkbase/Calculation/CalculationArc.html +166 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase.html +210 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase/Definition.html +204 -0
- data/doc/classes/Xbrlware/Linkbase/DefinitionLinkbase/Definition/DefinitionArc.html +160 -0
- data/doc/classes/Xbrlware/Linkbase/LabelLinkbase.html +239 -0
- data/doc/classes/Xbrlware/Linkbase/LabelLinkbase/Label.html +189 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase.html +172 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase/Link.html +217 -0
- data/doc/classes/Xbrlware/Linkbase/Linkbase/Link/Arc.html +284 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase.html +224 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase/Presentation.html +222 -0
- data/doc/classes/Xbrlware/Linkbase/PresentationLinkbase/Presentation/PresentationArc.html +160 -0
- data/doc/classes/Xbrlware/Taxonomy.html +369 -0
- data/doc/classes/Xbrlware/TaxonomyDefintion.html +177 -0
- data/doc/classes/Xbrlware/Unit.html +179 -0
- data/doc/classes/Xbrlware/Unit/Divide.html +165 -0
- data/doc/created.rid +1 -0
- data/doc/files/Readme_txt.html +124 -0
- data/doc/files/lib/edgar/edgar_data_downloader_rb.html +129 -0
- data/doc/files/lib/edgar/util_rb.html +129 -0
- data/doc/files/lib/edgar_rb.html +141 -0
- data/doc/files/lib/xbrlware/constants_rb.html +129 -0
- data/doc/files/lib/xbrlware/context_rb.html +129 -0
- data/doc/files/lib/xbrlware/date_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/float_patch_rb.html +129 -0
- data/doc/files/lib/xbrlware/hash_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/instance_rb.html +129 -0
- data/doc/files/lib/xbrlware/item_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/calculation_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/definition_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/label_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/linkbase/presentation_linkbase_rb.html +129 -0
- data/doc/files/lib/xbrlware/meta_util_rb.html +129 -0
- data/doc/files/lib/xbrlware/taxonomy_rb.html +129 -0
- data/doc/files/lib/xbrlware/unit_rb.html +129 -0
- data/doc/files/lib/xbrlware/util_rb.html +129 -0
- data/doc/files/lib/xbrlware/xml_parser_rb.html +129 -0
- data/doc/files/lib/xbrlware_rb.html +163 -0
- data/doc/fr_class_index.html +55 -0
- data/doc/fr_file_index.html +48 -0
- data/doc/fr_method_index.html +104 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/example/benchmark/instance_parser_benchmark.rb +25 -0
- data/example/case_study/buy_strategy.rb +34 -0
- data/example/case_study/c-20091230.xml +29 -0
- data/example/case_study/c_sell_strategy.rb +29 -0
- data/example/lang_integration/thrift/rating-client.py +21 -0
- data/example/lang_integration/thrift/rating-impl.rb +13 -0
- data/example/lang_integration/thrift/rating-server.rb +25 -0
- data/example/lang_integration/thrift/rating.thrift +52 -0
- data/example/quick_start/foo.rb +10 -0
- data/example/quick_start/foo.xml +29 -0
- data/example/quick_start/print_item.rb +27 -0
- data/lib/edgar.rb +30 -0
- data/lib/edgar/edgar_data_downloader.rb +126 -0
- data/lib/edgar/util.rb +30 -0
- data/lib/xbrlware.rb +65 -0
- data/lib/xbrlware/constants.rb +29 -0
- data/lib/xbrlware/context.rb +148 -0
- data/lib/xbrlware/date_util.rb +35 -0
- data/lib/xbrlware/float_patch.rb +26 -0
- data/lib/xbrlware/hash_util.rb +175 -0
- data/lib/xbrlware/instance.rb +406 -0
- data/lib/xbrlware/item.rb +115 -0
- data/lib/xbrlware/linkbase/calculation_linkbase.rb +137 -0
- data/lib/xbrlware/linkbase/definition_linkbase.rb +186 -0
- data/lib/xbrlware/linkbase/label_linkbase.rb +128 -0
- data/lib/xbrlware/linkbase/linkbase.rb +170 -0
- data/lib/xbrlware/linkbase/presentation_linkbase.rb +160 -0
- data/lib/xbrlware/meta_util.rb +45 -0
- data/lib/xbrlware/taxonomies/us_gaap_taxonomy_20090131.rb +40365 -0
- data/lib/xbrlware/taxonomy.rb +133 -0
- data/lib/xbrlware/unit.rb +42 -0
- data/lib/xbrlware/util.rb +83 -0
- data/lib/xbrlware/xml_parser.rb +122 -0
- data/setup.rb +1585 -0
- data/test/lib/edgar/edgar_data_downloader_test.rb +35 -0
- data/test/lib/edgar/resources/0000930413-09-005485-index.htm +331 -0
- data/test/lib/edgar/resources/usgaap.rss.xml +2861 -0
- data/test/lib/xbrlware/411_footnotes_test.rb +65 -0
- data/test/lib/xbrlware/42_schemaref_test.rb +20 -0
- data/test/lib/xbrlware/46_item_test.rb +253 -0
- data/test/lib/xbrlware/47_context_test.rb +129 -0
- data/test/lib/xbrlware/48_unit_test.rb +45 -0
- data/test/lib/xbrlware/49_tuple_test.rb +12 -0
- data/test/lib/xbrlware/date_util_test.rb +24 -0
- data/test/lib/xbrlware/dimension/context_explicit_dimension_test.rb +40 -0
- data/test/lib/xbrlware/dimension/resources/context_explicit_dimension.xml +84 -0
- data/test/lib/xbrlware/float_patch_test.rb +10 -0
- data/test/lib/xbrlware/hash_util_test.rb +29 -0
- data/test/lib/xbrlware/instance_test.rb +250 -0
- data/test/lib/xbrlware/linkbase/calculation_linkbase_test.rb +39 -0
- data/test/lib/xbrlware/linkbase/definition_linkbase_test.rb +35 -0
- data/test/lib/xbrlware/linkbase/label_linkbase_test.rb +22 -0
- data/test/lib/xbrlware/linkbase/linkbase_test.rb +36 -0
- data/test/lib/xbrlware/linkbase/linkbase_test_util.rb +98 -0
- data/test/lib/xbrlware/linkbase/presentation_linkbase_test.rb +33 -0
- data/test/lib/xbrlware/linkbase/report.html +62 -0
- data/test/lib/xbrlware/linkbase/resources/cal.xml +219 -0
- data/test/lib/xbrlware/linkbase/resources/def.xml +186 -0
- data/test/lib/xbrlware/linkbase/resources/def_with_multiple_dimension.xml +41 -0
- data/test/lib/xbrlware/linkbase/resources/instance.xml +5822 -0
- data/test/lib/xbrlware/linkbase/resources/lab.xml +782 -0
- data/test/lib/xbrlware/linkbase/resources/pre.xml +485 -0
- data/test/lib/xbrlware/linkbase/resources/report_10_q.htm +12327 -0
- data/test/lib/xbrlware/linkbase/resources/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/linkbase/sample_html_report.html +40 -0
- data/test/lib/xbrlware/meta_util_test.rb +23 -0
- data/test/lib/xbrlware/resources/411/411_footnotes.xml +66 -0
- data/test/lib/xbrlware/resources/42/42_schema_ref_with_base.xml +7 -0
- data/test/lib/xbrlware/resources/42/42_schema_ref_without_base.xml +7 -0
- data/test/lib/xbrlware/resources/46/46_item_value.xml +61 -0
- data/test/lib/xbrlware/resources/47/472_period_forever.xml +29 -0
- data/test/lib/xbrlware/resources/47/472_period_instant.xml +24 -0
- data/test/lib/xbrlware/resources/47/472_period_start_dt_and_end_dt.xml +30 -0
- data/test/lib/xbrlware/resources/47/4731_entity_identifier.xml +29 -0
- data/test/lib/xbrlware/resources/47/4732_entity_segment_not_present.xml +24 -0
- data/test/lib/xbrlware/resources/47/4732_entity_segment_present.xml +30 -0
- data/test/lib/xbrlware/resources/47/474_scenario_not_present.xml +26 -0
- data/test/lib/xbrlware/resources/47/474_scenario_present.xml +30 -0
- data/test/lib/xbrlware/resources/47/47_multiple_contexts.xml +36 -0
- data/test/lib/xbrlware/resources/48/482_unit_measure.xml +32 -0
- data/test/lib/xbrlware/resources/48/483_unit_divide.xml +39 -0
- data/test/lib/xbrlware/resources/48/48_multiple_units.xml +43 -0
- data/test/lib/xbrlware/resources/49/49_tuple.xml +61 -0
- data/test/lib/xbrlware/resources/49_tuple.xsd +44 -0
- data/test/lib/xbrlware/resources/instance.xml +128 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/cal.xml +219 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/def.xml +186 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/instance.xml +5822 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/lab.xml +782 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/pre.xml +485 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/report/report_index.html +62 -0
- data/test/lib/xbrlware/resources/report_test_xbrl_files/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/cal.xml +223 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/def.xml +190 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/lab.xml +786 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/pre.xml +489 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/1/taxonomy.xsd +177 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/cal.xml +223 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/def.xml +190 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/lab.xml +786 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/linkbases/pre.xml +489 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/2/taxonomy.xsd +175 -0
- data/test/lib/xbrlware/resources/taxonomy_test_files/3/taxonomy.xsd +175 -0
- data/test/lib/xbrlware/resources/us_gaap_schema.xsd +8 -0
- data/test/lib/xbrlware/resources/us_gaap_schema_local.xsd +10 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/cal.xml +219 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/def.xml +186 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/instance.xml +5822 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/lab.xml +782 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/pre.xml +485 -0
- data/test/lib/xbrlware/resources/util_test_xbrl_files/taxonomy.xsd +178 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/dei-2009-01-31.xsd +162 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/dei-std-2009-01-31.xsd +23 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/negated-2008-03-31.xsd +23 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/ref-2006-02-27.xsd +121 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-gaap-2009-01-31.xsd +13474 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-roles-2009-01-31.xsd +2283 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/us-types-2009-01-31.xsd +368 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrl-instance-2003-12-31.xsd +772 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrl-linkbase-2003-12-31.xsd +477 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrldi-2006.xsd +41 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xbrldt-2005.xsd +53 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xl-2003-12-31.xsd +246 -0
- data/test/lib/xbrlware/resources/xbrl_xsd/xlink-2003-12-31.xsd +117 -0
- data/test/lib/xbrlware/taxonomy_test.rb +124 -0
- data/test/lib/xbrlware/util_test.rb +18 -0
- data/test/lib/xbrlware/xml_parser_test.rb +142 -0
- data/test/schema_validator_jruby.rb +40 -0
- data/test/schema_validator_ruby.rb +7 -0
- data/test/scratchpad/block.rb +36 -0
- data/test/test_helper.rb +21 -0
- data/xbrlware.iml +30 -0
- metadata +261 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'xbrlware'
|
2
|
+
|
3
|
+
r=Xbrlware::Report.new
|
4
|
+
class << r
|
5
|
+
public :xbrl_files
|
6
|
+
end
|
7
|
+
files=r.xbrl_files("../../../xbrlware-wiki/sample_reports/edgar_data")
|
8
|
+
|
9
|
+
output = StringIO.new
|
10
|
+
output << "|| *Instance + Taxonomy file size (KB)* || *Time (Seconds)* ||"
|
11
|
+
output << "\n"
|
12
|
+
|
13
|
+
files.each do |file_map|
|
14
|
+
m=Benchmark.measure do
|
15
|
+
instance=Xbrlware.ins(file_map["ins"])
|
16
|
+
end
|
17
|
+
|
18
|
+
size = File.size(file_map["ins"]) / 1024.0
|
19
|
+
size += File.size(file_map["tax"]) / 1024.0
|
20
|
+
output << "|| " << format("%.4f", size).to_s << " || "
|
21
|
+
output << format("%.4f", m.total).to_s << " || "
|
22
|
+
output << "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
puts output.string
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems' # you need this when xbrlware is installed as gem
|
2
|
+
require 'edgar'
|
3
|
+
require 'xbrlware'
|
4
|
+
|
5
|
+
dl=Edgar::HTMLFeedDownloader.new()
|
6
|
+
|
7
|
+
url="http://www.sec.gov/Archives/edgar/data/843006/000135448809002030/0001354488-09-002030-index.htm"
|
8
|
+
download_dir=url.split("/")[-2] # download dir is : 000135448809002030
|
9
|
+
dl.download(url, download_dir)
|
10
|
+
|
11
|
+
instance_file=Xbrlware.file_grep(download_dir)["ins"]
|
12
|
+
instance=Xbrlware.ins(instance_file)
|
13
|
+
|
14
|
+
item_name="Assets"
|
15
|
+
assets = instance.item(item_name) # Extracts "Assets"
|
16
|
+
|
17
|
+
if assets.size < 2
|
18
|
+
puts item_name + " Not found.."
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
curr_asset, prev_asset=0, 0
|
23
|
+
|
24
|
+
if Date.parse(assets[0].context.period) > Date.parse(assets[1].context.period)
|
25
|
+
curr_asset=assets[0].value.to_f
|
26
|
+
prev_asset=assets[1].value.to_f
|
27
|
+
else
|
28
|
+
curr_asset=assets[1].value.to_f
|
29
|
+
prev_asset=assets[0].value.to_f
|
30
|
+
end
|
31
|
+
|
32
|
+
if curr_asset > prev_asset
|
33
|
+
puts "Buy..."
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="US-ASCII"?>
|
2
|
+
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:iso4217="http://www.xbrl.org/2003/iso4217"
|
3
|
+
xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:us-gaap="http://xbrl.us/us-gaap/2009-01-31"
|
4
|
+
xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xlink="http://www.w3.org/1999/xlink">
|
5
|
+
<link:schemaRef xlink:href="" xlink:type="simple"/>
|
6
|
+
<xbrli:context id="Y2009">
|
7
|
+
<xbrli:entity>
|
8
|
+
<xbrli:identifier scheme="http://www.sec.gov/CIK">9999999999</xbrli:identifier>
|
9
|
+
</xbrli:entity>
|
10
|
+
<xbrli:period>
|
11
|
+
<xbrli:startDate>2009-01-02</xbrli:startDate>
|
12
|
+
<xbrli:endDate>2009-12-30</xbrli:endDate>
|
13
|
+
</xbrli:period>
|
14
|
+
</xbrli:context>
|
15
|
+
<xbrli:context id="Y2008">
|
16
|
+
<xbrli:entity>
|
17
|
+
<xbrli:identifier scheme="http://www.sec.gov/CIK">9999999999</xbrli:identifier>
|
18
|
+
</xbrli:entity>
|
19
|
+
<xbrli:period>
|
20
|
+
<xbrli:startDate>2008-01-02</xbrli:startDate>
|
21
|
+
<xbrli:endDate>2008-12-30</xbrli:endDate>
|
22
|
+
</xbrli:period>
|
23
|
+
</xbrli:context>
|
24
|
+
<xbrli:unit id="USD">
|
25
|
+
<xbrli:measure>iso4217:USD</xbrli:measure>
|
26
|
+
</xbrli:unit>
|
27
|
+
<us-gaap:NetIncomeLoss contextRef="Y2009" unitRef="USD" decimals="-6">730000000</us-gaap:NetIncomeLoss>
|
28
|
+
<us-gaap:NetIncomeLoss contextRef="Y2008" unitRef="USD" decimals="-6">902000000</us-gaap:NetIncomeLoss>
|
29
|
+
</xbrli:xbrl>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems' # you need this when xbrlware is installed as gem
|
2
|
+
require 'xbrlware'
|
3
|
+
|
4
|
+
instance_file="c-20091230.xml"
|
5
|
+
instance = Xbrlware.ins(instance_file) # Create parser instance
|
6
|
+
|
7
|
+
item_name="NetIncomeLoss" # This is the item we are interested in.
|
8
|
+
net_incomes = instance.item(item_name) # Extracts "NetIncomeLoss"
|
9
|
+
|
10
|
+
if net_incomes.size < 2
|
11
|
+
puts item_name + " Not found.."
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
curr_netincome, prev_netincome=0, 0
|
16
|
+
|
17
|
+
if Date.parse(net_incomes[0].context.period["end_date"]) > Date.parse(net_incomes[1].context.period["end_date"])
|
18
|
+
curr_netincome=net_incomes[0].value.to_f
|
19
|
+
prev_netincome=net_incomes[1].value.to_f
|
20
|
+
else
|
21
|
+
curr_netincome=net_incomes[1].value.to_f
|
22
|
+
prev_netincome=net_incomes[0].value.to_f
|
23
|
+
end
|
24
|
+
|
25
|
+
expected_netincome=prev_netincome-(prev_netincome * 0.05)
|
26
|
+
|
27
|
+
if curr_netincome < expected_netincome
|
28
|
+
puts "Sell..." # Sell C's stocks
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
|
3
|
+
import sys
|
4
|
+
|
5
|
+
sys.path.append("gen-py")
|
6
|
+
|
7
|
+
from thrift.transport import TTransport
|
8
|
+
from thrift.transport import TSocket
|
9
|
+
from thrift.protocol import TBinaryProtocol
|
10
|
+
|
11
|
+
from risk import Rating
|
12
|
+
from risk.ttypes import *
|
13
|
+
|
14
|
+
transport = TTransport.TBufferedTransport(TSocket.TSocket("localhost", "9090"))
|
15
|
+
protocol = TBinaryProtocol.TBinaryProtocol(transport)
|
16
|
+
|
17
|
+
client = Rating.Client(protocol)
|
18
|
+
transport.open()
|
19
|
+
|
20
|
+
print client.piotroski("JAVA")
|
21
|
+
print client.altman_z("GOOG")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# provide an implementation of Rating service
|
2
|
+
class RatingImpl
|
3
|
+
|
4
|
+
def piotroski(entity_name)
|
5
|
+
# Code that use xbrlware goes here
|
6
|
+
return 1 # return some dummy value
|
7
|
+
end
|
8
|
+
|
9
|
+
def altman_z(entity_name)
|
10
|
+
# Code that use xbrlware goes here
|
11
|
+
return 2.2567 # return some dummy value
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.push('gen-rb')
|
2
|
+
|
3
|
+
require 'thrift'
|
4
|
+
|
5
|
+
require 'thrift/transport/server_socket'
|
6
|
+
require 'thrift/transport/buffered_transport'
|
7
|
+
require 'thrift/server/simple_server'
|
8
|
+
|
9
|
+
require 'rating'
|
10
|
+
require 'rating-impl'
|
11
|
+
|
12
|
+
# Thrift provides mutiple communication endpoints
|
13
|
+
# - Here we will expose our service via a TCP socket
|
14
|
+
# - Web-service will run as a single thread, on port 9090
|
15
|
+
|
16
|
+
handler = RatingImpl.new()
|
17
|
+
processor = Risk::Rating::Processor.new(handler)
|
18
|
+
|
19
|
+
transport = Thrift::ServerSocket.new(9090)
|
20
|
+
transportFactory = Thrift::BufferedTransportFactory.new()
|
21
|
+
server = Thrift::SimpleServer.new(processor, transport, transportFactory)
|
22
|
+
|
23
|
+
puts "Starting the Rating service..."
|
24
|
+
server.serve()
|
25
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/local/bin/thrift --java --php --py
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
4
|
+
# distributed with this work for additional information
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
7
|
+
# "License"); you may not use this file except in compliance
|
8
|
+
# with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
#
|
19
|
+
# Interface definition for Ratings Service
|
20
|
+
#
|
21
|
+
|
22
|
+
namespace java org.risk.service
|
23
|
+
namespace cpp org.risk
|
24
|
+
namespace csharp Risk
|
25
|
+
namespace py risk
|
26
|
+
namespace php risk
|
27
|
+
namespace perl Risk
|
28
|
+
namespace rb Risk
|
29
|
+
|
30
|
+
#
|
31
|
+
# constants
|
32
|
+
#
|
33
|
+
|
34
|
+
# for clients checking that server and it have same thrift definitions.
|
35
|
+
const string VERSION = "1.2"
|
36
|
+
|
37
|
+
#
|
38
|
+
# Exceptions
|
39
|
+
# (note that internal server errors will raise a TApplicationException, courtesy of Thrift)
|
40
|
+
#
|
41
|
+
|
42
|
+
#
|
43
|
+
# service api
|
44
|
+
#
|
45
|
+
|
46
|
+
service Rating {
|
47
|
+
# compute Piotroski score
|
48
|
+
i16 piotroski(1:string entity_name),
|
49
|
+
|
50
|
+
# compute Altman Z Score
|
51
|
+
double altman_z(1:string entity_name)
|
52
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rubygems' # you need this when xbrlware is installed as gem
|
2
|
+
require 'xbrlware'
|
3
|
+
|
4
|
+
instance=Xbrlware.ins("foo.xml")
|
5
|
+
items=instance.item("ProfitLoss")
|
6
|
+
|
7
|
+
puts "Profit-Loss \t Context"
|
8
|
+
items.each do |item|
|
9
|
+
puts item.value+" \t "+item.context.id
|
10
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="US-ASCII"?>
|
2
|
+
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:iso4217="http://www.xbrl.org/2003/iso4217"
|
3
|
+
xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:us-gaap="http://xbrl.us/us-gaap/2009-01-31"
|
4
|
+
xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xlink="http://www.w3.org/1999/xlink">
|
5
|
+
<link:schemaRef xlink:href="" xlink:type="simple"/>
|
6
|
+
<xbrli:context id="D2009Q2YTD">
|
7
|
+
<xbrli:entity>
|
8
|
+
<xbrli:identifier scheme="http://www.sec.gov/CIK">9999999999</xbrli:identifier>
|
9
|
+
</xbrli:entity>
|
10
|
+
<xbrli:period>
|
11
|
+
<xbrli:startDate>2009-02-01</xbrli:startDate>
|
12
|
+
<xbrli:endDate>2009-08-15</xbrli:endDate>
|
13
|
+
</xbrli:period>
|
14
|
+
</xbrli:context>
|
15
|
+
<xbrli:context id="D2008Q2YTD">
|
16
|
+
<xbrli:entity>
|
17
|
+
<xbrli:identifier scheme="http://www.sec.gov/CIK">9999999999</xbrli:identifier>
|
18
|
+
</xbrli:entity>
|
19
|
+
<xbrli:period>
|
20
|
+
<xbrli:startDate>2008-02-03</xbrli:startDate>
|
21
|
+
<xbrli:endDate>2008-08-16</xbrli:endDate>
|
22
|
+
</xbrli:period>
|
23
|
+
</xbrli:context>
|
24
|
+
<xbrli:unit id="USD">
|
25
|
+
<xbrli:measure>iso4217:USD</xbrli:measure>
|
26
|
+
</xbrli:unit>
|
27
|
+
<us-gaap:ProfitLoss contextRef="D2008Q2YTD" unitRef="USD" decimals="-6">730000000</us-gaap:ProfitLoss>
|
28
|
+
<us-gaap:ProfitLoss contextRef="D2009Q2YTD" unitRef="USD" decimals="-6">902000000</us-gaap:ProfitLoss>
|
29
|
+
</xbrli:xbrl>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems' # you need this when xbrlware is installed as gem
|
2
|
+
require 'edgar'
|
3
|
+
require 'xbrlware'
|
4
|
+
|
5
|
+
dl=Edgar::HTMLFeedDownloader.new()
|
6
|
+
|
7
|
+
url="http://www.sec.gov/Archives/edgar/data/843006/000135448809002030/0001354488-09-002030-index.htm"
|
8
|
+
download_dir=url.split("/")[-2] # download dir is : 000135448809002030
|
9
|
+
dl.download(url, download_dir)
|
10
|
+
|
11
|
+
# Name of xbrl documents downloaded from EDGAR system is in the following convention
|
12
|
+
# calculation linkbase document ends with _cal.xml
|
13
|
+
# definition linkbase document ends with _def.xml
|
14
|
+
# presentation linkbase ends with _pre.xml
|
15
|
+
# label linkbase document ends with _lab.xml
|
16
|
+
# taxonomy document ends with .xsd
|
17
|
+
# instance document ends with .xml
|
18
|
+
# Xbrl::file_grep understands above convention.
|
19
|
+
instance_file=Xbrlware.file_grep(download_dir)["ins"] # use file_grep to filter xbrl files and get instance file
|
20
|
+
|
21
|
+
instance=Xbrlware.ins(instance_file)
|
22
|
+
|
23
|
+
items=instance.item("OtherAssetsCurrent")
|
24
|
+
puts "Other-Assets \t Context"
|
25
|
+
items.each do |item|
|
26
|
+
puts item.value+" \t "+item.context.id
|
27
|
+
end
|
data/lib/edgar.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: xbrlware@bitstat.com
|
4
|
+
#
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
require 'ftools'
|
21
|
+
|
22
|
+
require 'open-uri'
|
23
|
+
require 'rexml/document'
|
24
|
+
require 'rexml/streamlistener'
|
25
|
+
|
26
|
+
require 'edgar/util'
|
27
|
+
require 'edgar/edgar_data_downloader'
|
28
|
+
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: xbrlware@bitstat.com
|
4
|
+
#
|
5
|
+
# Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
module Edgar
|
21
|
+
|
22
|
+
# This class defines method to download XBRL files from SEC's XBRL RSS Feed.
|
23
|
+
# See {report generation xbrlware wiki}[http://code.google.com/p/xbrlware/wiki/ReportGeneration] for how to use this class.
|
24
|
+
class RSSFeedDownloader
|
25
|
+
include FileUtil
|
26
|
+
|
27
|
+
attr_reader :content
|
28
|
+
|
29
|
+
def initialize(sec_edgar_rss_file=nil)
|
30
|
+
sec_edgar_rss_file ||= "http://www.sec.gov/Archives/edgar/usgaap.rss.xml"
|
31
|
+
@content = XmlSimple.xml_in(open(sec_edgar_rss_file).read, {'ForceContent' => true})
|
32
|
+
end
|
33
|
+
|
34
|
+
# Takes limit (how many entities to download), download_to (where to download)
|
35
|
+
# default value for limit is 100
|
36
|
+
# default value for download_to is current_dir + "/edgar_data"
|
37
|
+
def download(limit=100, download_to=File.expand_path(".")+File::SEPARATOR+"edgar_data")
|
38
|
+
items=@content["channel"][0]["item"]
|
39
|
+
items.each_with_index do |item, index|
|
40
|
+
break if index==limit
|
41
|
+
files=get_xbrl_files(item)
|
42
|
+
download_to += File::SEPARATOR unless download_to.end_with?(File::SEPARATOR)
|
43
|
+
data_dir=download_to
|
44
|
+
data_dir=data_dir+File::SEPARATOR+item["xbrlFiling"][0]["cikNumber"][0]["content"]
|
45
|
+
data_dir=data_dir+File::SEPARATOR+item["xbrlFiling"][0]["accessionNumber"][0]["content"]
|
46
|
+
mkdir(data_dir)
|
47
|
+
files.each do |file|
|
48
|
+
file_content=open(file["url"]).read
|
49
|
+
dump_to_file(data_dir+File::SEPARATOR+file["file"], file_content)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def print_stat # :nodoc:
|
55
|
+
i_url=""
|
56
|
+
i_size=0
|
57
|
+
title=""
|
58
|
+
items=@content["channel"][0]["item"]
|
59
|
+
items.each do |item|
|
60
|
+
files=get_xbrl_files(item)
|
61
|
+
files.each do |file|
|
62
|
+
if file["type"]=="EX-101.INS" && (i_size==0 || file["size"].to_i < i_size)
|
63
|
+
i_size = file["size"].to_i
|
64
|
+
i_url = file["url"]
|
65
|
+
title = item["title"]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
puts ""
|
70
|
+
puts " Smallest Instance File " + i_url
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
# Gets url that end with xml and xsd
|
75
|
+
def get_xbrl_files(item)
|
76
|
+
xbrl_files=item["xbrlFiling"][0]["xbrlFiles"][0]["xbrlFile"]
|
77
|
+
return xbrl_files.select {|e| e["url"].end_with?("xml") || e["url"].end_with?("xsd")}
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
# This class defines method to download XBRL files from SEC's EDGAR filling url.
|
83
|
+
# See {report generation xbrlware wiki}[http://code.google.com/p/xbrlware/wiki/ReportGeneration] for how to use this class.
|
84
|
+
class HTMLFeedDownloader
|
85
|
+
include REXML::StreamListener
|
86
|
+
include FileUtil
|
87
|
+
|
88
|
+
attr_reader :links
|
89
|
+
|
90
|
+
# Takes url and download_to (where to download)
|
91
|
+
# default value for download_to is current_dir
|
92
|
+
def download(url, download_to=File.expand_path(".")+File::SEPARATOR)
|
93
|
+
$LOG.info " Starting download of fillings from SEC url ["+url+"]"
|
94
|
+
files=[]
|
95
|
+
content = open(url).read
|
96
|
+
@links = Set.new
|
97
|
+
uri=URI(url)
|
98
|
+
@base_path=""
|
99
|
+
@base_path=(uri.scheme+"://"+uri.host+((uri.port==80 && "") || ":"+uri.port.to_s)) unless uri.host.nil?
|
100
|
+
parse(content)
|
101
|
+
download_to += File::SEPARATOR unless download_to.end_with?(File::SEPARATOR)
|
102
|
+
mkdir(download_to)
|
103
|
+
@links.each do |link|
|
104
|
+
file=download_to + link.split("/")[-1]
|
105
|
+
dump_to_file(file, open(link).read)
|
106
|
+
files << file
|
107
|
+
end unless uri.host.nil?
|
108
|
+
files
|
109
|
+
end
|
110
|
+
|
111
|
+
# Callback method for notifying start of xml elements by REXML stream parser.
|
112
|
+
def tag_start(name, attrs) # :nodoc:
|
113
|
+
if "a"==name
|
114
|
+
href=attrs["href"]
|
115
|
+
@links << @base_path + href if href.end_with?("xml") || href.end_with?("xsd")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
def parse(text)
|
121
|
+
REXML::Document.parse_stream(text, self)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|