alphavantagerb 1.3.0 → 1.3.1

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: 743749f1cf99b12c71e4c5550074305f1c7b04a5
4
- data.tar.gz: 5640ecf935bc22da9f2dc6577e138e1f3846a43c
3
+ metadata.gz: 07f4cfa1ff82b3ce771c5c2c0147e603b44fdc8c
4
+ data.tar.gz: 314b436e632aec4e3855ca5a37c8ed9cbf4eba26
5
5
  SHA512:
6
- metadata.gz: f46bf5a084371e19873eb21cc8ece703da94469fa079b933db4cc79f6d8b194adf0d280bb75c29f196ab7ce92c111a88b887af2156aa58faefce6e4906735bc0
7
- data.tar.gz: 7bd15d518d533a731935bfaeca3b30a986e087a35be39562b97e7cf0d0f357b4ff84a3fd29e0133c5f5e422095b9577fcec7be2ab9d8442b5d3b79637aa0540d
6
+ metadata.gz: add330bcd18fb80ab7a16545356d38e736c9ec89bf18ec308f32f7c141851c3463869744fc37882bccc1ce46c85528cc306040cc01bc372b662023b83cb95419
7
+ data.tar.gz: fc1f7262bbefa9c4b1e0ecb09cefc37eaf8cf8b4f2803868038b84895cf9b86d31792410d53539c2b89a23a2a7252649d996b1c4a5c06d3ab7cad66cebbc1ab0
@@ -4,7 +4,7 @@ require "rake"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "alphavantagerb"
7
- s.version = "1.3.0"
7
+ s.version = "1.3.1"
8
8
  s.authors = ["Stefano Martin"]
9
9
  s.email = ["stefano.martin87@gmail.com"]
10
10
  s.homepage = "https://github.com/StefanoMartin/AlphaVantageRB"
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  AlphavantageRB [![Gem Version](https://badge.fury.io/rb/alphavantagerb.svg)](https://badge.fury.io/rb/alphavantagerb)
2
2
  =========================================================
3
3
 
4
+ Last update: 11/10/2018
5
+
4
6
  [Alpha Vantage](https://www.alphavantage.co/) is a great API for retrieving Stock
5
7
  market data in JSON or CSV format.
6
8
  AlphavantageRB is a Gem to use Alpha Vantage with Ruby. AlphavantageRB is based
@@ -13,6 +15,7 @@ To use it in your application: `require "alphavantagerb"`
13
15
  ## How to test
14
16
 
15
17
  To test the Gem create a config.yml file inside the folder /spec with inside a line
18
+
16
19
  ``` ruby
17
20
  key: [YOUR KEY]
18
21
  ```
@@ -44,6 +47,7 @@ Alphavantage::Client is used to create a client that will be used from the Alpha
44
47
  To contact Alpha Vantage you need to use a valid key that you can require from [here](https://www.alphavantage.co/support/#api-key).
45
48
 
46
49
  To setup your credentials use:
50
+
47
51
  ``` ruby
48
52
  client = Alphavantage::Client.new key: "YOURKEY"
49
53
  ```
@@ -56,12 +60,14 @@ setup verbose equal to true.
56
60
  ```
57
61
 
58
62
  You can use the method search to find some stocks by name.
63
+
59
64
  ``` ruby
60
65
  stocks_found = client.search keywords: "MSFT"
61
66
  stocks_found.output # Return the hash retrieved
62
67
  ```
63
68
 
64
69
  This will return an array where each elements has the following structure:
70
+
65
71
  ``` ruby
66
72
  stocks_found.stocks[0].symbol
67
73
  stocks_found.stocks[0].name
@@ -94,6 +100,7 @@ stock = Alphavantage::Stock.new symbol: "MSFT", key: "YOURKEY"
94
100
  ```
95
101
 
96
102
  Note that the initialization owns different entry:
103
+
97
104
  * symbol: it is a string that denote the stock you want to retrieve.
98
105
  * key: authentication key. This value cannot be setup if you are initializing a Stock class from a client
99
106
  * verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
@@ -105,6 +112,28 @@ You can setup the datatype of future retrieving by doing:
105
112
  stock.datatype = "csv"
106
113
  ```
107
114
 
115
+ You can retrieve an Openstruct document of the actual status of the stock by using:
116
+
117
+ ``` ruby
118
+ stock_quote = stock.quote
119
+ ```
120
+
121
+ This include different method with several information:
122
+
123
+ ``` ruby
124
+ stock_quote.output # Output of the request
125
+ stock_quote.symbol
126
+ stock_quote.open
127
+ stock_quote.high
128
+ stock_quote.low
129
+ stock_quote.price
130
+ stock_quote.volume
131
+ stock_quote.latest_trading_day
132
+ stock_quote.previous_close
133
+ stock_quote.change
134
+ stock_quote.change_percent
135
+ ```
136
+
108
137
  <a name="Timeseries"></a>
109
138
  ## Alphavantage::Timeseries
110
139
 
@@ -118,6 +147,7 @@ timeseries = Alphavantage::Timeseries.new symbol: "MSFT", key: "YOURKEY"
118
147
  ```
119
148
 
120
149
  Note that the initialization owns different entries:
150
+
121
151
  * symbol: it is a string that denote the stock you want to retrieve. This value cannot be setup if you are initializing a timeseries from a stock
122
152
  * key: authentication key. This value cannot be setup if you are initializing a timeseries from a stock
123
153
  * verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
@@ -130,6 +160,7 @@ Note that the initialization owns different entries:
130
160
  * file: path where a csv file should be saved (default "nil")
131
161
 
132
162
  You can retrieve all the output from Alpha Vantage by doing.
163
+
133
164
  ``` ruby
134
165
  timeseries.output
135
166
  ```
@@ -180,6 +211,7 @@ indicator = Alphavantage::Indicator.new function: "SMA", symbol: "MSFT", key: "Y
180
211
 
181
212
  Note that the initialization owns different entries (for deeper explanation on the parameters, please consult the Alpha Vantage documentation).
182
213
  Some of these parameters are necessary for each functions.
214
+
183
215
  * symbol: it is a string that denote the stock you want to retrieve. This value cannot be setup if you are initializing a timeseries from a stock
184
216
  * key: authentication key. This value cannot be setup if you are initializing a timeseries from a stock
185
217
  * verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
@@ -196,6 +228,7 @@ positive integer parameters, positive float parameters and MA parameters.
196
228
  The MA parameters accept as an entry one of these attributes: "0", "1", "2", "3", "4", "5", "6", "7", "8", "SMA", "EMA", "WMA", "DEMA", "TEMA", "TRIMA", "T3", "KAMA", or "MAMA".
197
229
 
198
230
  Each indicator has several methods that can use in relation of the type. Some are used for each indicator.
231
+
199
232
  ``` ruby
200
233
  indicator = stock.indicator(function: "SMA", interval: "weekly", time_period: "60", series_type: "close")
201
234
  indicator.output # Retrieve the output from Alpha vantage
@@ -207,55 +240,65 @@ indicator.time_zone
207
240
  ```
208
241
 
209
242
  Some other are more specific in relation of the type of indicator used.
243
+
210
244
  ``` ruby
211
245
  indicator.time_period # time_period is only supported by "SMA", "EMA", "WMA", "DEMA", "TEMA", "TRIMA", "KAMA", "T3", "RSI", "STOCHRSI", "WILLR", "ADX", "ADXR", "MOM", "CCI", "CMO", "ROC", "ROCR", "AROON", "AROONOSC", "MFI", "TRIX", "DX", "MINUS_DI", "PLUS_DI", "MINUS_DM", "PLUS_DM", "BBANDS", "MIDPOINT", "MIDPRICE", "ATR","NATR"
212
246
  indicator.series_type # series_type is only supported by "SMA", "EMA", "WMA", "DEMA", "TEMA", "TRIMA", "KAMA", "T3", "RSI", "MAMA", "MACD", "MACDEXT", "STOCHRSI", "APO", "PPO", "MOM", "ROC","ROCR", "TRIX", "BBANDS", "MIDPOINT", "HT_SINE", "HT_TRENDLINE", "HT_TRENDMODE", "HT_DCPERIOD", "HT_DCPHASE", "HT_PHASOR", "CMO"
213
247
  ```
248
+
214
249
  Then there are really specific indicator, for only some functions.
215
250
 
216
251
  ### SMA
252
+
217
253
  ``` ruby
218
254
  indicator = stock.indicator(function: "SMA", interval: "weekly", time_period: "60", series_type: "close")
219
255
  indicator.sma
220
256
  ```
221
257
 
222
258
  ### EMA
259
+
223
260
  ``` ruby
224
261
  indicator = stock.indicator(function: "EMA", interval: "weekly", time_period: "60", series_type: "close")
225
262
  indicator.ema
226
263
  ```
227
264
 
228
265
  ### WMA
266
+
229
267
  ``` ruby
230
268
  indicator = stock.indicator(function: "WMA", interval: "weekly", time_period: "60", series_type: "close")
231
269
  indicator.wma
232
270
  ```
233
271
 
234
272
  ### DEMA
273
+
235
274
  ``` ruby
236
275
  indicator = stock.indicator(function: "DEMA", interval: "weekly", time_period: "60", series_type: "close")
237
276
  indicator.dema
238
277
  ```
239
278
 
240
279
  ### TEMA
280
+
241
281
  ``` ruby
242
282
  indicator = stock.indicator(function: "TEMA", interval: "weekly", time_period: "60", series_type: "close")
243
283
  indicator.tema
244
284
  ```
245
285
 
246
286
  ### TRIMA
287
+
247
288
  ``` ruby
248
289
  indicator = stock.indicator(function: "TRIMA", interval: "weekly", time_period: "60", series_type: "close")
249
290
  indicator.trima
250
291
  ```
251
292
 
252
293
  ### KAMA
294
+
253
295
  ``` ruby
254
296
  indicator = stock.indicator(function: "KAMA", interval: "weekly", time_period: "60", series_type: "close")
255
297
  indicator.kama
256
298
  ```
257
299
 
258
300
  ### MAMA
301
+
259
302
  * fastlimit: it can be a positive float (default "0.01")
260
303
  * slowlimit: it can be a positive float (default "0.01")
261
304
 
@@ -268,12 +311,14 @@ indicator.mama
268
311
  ```
269
312
 
270
313
  ### T3
314
+
271
315
  ``` ruby
272
316
  indicator = stock.indicator(function: "T3", interval: "weekly", time_period: "60", series_type: "close")
273
317
  indicator.t3
274
318
  ```
275
319
 
276
320
  ### MACD
321
+
277
322
  * fastperiod: it can be a positive integer (default "12")
278
323
  * slowperiod: it can be a positive integer (default "26")
279
324
  * signalperiod: it can be a positive integer (default "9")
@@ -289,6 +334,7 @@ indicator.macd
289
334
  ```
290
335
 
291
336
  ### MACDEXT
337
+
292
338
  * fastperiod: it can be a positive integer (default "12")
293
339
  * slowperiod: it can be a positive integer (default "26")
294
340
  * signalperiod: it can be a positive integer (default "9")
@@ -310,6 +356,7 @@ indicator.macd
310
356
  ```
311
357
 
312
358
  ### STOCH
359
+
313
360
  * fastkperiod: it can be a positive integer (default "5")
314
361
  * slowkperiod: it can be a positive integer (default "3")
315
362
  * slowdperiod: it can be a positive integer (default "3")
@@ -328,6 +375,7 @@ indicator.slowd
328
375
  ```
329
376
 
330
377
  ### STOCHF
378
+
331
379
  * fastkperiod: it can be a positive integer (default "5")
332
380
  * fastdperiod: it can be a positive integer (default "3")
333
381
  * fastdmatype: it is a MA parameter (default "0")
@@ -342,12 +390,14 @@ indicator.fastd
342
390
  ```
343
391
 
344
392
  ### RSI
393
+
345
394
  ``` ruby
346
395
  indicator = stock.indicator(function: "RSI", interval: "weekly", time_period: "60", series_type: "close")
347
396
  indicator.rsi
348
397
  ```
349
398
 
350
399
  ### STOCHRSI
400
+
351
401
  * fastkperiod: it can be a positive integer (default "5")
352
402
  * fastdperiod: it can be a positive integer (default "3")
353
403
  * fastdmatype: it is a MA parameter (default "0")
@@ -362,24 +412,28 @@ indicator.fastd
362
412
  ```
363
413
 
364
414
  ### WILLR
415
+
365
416
  ``` ruby
366
417
  indicator = stock.indicator(function: "WILLR", interval: "weekly", time_period: "60")
367
418
  indicator.willr
368
419
  ```
369
420
 
370
421
  ### ADX
422
+
371
423
  ``` ruby
372
424
  indicator = stock.indicator(function: "ADX", interval: "weekly", time_period: "60")
373
425
  indicator.adx
374
426
  ```
375
427
 
376
428
  ### ADXR
429
+
377
430
  ``` ruby
378
431
  indicator = stock.indicator(function: "ADXR", interval: "weekly", time_period: "60")
379
432
  indicator.adxr
380
433
  ```
381
434
 
382
435
  ### APO
436
+
383
437
  * fastperiod: it can be a positive integer (default "12")
384
438
  * slowperiod: it can be a positive integer (default "26")
385
439
  * signalperiod: it can be a positive integer (default "9")
@@ -394,6 +448,7 @@ indicator.apo
394
448
  ```
395
449
 
396
450
  ### PPO
451
+
397
452
  * fastperiod: it can be a positive integer (default "12")
398
453
  * slowperiod: it can be a positive integer (default "26")
399
454
  * signalperiod: it can be a positive integer (default "9")
@@ -408,42 +463,49 @@ indicator.ppo
408
463
  ```
409
464
 
410
465
  ### MOM
466
+
411
467
  ``` ruby
412
468
  indicator = stock.indicator(function: "MOM", interval: "weekly", time_period: "60", series_type: "close")
413
469
  indicator.mom
414
470
  ```
415
471
 
416
472
  ### BOP
473
+
417
474
  ``` ruby
418
475
  indicator = stock.indicator(function: "MOM", interval: "weekly", time_period: "60", series_type: "close")
419
476
  indicator.bop
420
477
  ```
421
478
 
422
479
  ### CCI
480
+
423
481
  ``` ruby
424
482
  indicator = stock.indicator(function: "CCI", interval: "weekly", time_period: "60")
425
483
  indicator.cci
426
484
  ```
427
485
 
428
486
  ### CMO
487
+
429
488
  ``` ruby
430
489
  indicator = stock.indicator(function: "CMO", interval: "weekly", time_period: "60")
431
490
  indicator.cmo
432
491
  ```
433
492
 
434
493
  ### ROC
494
+
435
495
  ``` ruby
436
496
  indicator = stock.indicator(function: "ROC", interval: "weekly", time_period: "60", series_type: "close")
437
497
  indicator.roc
438
498
  ```
439
499
 
440
500
  ### ROCR
501
+
441
502
  ``` ruby
442
503
  indicator = stock.indicator(function: "ROCR", interval: "weekly", time_period: "60", series_type: "close")
443
504
  indicator.rocr
444
505
  ```
445
506
 
446
507
  ### AROON
508
+
447
509
  ``` ruby
448
510
  indicator = stock.indicator(function: "AROON", interval: "weekly", time_period: "60")
449
511
  indicator.aroon_down
@@ -451,24 +513,28 @@ indicator.aroon_up
451
513
  ```
452
514
 
453
515
  ### AROONOSC
516
+
454
517
  ``` ruby
455
518
  indicator = stock.indicator(function: "AROONOSC", interval: "weekly", time_period: "60")
456
519
  indicator.aroonosc
457
520
  ```
458
521
 
459
522
  ### MFI
523
+
460
524
  ``` ruby
461
525
  indicator = stock.indicator(function: "MFI", interval: "weekly", time_period: "60")
462
526
  indicator.mfi
463
527
  ```
464
528
 
465
529
  ### TRIX
530
+
466
531
  ``` ruby
467
532
  indicator = stock.indicator(function: "TRIX", interval: "weekly", time_period: "60", series_type: "close")
468
533
  indicator.trix
469
534
  ```
470
535
 
471
536
  ### ULTOSC
537
+
472
538
  * timeperiod1: it can be a positive integer (default "7")
473
539
  * timeperiod2: it can be a positive integer (default "14")
474
540
  * timeperiod3: it can be a positive integer (default "28")
@@ -482,36 +548,42 @@ indicator.ultosc
482
548
  ```
483
549
 
484
550
  ### DX
551
+
485
552
  ``` ruby
486
553
  indicator = stock.indicator(function: "DX", interval: "weekly", time_period: "60")
487
554
  indicator.dx
488
555
  ```
489
556
 
490
557
  ### MINUS_DI
558
+
491
559
  ``` ruby
492
560
  indicator = stock.indicator(function: "MINUS_DI", interval: "weekly", time_period: "60")
493
561
  indicator.minus_di
494
562
  ```
495
563
 
496
564
  ### PLUS_DI
565
+
497
566
  ``` ruby
498
567
  indicator = stock.indicator(function: "PLUS_DI", interval: "weekly", time_period: "60")
499
568
  indicator.plus_di
500
569
  ```
501
570
 
502
571
  ### MINUS_DM
572
+
503
573
  ``` ruby
504
574
  indicator = stock.indicator(function: "PLUS_DI", interval: "weekly", time_period: "60")
505
575
  indicator.minus_dm
506
576
  ```
507
577
 
508
578
  ### PLUS_DM
579
+
509
580
  ``` ruby
510
581
  indicator = stock.indicator(function: "PLUS_DM", interval: "weekly", time_period: "60", series_type: "close")
511
582
  indicator.plus_dm
512
583
  ```
513
584
 
514
585
  ### BBANDS
586
+
515
587
  * matype: it is a MA parameter (default "0")
516
588
  * nbdevup: it can be a positive integer (default "2")
517
589
  * nbdevdn: it can be a positive integer (default "2")
@@ -527,18 +599,21 @@ indicator.real_upper_band
527
599
  ```
528
600
 
529
601
  ### MIDPOINT
602
+
530
603
  ``` ruby
531
604
  indicator = stock.indicator(function: "MIDPOINT", interval: "weekly", time_period: "60", series_type: "close")
532
605
  indicator.midpoint
533
606
  ```
534
607
 
535
608
  ### MIDPRICE
609
+
536
610
  ``` ruby
537
611
  indicator = stock.indicator(function: "MIDPRICE", interval: "weekly", time_period: "60", series_type: "close")
538
612
  indicator.midprice
539
613
  ```
540
614
 
541
615
  ### SAR
616
+
542
617
  * acceleration: it can be a positive float (default "0.01")
543
618
  * maximum: it can be a positive float (default "0.20")
544
619
 
@@ -550,30 +625,35 @@ indicator.sar
550
625
  ```
551
626
 
552
627
  ### TRANGE
628
+
553
629
  ``` ruby
554
630
  indicator = stock.indicator(function: "TRANGE", interval: "weekly")
555
631
  indicator.trange
556
632
  ```
557
633
 
558
634
  ### ATR
635
+
559
636
  ``` ruby
560
637
  indicator = stock.indicator(function: "ATR", interval: "weekly", time_period: "60")
561
638
  indicator.atr
562
639
  ```
563
640
 
564
641
  ### NATR
642
+
565
643
  ``` ruby
566
644
  indicator = stock.indicator(function: "NATR", interval: "weekly", time_period: "60")
567
645
  indicator.natr
568
646
  ```
569
647
 
570
648
  ### AD
649
+
571
650
  ``` ruby
572
651
  indicator = stock.indicator(function: "AD", interval: "weekly")
573
652
  indicator.chaikin_ad
574
653
  ```
575
654
 
576
655
  ### ADOSC
656
+
577
657
  * fastperiod: it can be a positive integer (default "12")
578
658
  * slowperiod: it can be a positive integer (default "26")
579
659
 
@@ -585,18 +665,21 @@ indicator.adosc
585
665
  ```
586
666
 
587
667
  ### OBV
668
+
588
669
  ``` ruby
589
670
  indicator = stock.indicator(function: "OBV", interval: "weekly")
590
671
  indicator.obv
591
672
  ```
592
673
 
593
674
  ### HT_TRENDLINE
675
+
594
676
  ``` ruby
595
677
  indicator = stock.indicator(function: "HT_TRENDLINE", interval: "weekly", time_period: "60", series_type: "close")
596
678
  indicator.ht_trendline
597
679
  ```
598
680
 
599
681
  ### HT_SINE
682
+
600
683
  ``` ruby
601
684
  indicator = stock.indicator(function: "HT_SINE", interval: "weekly", series_type: "close")
602
685
  indicator.sine
@@ -604,29 +687,34 @@ indicator.lead_sine
604
687
  ```
605
688
 
606
689
  ### HT_TRENDMODE
690
+
607
691
  ``` ruby
608
692
  indicator = stock.indicator(function: "HT_TRENDMODE", interval: "weekly", series_type: "close")
609
693
  indicator.trendmode
610
694
  ```
611
695
 
612
696
  ### HT_DCPERIOD
697
+
613
698
  ``` ruby
614
699
  indicator = stock.indicator(function: "HT_DCPERIOD", interval: "weekly", series_type: "close")
615
700
  indicator.dcperiod
616
701
  ```
617
702
 
618
703
  ### HT_DCPHASE
704
+
619
705
  ``` ruby
620
706
  indicator = stock.indicator(function: "EMA", interval: "weekly", series_type: "close")
621
707
  indicator.ht_dcphase
622
708
  ```
623
709
 
624
710
  ### HT_PHASOR
711
+
625
712
  ``` ruby
626
713
  indicator = stock.indicator(function: "HT_PHASOR", interval: "weekly", series_type: "close")
627
714
  indicator.quadrature
628
715
  indicator.phase
629
716
  ```
717
+
630
718
  <a name="Crypto"></a>
631
719
  ## Alphavantage::Crypto
632
720
 
@@ -642,6 +730,7 @@ crypto = Alphavantage::Crypto.new symbol: "BTC", market: "DKK", key: "YOURKEY"
642
730
  ```
643
731
 
644
732
  Note that the initialization owns different entry:
733
+
645
734
  * symbol: it is a string that denote the cryptocurrency you want to retrieve.
646
735
  * market: denote the market where you want to analyze the cryptocurrency
647
736
  * key: authentication key. This value cannot be setup if you are initializing a Stock class from a client
@@ -667,8 +756,9 @@ crypto_timeseries = Alphavantage::Crypto_Timeseries.new type: "daily", symbol: "
667
756
  ```
668
757
 
669
758
  Note that the initialization owns different entries:
759
+
670
760
  * symbol: it is a string that denote the stock you want to retrieve. This value cannot be setup if you are initializing a timeseries from a crypto class from a crypto class
671
- * market: it is a string that denote the market you want to analyze. This value cannot be setup if you are initializing a timeseries from a stock
761
+ * market: it is a string that denote the market you want to analyse. This value cannot be setup if you are initializing a timeseries from a stock
672
762
  * key: authentication key. This value cannot be setup if you are initializing a timeseries from a crypto class
673
763
  * verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
674
764
  * type: it can be "intraday", "daily", "weekly", "monthly" (default "daily")
@@ -676,6 +766,7 @@ Note that the initialization owns different entries:
676
766
  * file: path where a csv file should be saved (default "nil")
677
767
 
678
768
  You can retrieve all the output from Alpha Vantage by doing.
769
+
679
770
  ``` ruby
680
771
  crypto_timeseries.output
681
772
  ```
@@ -716,6 +807,7 @@ You can order the data in ascending or descending order.
716
807
  crypto_timeseries.open("desc") # Default
717
808
  crypto_timeseries.open("asc")
718
809
  ```
810
+
719
811
  <a name="Exchange"></a>
720
812
  ## Alphavantage::Exchange
721
813
 
@@ -730,6 +822,7 @@ exchange = Alphavantage::Exchange.new from: "USD", to: "DKK", key: "YOURKEY"
730
822
  ```
731
823
 
732
824
  Note that the initialization owns different entry:
825
+
733
826
  * from: input currency you want to check the value
734
827
  * to: output currency you want to see the value
735
828
  * symbol: it is a string that denote the stock you want to retrieve.
@@ -738,6 +831,7 @@ Note that the initialization owns different entry:
738
831
  * datatype: it can be "json" or "csv" (default "json")
739
832
 
740
833
  You can retrieve the actual situation of the exchange from Alpha Vantage by doing.
834
+
741
835
  ``` ruby
742
836
  ex_now = exchange.now
743
837
  ```
@@ -770,6 +864,7 @@ exchange_timeseries = Alphavantage::Exchange_Timeseries.new from: "USD", to: "DK
770
864
  ```
771
865
 
772
866
  Note that the initialization owns different entries:
867
+
773
868
  * symbol: it is a string that denote the stock you want to retrieve. This value cannot be setup if you are initializing a timeseries from a stock
774
869
  * key: authentication key. This value cannot be setup if you are initializing a timeseries from a stock
775
870
  * verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
@@ -782,6 +877,7 @@ Note that the initialization owns different entries:
782
877
  * file: path where a csv file should be saved (default "nil")
783
878
 
784
879
  You can retrieve all the output from Alpha Vantage by doing.
880
+
785
881
  ``` ruby
786
882
  exchange_timeseries.output
787
883
  ```
@@ -828,14 +924,17 @@ sector = Alphavantage::Sector.new key: "YOURKEY"
828
924
  ```
829
925
 
830
926
  Note that the initialization owns different entries:
927
+
831
928
  * key: authentication key. This value cannot be setup if you are initializing a timeseries from a crypto class
832
929
 
833
930
  You can retrieve all the output from Alpha Vantage by doing.
931
+
834
932
  ``` ruby
835
933
  sector.output
836
934
  ```
837
935
 
838
936
  Specific information about the timeseries can be retrieved using the following methods:
937
+
839
938
  ``` ruby
840
939
  sector.information
841
940
  sector.last_refreshed
@@ -856,6 +955,7 @@ Specific information about the timeseries can be retrieved using the following m
856
955
 
857
956
  Errors are handled by this class.
858
957
  You receive errors in the following cases:
958
+
859
959
  * "Failed request": a request to Alpha Vantage fails
860
960
  * "Parsing failed": the parsing of the JSON from Alpha Vantage fails
861
961
  * A generic message from Alpha Vantage (for example by using a wrong key, a wrong query or too many requests at once). This message is equal as the one returned from Alpha Vantage API
@@ -869,6 +969,7 @@ You receive errors in the following cases:
869
969
  * "Key should be a string": you are trying to use a wrong key
870
970
 
871
971
  You can retrieve more information from your error by using:
972
+
872
973
  ``` ruby
873
974
  e.message
874
975
  e.data # Data retrieved from Alpha vantage or further information to correct the error
@@ -27,6 +27,24 @@ describe Alphavantage::Stock do
27
27
  expect(bool).to eq ["json", "error", "csv"]
28
28
  end
29
29
 
30
+ it "can retrieve quote" do
31
+ stock = @client.stock symbol: "MSFT"
32
+ stock_quote = stock.quote
33
+ res = []
34
+ res << stock_quote.output.is_a?(Hash)
35
+ res << stock_quote.symbol.is_a?(String)
36
+ res << stock_quote.open.is_a?(String)
37
+ res << stock_quote.high.is_a?(String)
38
+ res << stock_quote.low.is_a?(String)
39
+ res << stock_quote.price.is_a?(String)
40
+ res << stock_quote.volume.is_a?(String)
41
+ res << stock_quote.latest_trading_day.is_a?(String)
42
+ res << stock_quote.previous_close.is_a?(String)
43
+ res << stock_quote.change.is_a?(String)
44
+ res << stock_quote.change_percent.is_a?(String)
45
+ expect(res.all?{|e| e}).to eq true
46
+ end
47
+
30
48
  it "can create a new timeseries from stock" do
31
49
  stock = @client.stock symbol: "MSFT"
32
50
  timeseries = stock.timeseries
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphavantagerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty