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



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

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

Instance Method Details

#availableObject



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

def available
  available_amount
end

#balanceObject



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

def balance
  0.01
end

#delta_to_plot_p(*args) ⇒ Object

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



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

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



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

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:



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

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

#summary_unitObject

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



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

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

#to_sObject



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

def to_s
  slug
end