Method: Quant::Ticks::Serializers::OHLC.to_h

Defined in:
lib/quant/ticks/serializers/ohlc.rb

.to_h(tick) ⇒ Hash

Returns a Hash of the Spot tick’s key properties

Serialized Keys:

  • ot: open timestamp

  • ct: close timestamp

  • o: open price

  • h: high price

  • l: low price

  • c: close price

  • bv: base volume

  • tv: target volume

  • t: trades

  • g: green

  • j: doji

Examples:

Quant::Ticks::Serializers::Tick.to_h(tick)
# => { "ot" => [Time], "ct" => [Time], "o" => 1.0, "h" => 2.0,
#      "l" => 0.5, "c" => 1.5, "bv" => 6.0, "tv" => 5.0, "t" => 1, "g" => true, "j" => true }

Parameters:

Returns:

  • (Hash)


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/quant/ticks/serializers/ohlc.rb', line 73

def self.to_h(tick)
  { "ot" => tick.open_timestamp,
    "ct" => tick.close_timestamp,

    "o" => tick.open_price,
    "h" => tick.high_price,
    "l" => tick.low_price,
    "c" => tick.close_price,

    "bv" => tick.base_volume,
    "tv" => tick.target_volume,

    "t" => tick.trades,
    "g" => tick.green,
    "j" => tick.doji }
end