yfinance_wrapper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1d85bd7392805b47e38c34a148124b7ecd68822b597001c9051aeacd30791516
4
+ data.tar.gz: 12e22cf4668680cd6a6a3d10934575a77987459483cbd7aecc5a136a7b963aac
5
+ SHA512:
6
+ metadata.gz: be045351689c7bd513a98ec75817812946f447bdb1956ec8a88703c33c12219a86870739b803cb9f10593dd54f3a6b443e5f1f4005d717c3e1f1905644109b3f
7
+ data.tar.gz: 6595f89d4e915571c134734b32206b7fcbb6aab8bcdd8f946762743647692a22ddc2973c0ee9e489f41edb645132082523fcb296291291fb42eb4feae3d278e7
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/Documentation:
11
+ Enabled: false
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # YfinanceWrapper
2
+
3
+ YfinanceWrapper is a Ruby wrapper library for the Python yfinance library, which provides access to Yahoo Finance's API.
4
+
5
+ This library has the following features:
6
+
7
+ - Uses PyCall to make the Python yfinance library accessible from Ruby
8
+ - Simple and intuitive API
9
+ - Compatible with Ruby 3.0 and above
10
+
11
+ Main features:
12
+
13
+ - Stock information retrieval
14
+ - Stock price data retrieval
15
+ - Company information retrieval
16
+
17
+ This library supports the development of financial data applications and analysis tools by providing easy access to Yahoo Finance's data through Ruby.
18
+
19
+ # Installation
20
+
21
+ 1. Install python3.
22
+ 2. Install yfinance
23
+
24
+ ```bash
25
+ pip3 install yfinance
26
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pycall/import"
4
+
5
+ module YfinanceWrapper
6
+ class Ticker
7
+ def initialize(symbol)
8
+ @ticker = YfinanceWrapper.yf.Ticker.new(symbol)
9
+ end
10
+
11
+ def info
12
+ @ticker.info.to_h
13
+ end
14
+
15
+ def history(*args, **kwargs)
16
+ result = @ticker.history(*args, **kwargs)
17
+ indexes = result.index
18
+
19
+ res = {}
20
+
21
+ indexes.size.times do |i|
22
+ key = indexes[i]
23
+ res[Time.new(key.to_s)] = candle_to_hash(result.loc[key], %w[Open High Low Close])
24
+ end
25
+
26
+ res
27
+ end
28
+
29
+ private
30
+
31
+ # Add Candle class when candle needs more mothods.
32
+ def candle_to_hash(candle, keys)
33
+ keys.each_with_object({}) do |key, hash|
34
+ hash[key] = candle[key].to_f
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YfinanceWrapper
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "yfinance_wrapper/ticker"
4
+ include PyCall::Import
5
+ module YfinanceWrapper
6
+ pyimport :yfinance, as: :yf
7
+ # rubocop:disable Style/ClassVars
8
+ @@yf = yf
9
+ # rubocop:enable Style/ClassVars
10
+ end
@@ -0,0 +1,4 @@
1
+ module YfinanceWrapper
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yfinance_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ys7i
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pycall
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: numpy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pandas
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.8
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.8
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: A simple and easy-to-use Ruby wrapper library for Yahoo Finance API
70
+ email:
71
+ - s7i.yuhi@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - ".rubocop.yml"
78
+ - README.md
79
+ - Rakefile
80
+ - lib/yfinance_wrapper.rb
81
+ - lib/yfinance_wrapper/ticker.rb
82
+ - lib/yfinance_wrapper/version.rb
83
+ - sig/yfinance_wrapper.rbs
84
+ homepage: https://github.com/ys7i/yfinance_wrapper
85
+ licenses: []
86
+ metadata:
87
+ allowed_push_host: https://rubygems.org
88
+ homepage_uri: https://github.com/ys7i/yfinance_wrapper
89
+ source_code_uri: https://github.com/ys7i/yfinance_wrapper
90
+ changelog_uri: https://github.com/ys7i/yfinance_wrapper/blob/main/CHANGELOG.md
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 3.0.0
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.5.16
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A Ruby wrapper for Yahoo Finance API
110
+ test_files: []