Class: Moex::Api
- Inherits:
-
Object
- Object
- Moex::Api
- Defined in:
- app/lib/moex/api.rb
Overview
Moscow Exchange public api
Constant Summary collapse
- BASE_URL =
"https://iss.moex.com/iss"
Instance Method Summary collapse
-
#history_engine_market_securities(engine, market, date, start: 0, lang: "en") ⇒ Array<Hash>
Get market data for all assets on a specific date.
-
#index(lang: "en") ⇒ Hash
Get references: engines, markets, boards, boardgroups, durations, securitytypes, securitygroups, securitycollections.
Instance Method Details
#history_engine_market_securities(engine, market, date, start: 0, lang: "en") ⇒ Array<Hash>
Get market data for all assets on a specific date
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/lib/moex/api.rb', line 18 def history_engine_market_securities( engine, market, date, start: 0, lang: "en" ) response = RestClient.get( "#{BASE_URL}/history/engines/#{engine}/markets/#{market }/securities.json", params: { date: date, start: start, lang: lang, "iss.json" => "extended", "iss.meta" => "off" } ) result = JSON.parse(response.body).last cursor = result["history.cursor"].last history = result["history"] return history if cursor["INDEX"] + cursor["PAGESIZE"] >= cursor["TOTAL"] history + history_engine_market_securities( engine, market, date, start: start + cursor["PAGESIZE"], lang: lang ) end |
#index(lang: "en") ⇒ Hash
Get references: engines, markets, boards, boardgroups, durations, securitytypes, securitygroups, securitycollections
42 43 44 45 46 47 48 |
# File 'app/lib/moex/api.rb', line 42 def index(lang: "en") response = RestClient.get( "#{BASE_URL}/index.json", params: { "iss.json" => "extended", "iss.meta" => "off", lang: lang } ) JSON.parse(response.body).last end |