yquotes 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7878ccd08e7306c95955a80b8d53f2f341b5e0dd
4
- data.tar.gz: 1b3eb58db34d9b795cff93067634e607b763f0bb
3
+ metadata.gz: a8838912fb8a6fbb4b2bb4763747ff10ed0b3064
4
+ data.tar.gz: 74a817327c6e1a4ef4da6eaf569448dbf31ff263
5
5
  SHA512:
6
- metadata.gz: d2177755c12cdefd1d483db8a38e57b5c43148faeb38c895a2db745dab3e3dbbaf8cbe413882b3662bc7969ac178a1040863e602113f6a0c59753abffa489aef
7
- data.tar.gz: f4f2beb0bb2c75b76028a26365dc499b8f2f27abd7bf3c7ba1acb9824a438d6da377c1cfbdb35304b87b205c67a243123c4cf82fed2040d8b0d12a4dd27fb923
6
+ metadata.gz: b955472d0f609237043ac7d3a9c70b76f1d2270c12686ec36151b2f1f114b12d5b14c4f52dcffdaf1e6fa0ff88cac665f3bee3aab0caefe45d1fca674219709f
7
+ data.tar.gz: c7f2a6f267546409eceae72332fd898e3365356a0c82621be4e5677f65962221c8a25042ce8dcdf10dbfee1cdee40a14d585a00a77617eab84f9ad0d5ef5e726
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # YQuotes
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/yquotes.svg)](https://badge.fury.io/rb/yquotes)
4
+ [![Build Status](https://travis-ci.org/cpankaj/yquotes.svg?branch=master)](https://travis-ci.org/cpankaj/yquotes)
5
+
3
6
  Get historical quotes from Yahoo Finance.
4
7
 
5
8
 
@@ -23,7 +26,19 @@ Or install it yourself as:
23
26
 
24
27
  client = YQuotes::Client.new
25
28
 
26
- df = client.get_quote(ticker, start_date, end_date)
29
+ df = client.get_quote(ticker, {
30
+ period: 'm',
31
+ start_date: '2017-01-02',
32
+ end_date: '2017-03-31'
33
+ })
34
+
35
+ OR
36
+
37
+ df = client.get_quote(ticker, {
38
+ p: 'm',
39
+ s: '2017-01-02',
40
+ e: '2017-03-31'
41
+ })
27
42
 
28
43
  ## Development
29
44
 
@@ -1,3 +1,3 @@
1
1
  module YQuotes
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/yquotes/yahoo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'open-uri'
2
2
  require 'csv'
3
- require 'Date'
3
+ require 'date'
4
4
 
5
5
 
6
6
  module YQuotes
data/lib/yquotes.rb CHANGED
@@ -13,7 +13,19 @@ module YQuotes
13
13
  end
14
14
 
15
15
  # get_quote: returns Daru::DataFrame of the quote with volume and close
16
- def get_quote(ticker, start_date=nil, end_date=nil, period='d')
16
+ def get_quote(ticker, args = {})
17
+
18
+ if args.is_a? Hash
19
+ start_date = args[:start_date] if args[:start_date]
20
+ start_date ||= args[:s] if args[:s]
21
+
22
+ end_date = args[:end_date] if args[:end_date]
23
+ end_date ||= args[:e] if args[:e]
24
+
25
+ period = args[:period] if args[:period]
26
+ period ||= args[:p] if args[:p]
27
+ end
28
+
17
29
  csv = @yahoo_client.get_csv(ticker, start_date, end_date, period)
18
30
  create_from_csv(csv)
19
31
  end
@@ -38,14 +50,15 @@ module YQuotes
38
50
  df = Daru::DataFrame.from_csv(file_path, :converters => :numeric)
39
51
  File.delete(file_path) if File.exists?(file_path)
40
52
 
53
+ #sort from earlier to latest
54
+ df = df.sort ['Date']
55
+
41
56
  # strip columns and create index
42
57
  df.index = Daru::Index.new(df['Date'].to_a)
43
58
  df = df['Volume', 'Adj Close']
44
59
  df.rename_vectors 'Volume' => :volume, 'Adj Close' => :close
45
60
 
46
61
  d = df.filter(:row) { |row| row[:volume] > 0}
47
-
48
- return d
49
62
  end
50
63
 
51
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yquotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - P Choudhary
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-06 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler