finviz_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 066eeb06e6776516c903b05798b6ce55ba6518d8
4
- data.tar.gz: b1c0800b0a5be8a9231be57a867e0161d70362cd
3
+ metadata.gz: 223d8fc0a307e9f2cb6ddbbb120c564157e5ec2e
4
+ data.tar.gz: 340e379415036d294cd00f594cfe0eaf27c3eeb0
5
5
  SHA512:
6
- metadata.gz: f465dc6fc3000e81c8799a04df7a79437841407fc3645916df8886c0ea1910ef6c0777853bb4f01065ca812d15bf912b9520faf29c728d8fcbde5ba8a9452b3d
7
- data.tar.gz: 16efb469e94658782d85f3662173a14894b6782daf82be48e8e7e6eb2cbbf8eec1f6c4dfe8cca375eb6934d328c804ec638758b3a766d7a25f491307ca8f1e8f
6
+ metadata.gz: 4bcddd10139710b6dce243d7705b6f90fa5ebca0d6ecc2217343f462e547123d5a8bc1dcf0993a6ca75df2b68e71d8904c64f2fe881b2f4c7f13d4d5c5f0f780
7
+ data.tar.gz: 3d7631c883f5cd238558d508d2d8e863263ae61bb49d685efaeb585d4890b78828b3e6d7575b82a86076335b97928d8db745ab9b1bec4089caa73d2f7a0b1a19
@@ -4,6 +4,7 @@ require "finviz_rails/screener"
4
4
  require "finviz_rails/url_formatter"
5
5
  require "finviz_rails/filter_mapper"
6
6
  require "finviz_rails/indices"
7
+ require "finviz_rails/series"
7
8
 
8
9
  module FinvizRails
9
10
  end
@@ -24,6 +24,10 @@ class Finviz
24
24
  UrlFormatter.new(nil, nil, params, nil).run
25
25
  end
26
26
 
27
+ def series(symbol, params)
28
+ Series.new(symbol, params, agent).run
29
+ end
30
+
27
31
  private
28
32
 
29
33
 
@@ -0,0 +1,61 @@
1
+ class Series
2
+ def initialize(symbol, params, agent)
3
+ @symbol = symbol
4
+ @params = params
5
+ @agent = agent
6
+ end
7
+
8
+ INTERVAL_OPTIONS = ["m", "w", "d", "i1", "i3", "i5", "i15"]
9
+
10
+ def run
11
+ @agent.get(url)
12
+ result
13
+ end
14
+
15
+ private
16
+
17
+ def result
18
+ [
19
+ json["date"],
20
+ json["volume"],
21
+ json["open"],
22
+ json["high"],
23
+ json["low"],
24
+ json["close"]
25
+ ].transpose.map do |date, volume, open, close, high, low|
26
+ {
27
+ date: date,
28
+ volume: volume,
29
+ open: open,
30
+ high: high,
31
+ low: low,
32
+ close: close
33
+ }
34
+ end
35
+ end
36
+
37
+ def json
38
+ @json ||= JSON.parse(json_string)
39
+ end
40
+
41
+ def json_string
42
+ html.match(/var data = ({.*?})/)[1]
43
+ end
44
+
45
+ def html
46
+ @html ||= @agent.page.content
47
+ end
48
+
49
+ def interval
50
+ if @params["interval"]
51
+ throw "incorrect interval type" unless INTERVAL_OPTIONS.include?(@params["interval"])
52
+ @params["interval"]
53
+ else
54
+ "d"
55
+ end
56
+ end
57
+
58
+ def url
59
+ "http://elite.finviz.com/quote.ashx?t=TNET&ty=c&ta=2&p=#{interval}&b=1"
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module FinvizRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -545,5 +545,78 @@ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
545
545
   (0.1ms) begin transaction
546
546
  --------------------------------------------------------------
547
547
  FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
548
+ --------------------------------------------------------------
549
+  (0.1ms) rollback transaction
550
+  (0.1ms) begin transaction
551
+ --------------------------------------------------------------
552
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
553
+ --------------------------------------------------------------
554
+  (0.1ms) rollback transaction
555
+  (0.1ms) begin transaction
556
+ --------------------------------------------------------------
557
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
558
+ --------------------------------------------------------------
559
+  (0.1ms) rollback transaction
560
+  (0.1ms) begin transaction
561
+ --------------------------------------------------------------
562
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
563
+ --------------------------------------------------------------
564
+  (0.1ms) rollback transaction
565
+  (0.1ms) begin transaction
566
+ --------------------------------------------------------------
567
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
568
+ --------------------------------------------------------------
569
+  (0.1ms) rollback transaction
570
+  (0.1ms) begin transaction
571
+ --------------------------------------------------------------
572
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
573
+ --------------------------------------------------------------
574
+  (0.1ms) rollback transaction
575
+  (0.1ms) begin transaction
576
+ --------------------------------------------------------------
577
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
578
+ --------------------------------------------------------------
579
+  (0.1ms) rollback transaction
580
+  (0.1ms) begin transaction
581
+ --------------------------------------------------------------
582
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
583
+ --------------------------------------------------------------
584
+  (0.1ms) rollback transaction
585
+  (0.1ms) begin transaction
586
+ --------------------------------------------------------------
587
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
588
+ --------------------------------------------------------------
589
+  (2.1ms) begin transaction
590
+ --------------------------------------------------------------
591
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
592
+ --------------------------------------------------------------
593
+  (0.1ms) begin transaction
594
+ --------------------------------------------------------------
595
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
596
+ --------------------------------------------------------------
597
+  (0.1ms) rollback transaction
598
+  (0.1ms) begin transaction
599
+ --------------------------------------------------------------
600
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
601
+ --------------------------------------------------------------
602
+  (0.1ms) rollback transaction
603
+  (0.1ms) begin transaction
604
+ --------------------------------------------------------------
605
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
606
+ --------------------------------------------------------------
607
+  (0.1ms) rollback transaction
608
+  (0.1ms) begin transaction
609
+ --------------------------------------------------------------
610
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
611
+ --------------------------------------------------------------
612
+  (0.1ms) rollback transaction
613
+  (0.1ms) begin transaction
614
+ --------------------------------------------------------------
615
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
616
+ --------------------------------------------------------------
617
+  (0.2ms) rollback transaction
618
+  (0.1ms) begin transaction
619
+ --------------------------------------------------------------
620
+ FinvizRailsTest: test_non-auth_screener_get_first_page_of_data
548
621
  --------------------------------------------------------------
549
622
   (0.1ms) rollback transaction
@@ -4,12 +4,6 @@ require "pp"
4
4
  class FinvizRailsTest < ActiveSupport::TestCase
5
5
  test "non-auth screener get first page of data" do
6
6
  finviz = Finviz.new
7
- pp finviz.screener(
8
- price_range: "2to3",
9
- analyst_recommendation: "strongbuy",
10
- average_volume: "o50",
11
- pattern: "wedgedown",
12
- is_active: true
13
- )
7
+ pp finviz.series("TNET", {"interval" => "i1"})
14
8
  end
15
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finviz_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nemrow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -82,6 +82,7 @@ files:
82
82
  - lib/finviz_rails/indices.rb
83
83
  - lib/finviz_rails/login.rb
84
84
  - lib/finviz_rails/screener.rb
85
+ - lib/finviz_rails/series.rb
85
86
  - lib/finviz_rails/url_formatter.rb
86
87
  - lib/finviz_rails/version.rb
87
88
  - lib/tasks/finviz_rails_tasks.rake