brazilian_financial_indexes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4e53d68b92eee07da54f805ab60a5f59362ca70
4
+ data.tar.gz: 8903213a5184d4e405f701f82235e02dcf3ff7b1
5
+ SHA512:
6
+ metadata.gz: b3942a4246278ed0bc023947e78d0a8d1844fa068e31281b001b34ef2f929ebb1df2c4879b82aef1388d5e6abebc75175b915e70187d59ace172b776e873e5e8
7
+ data.tar.gz: 77fe69803427d5c5cea293c7eaa67aac2e31ad7dceca15f70b6100d9843d7020d0a80820a9e9aaa7e6e98fafb82ab0d0e1fc85337d8b1f3f21080f0dc8e54829
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ indic_bovespa_parser
2
+ ====================
3
+
4
+ Parser de Indicadores Econômicos da BM&F Bovespa
Binary file
data/bin/Indica.exe ADDED
Binary file
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "brazilian_financial_indexes"
5
+
6
+ BrazilianFinancialIndexes::Application.run
@@ -0,0 +1,35 @@
1
+ module BrazilianFinancialIndexes
2
+ INDEX_DOWNLOADER_BIN = Pathname("bin/Download_Indices.exe").to_s
3
+ OUTPUT = "Indic.txt"
4
+
5
+ class Application
6
+ def self.run
7
+ create_file
8
+ parse_file
9
+ end
10
+
11
+ private
12
+ def self.create_file
13
+ prefix = RUBY_PLATFORM.match(/linux/) ? "wine" : ""
14
+ File.delete(OUTPUT) if File.exists?(OUTPUT)
15
+ system("#{prefix} #{INDEX_DOWNLOADER_BIN}")
16
+ end
17
+
18
+ def self.parse_file
19
+ lines = File.readlines(OUTPUT).map do |line|
20
+ date = Date.parse(line[11..18])
21
+ value = parse_value(line)
22
+ OpenStruct.new(
23
+ id: line[0..5], complement: line[6..8], type: line[9..10],
24
+ date: date, group: line[19..20], code: line[21..45].strip,
25
+ value: value)
26
+ end.compact
27
+ end
28
+
29
+ def self.parse_value(line)
30
+ value = BigDecimal.new(line[46..70])
31
+ precision = line[71..72].to_i
32
+ parsed_value = (value / (10 ** precision)).to_f
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module BrazilianFinancialIndexes
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "bigdecimal"
2
+ require "ostruct"
3
+ require "pry"
4
+
5
+ require "brazilian_financial_indexes/application"
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brazilian_financial_indexes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adriano Bacha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Parses financial indicators from BMFBovespa
14
+ email:
15
+ - abacha@gmail.com
16
+ executables:
17
+ - brazilian_financial_indexes
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - bin/Download_Indices.exe
23
+ - bin/Indica.exe
24
+ - bin/brazilian_financial_indexes
25
+ - lib/brazilian_financial_indexes.rb
26
+ - lib/brazilian_financial_indexes/application.rb
27
+ - lib/brazilian_financial_indexes/version.rb
28
+ homepage: http://github.com/simplific/brazilian_financial_indexes
29
+ licenses: []
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project: brazilian_financial_indexes
47
+ rubygems_version: 2.2.2
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Parses financial indicators from BMFBovespa
51
+ test_files: []