Class: Peatio::Injectors::PeatioEvents
- Inherits:
-
Object
- Object
- Peatio::Injectors::PeatioEvents
- Defined in:
- lib/peatio/injectors/peatio_events.rb
Instance Attribute Summary collapse
-
#base_unit ⇒ Object
Returns the value of attribute base_unit.
-
#buyer_uid ⇒ Object
Returns the value of attribute buyer_uid.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#market ⇒ Object
Returns the value of attribute market.
-
#market_name ⇒ Object
Returns the value of attribute market_name.
-
#quote_unit ⇒ Object
Returns the value of attribute quote_unit.
-
#seller_uid ⇒ Object
Returns the value of attribute seller_uid.
Instance Method Summary collapse
- #create_messages ⇒ Object
- #created_at ⇒ Object
- #inject_message ⇒ Object
- #private_order ⇒ Object
- #private_trade_user1 ⇒ Object
- #private_trade_user2 ⇒ Object
- #public_orderbook ⇒ Object
- #public_tickers ⇒ Object
- #public_trade ⇒ Object
- #run! ⇒ Object
- #updated_at ⇒ Object (also: #completed_at, #canceled_at)
Instance Attribute Details
#base_unit ⇒ Object
Returns the value of attribute base_unit.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def base_unit @base_unit end |
#buyer_uid ⇒ Object
Returns the value of attribute buyer_uid.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def buyer_uid @buyer_uid end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def logger @logger end |
#market ⇒ Object
Returns the value of attribute market.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def market @market end |
#market_name ⇒ Object
Returns the value of attribute market_name.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def market_name @market_name end |
#quote_unit ⇒ Object
Returns the value of attribute quote_unit.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def quote_unit @quote_unit end |
#seller_uid ⇒ Object
Returns the value of attribute seller_uid.
3 4 5 |
# File 'lib/peatio/injectors/peatio_events.rb', line 3 def seller_uid @seller_uid end |
Instance Method Details
#create_messages ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/peatio/injectors/peatio_events.rb', line 36 def [ public_tickers, public_orderbook, private_order, private_trade_user1, private_trade_user2, public_trade, ] end |
#created_at ⇒ Object
47 48 49 |
# File 'lib/peatio/injectors/peatio_events.rb', line 47 def created_at Time.now - 600 end |
#inject_message ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/peatio/injectors/peatio_events.rb', line 25 def if = @messages.shift type, id, event, data = Peatio::MQ::Events.publish(type, id, event, data) { } else Peatio::MQ::Client.disconnect { EventMachine.stop } end end |
#private_order ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/peatio/injectors/peatio_events.rb', line 101 def private_order [ "private", "IDABC0000001", "order", { "id": 22, "at": created_at.to_i, "market": market, "kind":"bid", "price":"1026.0", "state":"wait", "volume":"0.001", "origin_volume":"0.001" } ] end |
#private_trade_user1 ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/peatio/injectors/peatio_events.rb', line 119 def private_trade_user1 [ "private", "IDABC0000001", "trade", { "id": 7, "kind": "ask", "at": created_at.to_i, "price": "1020.0", "volume": "0.001", "ask_id": 15, "bid_id": 22, "market": market } ] end |
#private_trade_user2 ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/peatio/injectors/peatio_events.rb', line 137 def private_trade_user2 [ "private", "IDABC0000002", "trade", { "id": 7, "kind": "bid", "at": created_at.to_i, "price": "1020.0", "volume": "0.001", "ask_id": 15, "bid_id": 22, "market": market } ] end |
#public_orderbook ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/peatio/injectors/peatio_events.rb', line 58 def public_orderbook [ "public", market, "update", { "asks": [ ["1020.0","0.005"], ["1026.0","0.03"] ], "bids": [ ["1000.0","0.25"], ["999.0","0.005"], ["994.0","0.005"], ["1.0","11.0"] ] } ] end |
#public_tickers ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/peatio/injectors/peatio_events.rb', line 78 def public_tickers [ "public", "global", "tickers", { market => { "name": market_name, "base_unit": base_unit, "quote_unit": quote_unit, "low": "1000.0", "high": "10000.0", "last": "1000.0", "open": 1000.0, "volume": "0.0", "sell": "1020.0", "buy": "1000.0", "at": Time.now.to_i } } ] end |
#public_trade ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/peatio/injectors/peatio_events.rb', line 155 def public_trade [ "public", market, "trades", { "trades": [ { "tid": 7, "type": "buy", "date": created_at.to_i, "price": "1020.0", "amount": "0.001" } ] } ] end |
#run! ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/peatio/injectors/peatio_events.rb', line 5 def run! require "time" @logger = Peatio::Logger.logger @market = "eurusd" @market_name = "EUR/USD" @base_unit = "eur" @quote_unit = "usd" @seller_uid = 21 @buyer_uid = 42 @messages = @exchange_name = "peatio.events.market" EventMachine.run do Peatio::MQ::Client.new Peatio::MQ::Client.connect! Peatio::MQ::Client.create_channel! end end |
#updated_at ⇒ Object Also known as: completed_at, canceled_at
51 52 53 |
# File 'lib/peatio/injectors/peatio_events.rb', line 51 def updated_at Time.now end |