A
A
anton_trofimov952020-09-17 18:46:53
Ruby on Rails
anton_trofimov95, 2020-09-17 18:46:53

How to display stock prices?

There was an idea to create a simple application with real-time display of the prices of some stocks on the main page. Maybe someone has already written something like this and can tell where you can get a free api for all this? In my head it looks like this - I get a json request and parse it on the page, updating every second

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman Mirilaczvili, 2015-10-20
@vadimstroganov

It turned out only if iterate over the records like this:
What if there are too many records?

Your code is correct.
.limit()limits the number of records returned by the SQL database, sorted by primary ID unless otherwise specified. So there shouldn't be any scalability issues here.
It is also desirable to use .select()for selected fields in order to speed up the query a little more.

B
Biggless, 2015-10-20
@Biggless

Post.where(id: Post.offset(5).limit(2)).order(created_at: :desc) ?

A
Artem Pyankov, 2015-10-22
@ibub1ik

Sorting at the application level is VERY bad, you should strive to delegate the maximum of such work to the database. Try like this:
I may have made a mistake somewhere, but dig this way in the docks .

8
8XL, 2020-09-17
@8XL

['BTC','DASH','DOGE','DCR','DAI', 'EOS','ETH','ETC',
'XLM','XMR', 'ZRX', 'TRX'];
//ADA,BAT,BCH,BSV,BTC,BTG,DASH,DOGE
//,IOTA,LTC,QTUM,LINK,LSK,XEM,NEO,USDC
//,USDT ,XRP,XTZ,ZEC available tickers
` https: //production.api.coindesk.com/v2/price/ticke... insert available tickers separated by commas"`
I took from here. After digging into the api, you can find many other interesting things
ps and change the tag to api, it will be more convenient thanks to all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question