paribu_price 0.2.0 → 0.3.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 +4 -4
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/lib/paribu_price.rb +13 -1
- data/lib/paribu_price/functions.rb +7 -0
- data/lib/paribu_price/orderbook.rb +31 -0
- data/lib/paribu_price/ticker.rb +62 -0
- data/lib/paribu_price/version.rb +1 -1
- data/paribu_price.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 634b0b13d3b56c53ccd7ad451e6b6b686103fc78
|
4
|
+
data.tar.gz: 54662a19d44e1fbeb75a8668aeb056427a45dc9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703771f1d80af18246661d91b1cddd99bf87ac92e1921fa1a772bdb8fffd03c7fd1c3d68c9a7a9e2164d1c499164b3185b77769d72eb80bb49279a620f8ffa62
|
7
|
+
data.tar.gz: ed0b5bd33fbc4af48a37a8cc09e42fc1767248b34ffdd0a1e587ae18fd84279fa5402e0f8fcbb49ea1f1ce5f16b13064b3428b86dac4c72d607464c62b21c817
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paribu_price`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
|
5
|
+
Delete this and the text above, and describe your gem
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Write usage instructions here
|
26
26
|
|
27
27
|
## Development
|
28
28
|
|
data/lib/paribu_price.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
require "paribu_price/version"
|
2
2
|
|
3
3
|
module ParibuPrice
|
4
|
-
|
4
|
+
API_URL = 'https://www.paribu.com/endpoint/state'
|
5
|
+
PRICE_UNIT = 'TRY'
|
6
|
+
|
7
|
+
def self.buy_price
|
8
|
+
Ticker.buy_price
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.sell_price
|
12
|
+
Ticker.sell_price
|
13
|
+
end
|
5
14
|
end
|
15
|
+
|
16
|
+
require 'paribu_price/ticker'
|
17
|
+
require 'paribu_price/orderbook'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ParibuPrice
|
2
|
+
class Orderbook
|
3
|
+
require 'paribu_price/functions'
|
4
|
+
require 'httparty'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
@response = nil
|
8
|
+
|
9
|
+
def self.asks
|
10
|
+
ParibuPrice::Functions.sort_by_price(orders['sell'])
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.bids
|
14
|
+
ParibuPrice::Functions.sort_by_price(orders['buy'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.refresh
|
18
|
+
@response = nil
|
19
|
+
response
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.response
|
24
|
+
@response ||= JSON.parse(HTTParty.get(API_URL).body)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.orders
|
28
|
+
response['publicState']['orders']['active']['btc_tl']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module ParibuPrice
|
2
|
+
class Ticker
|
3
|
+
require 'paribu_price/functions'
|
4
|
+
require 'httparty'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
@response = nil
|
8
|
+
@sell = nil
|
9
|
+
|
10
|
+
def self.buy_price
|
11
|
+
day_stats['lst']
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.sell_price
|
15
|
+
@sell ||= ParibuPrice::Functions.sort_by_price(sell_orders).first['p']
|
16
|
+
@sell.to_f
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.volume
|
20
|
+
day_stats['sum']
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.average_price
|
24
|
+
day_stats['avg']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.weighted_average_price
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.highest
|
32
|
+
day_stats['max']
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.lowest
|
36
|
+
day_stats['min']
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.refresh
|
40
|
+
@response = nil
|
41
|
+
@sell = nil
|
42
|
+
response
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.response
|
47
|
+
@response ||= JSON.parse(HTTParty.get(API_URL).body)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.day_stats
|
51
|
+
response['publicState']['market_sum']['day_stats']
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.orders
|
55
|
+
response['publicState']['orders']
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.sell_orders
|
59
|
+
orders['active']['btc_tl']['sell']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/paribu_price/version.rb
CHANGED
data/paribu_price.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paribu_price
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fatih AYTAÇ
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- fatih.aytac@gmail.com
|
@@ -67,6 +81,9 @@ files:
|
|
67
81
|
- bin/console
|
68
82
|
- bin/setup
|
69
83
|
- lib/paribu_price.rb
|
84
|
+
- lib/paribu_price/functions.rb
|
85
|
+
- lib/paribu_price/orderbook.rb
|
86
|
+
- lib/paribu_price/ticker.rb
|
70
87
|
- lib/paribu_price/version.rb
|
71
88
|
- paribu_price.gemspec
|
72
89
|
homepage: https://github.com/computeus/paribu_price
|