quantitative 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/quant/asset.rb +88 -0
- data/lib/quant/{security_class.rb → asset_class.rb} +14 -14
- data/lib/quant/attributes.rb +134 -0
- data/lib/quant/errors.rb +30 -5
- data/lib/quant/indicators/indicator.rb +87 -52
- data/lib/quant/indicators/indicator_point.rb +9 -21
- data/lib/quant/indicators/ma.rb +12 -20
- data/lib/quant/indicators/ping.rb +16 -0
- data/lib/quant/indicators.rb +1 -23
- data/lib/quant/indicators_proxy.rb +23 -0
- data/lib/quant/indicators_sources.rb +18 -0
- data/lib/quant/interval.rb +37 -12
- data/lib/quant/mixins/filters.rb +2 -0
- data/lib/quant/refinements/array.rb +8 -7
- data/lib/quant/series.rb +36 -19
- data/lib/quant/ticks/ohlc.rb +7 -10
- data/lib/quant/ticks/serializers/ohlc.rb +33 -22
- data/lib/quant/ticks/serializers/spot.rb +1 -4
- data/lib/quant/ticks/serializers/tick.rb +3 -3
- data/lib/quant/ticks/spot.rb +7 -7
- data/lib/quant/ticks/tick.rb +22 -9
- data/lib/quant/version.rb +1 -1
- data/lib/quantitative.rb +1 -1
- metadata +8 -4
- data/lib/quant/security.rb +0 -80
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quantitative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -44,12 +44,18 @@ files:
|
|
44
44
|
- LICENSE
|
45
45
|
- README.md
|
46
46
|
- Rakefile
|
47
|
+
- lib/quant/asset.rb
|
48
|
+
- lib/quant/asset_class.rb
|
49
|
+
- lib/quant/attributes.rb
|
47
50
|
- lib/quant/config.rb
|
48
51
|
- lib/quant/errors.rb
|
49
52
|
- lib/quant/indicators.rb
|
50
53
|
- lib/quant/indicators/indicator.rb
|
51
54
|
- lib/quant/indicators/indicator_point.rb
|
52
55
|
- lib/quant/indicators/ma.rb
|
56
|
+
- lib/quant/indicators/ping.rb
|
57
|
+
- lib/quant/indicators_proxy.rb
|
58
|
+
- lib/quant/indicators_sources.rb
|
53
59
|
- lib/quant/interval.rb
|
54
60
|
- lib/quant/mixins/direction.rb
|
55
61
|
- lib/quant/mixins/filters.rb
|
@@ -61,8 +67,6 @@ files:
|
|
61
67
|
- lib/quant/mixins/trig.rb
|
62
68
|
- lib/quant/mixins/weighted_average.rb
|
63
69
|
- lib/quant/refinements/array.rb
|
64
|
-
- lib/quant/security.rb
|
65
|
-
- lib/quant/security_class.rb
|
66
70
|
- lib/quant/series.rb
|
67
71
|
- lib/quant/settings.rb
|
68
72
|
- lib/quant/settings/indicators.rb
|
data/lib/quant/security.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "security_class"
|
4
|
-
|
5
|
-
module Quant
|
6
|
-
# A +Security+ is a representation of a financial instrument such as a stock, option, future, or currency.
|
7
|
-
# It is used to represent the instrument that is being traded, analyzed, or managed.
|
8
|
-
# @example
|
9
|
-
# security = Quant::Security.new(symbol: "AAPL", name: "Apple Inc.", security_class: :stock, exchange: "NASDAQ")
|
10
|
-
# security.symbol # => "AAPL"
|
11
|
-
# security.name # => "Apple Inc."
|
12
|
-
# security.stock? # => true
|
13
|
-
# security.option? # => false
|
14
|
-
# security.future? # => false
|
15
|
-
# security.currency? # => false
|
16
|
-
# security.exchange # => "NASDAQ"
|
17
|
-
# security.to_h # => { "s" => "AAPL", "n" => "Apple Inc.", "sc" => "stock", "x" => "NASDAQ" }
|
18
|
-
class Security
|
19
|
-
attr_reader :symbol, :name, :security_class, :id, :exchange, :source, :meta, :created_at, :updated_at
|
20
|
-
|
21
|
-
def initialize(
|
22
|
-
symbol:,
|
23
|
-
name: nil,
|
24
|
-
id: nil,
|
25
|
-
active: true,
|
26
|
-
tradeable: true,
|
27
|
-
exchange: nil,
|
28
|
-
source: nil,
|
29
|
-
security_class: nil,
|
30
|
-
created_at: Quant.current_time,
|
31
|
-
updated_at: Quant.current_time,
|
32
|
-
meta: {}
|
33
|
-
)
|
34
|
-
raise ArgumentError, "symbol is required" unless symbol
|
35
|
-
|
36
|
-
@symbol = symbol.to_s.upcase
|
37
|
-
@name = name
|
38
|
-
@id = id
|
39
|
-
@tradeable = tradeable
|
40
|
-
@active = active
|
41
|
-
@exchange = exchange
|
42
|
-
@source = source
|
43
|
-
@security_class = SecurityClass.new(security_class)
|
44
|
-
@created_at = created_at
|
45
|
-
@updated_at = updated_at
|
46
|
-
@meta = meta
|
47
|
-
end
|
48
|
-
|
49
|
-
def active?
|
50
|
-
!!@active
|
51
|
-
end
|
52
|
-
|
53
|
-
def tradeable?
|
54
|
-
!!@tradeable
|
55
|
-
end
|
56
|
-
|
57
|
-
SecurityClass::CLASSES.each do |class_name|
|
58
|
-
define_method("#{class_name}?") do
|
59
|
-
security_class == class_name
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_h(full: false)
|
64
|
-
return { "s" => symbol } unless full
|
65
|
-
|
66
|
-
{ "s" => symbol,
|
67
|
-
"n" => name,
|
68
|
-
"id" => id,
|
69
|
-
"t" => tradeable?,
|
70
|
-
"a" => active?,
|
71
|
-
"x" => exchange,
|
72
|
-
"sc" => security_class.to_s,
|
73
|
-
"src" => source.to_s }
|
74
|
-
end
|
75
|
-
|
76
|
-
def to_json(*args, full: false)
|
77
|
-
Oj.dump(to_h(full: full), *args)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|