Class: Math::Finance::CurrencyMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/ruuuby/math/finance/currency_matrix.rb

Overview

@note: temporary implementation

‣ w/ n currencies there exists ‘n² - n` exchange rates

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(labels, data, raw_ratios = true) ⇒ CurrencyMatrix

Returns a new instance of CurrencyMatrix.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 19

def initialize(labels, data, raw_ratios=true)
  

Instance Attribute Details

#cached_statsObject (readonly)

Returns the value of attribute cached_stats.



17
18
19
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 17

def cached_stats
  @cached_stats
end

#dataObject (readonly)

Returns the value of attribute data.



17
18
19
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 17

def data
  @data
end

#labelsObject (readonly)

Returns the value of attribute labels.



17
18
19
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 17

def labels
  @labels
end

Instance Method Details

#algo_🌴_arbitrageObject



48
49
50
51
52
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 48

def algo_

#calc_arbitrage_multipliersArray

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 55

def calc_arbitrage_multipliers
  

#calc_karps_algo_valuesFloat, ...

karps algo will verify the best value but NOT which vertexes are involved to create that best value

Returns:



101
102
103
104
105
106
107
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 101

def calc_karps_algo_values
  

#karps_algorithm(target_vertex) ⇒ Float

Parameters:

Returns:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 114

def karps_algorithm(target_vertex)
  identity_matrix                = ::Array.new(@len, ::Float::INFINITY_NEGATIVE)
  identity_matrix[target_vertex] = 0.0
  identity_matrix                = ::Matrix.column_vector(identity_matrix)
  v

#η̂!Matrix

Returns self (w/ each normalized via lnₑ).

Returns:

  • (Matrix)

    self (w/ each normalized via lnₑ)



38
39
40
41
42
43
44
45
46
# File 'lib/ruuuby/math/finance/currency_matrix.rb', line 38

def