Class: Iro::Purse

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
Defined in:
app/models/iro/purse.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listObject



69
70
71
# File 'app/models/iro/purse.rb', line 69

def self.list
  [[nil,nil]] + all.map { |p| [p, p.id] }
end

Instance Method Details

#availableObject



33
34
35
# File 'app/models/iro/purse.rb', line 33

def available
  available_amount
end

#balanceObject



37
38
39
# File 'app/models/iro/purse.rb', line 37

def balance
  0.01
end

#delta_to_plot_p(*args) ⇒ Object

delta to plot percentage convert to normal between 0 and 3 std



55
56
57
58
59
60
61
62
63
64
# File 'app/models/iro/purse.rb', line 55

def delta_to_plot_p( *args )
  x = delta_wt_avg( *args ).abs
  if x < 0.5
    y = 1
  else
    y = 2 - 1/( 1.5 - x )
  end
  y_ = "#{ (y*100) .to_i}%"
  return y_
end

#delta_wt_avg(begin_end, long_short, inner_outer) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/iro/purse.rb', line 41

def delta_wt_avg( begin_end, long_short, inner_outer )
  max_loss_total = 0

  out = positions.send( long_short ).map do |pos|
    max_loss_total += pos.max_loss * pos.q
    pos.max_loss * pos.q * pos.send( inner_outer ).send( "#{begin_end}_delta" )
  end
  # puts! out, 'delta_wt_avg 1'
  out = out.reduce( &:+ ) / max_loss_total rescue 0
  # puts! out, 'delta_wt_avg 2'
  return out
end

#heightObject

for rolling only:



27
# File 'app/models/iro/purse.rb', line 27

field :height,           type: :integer, default: 100

#summary_unitObject

with unit 10, .001 with unit 100, .0001



24
# File 'app/models/iro/purse.rb', line 24

field :summary_unit,    type: :float, default: 0.001

#to_sObject



66
67
68
# File 'app/models/iro/purse.rb', line 66

def to_s
  slug
end