Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
allpts.png | 2019-05-10 | 10.0 kB | |
btcp.c | 2019-05-10 | 17.1 kB | |
readme.md | 2019-05-10 | 1.4 kB | |
dialog.png | 2019-05-10 | 11.6 kB | |
Makefile | 2019-05-10 | 537 Bytes | |
Totals: 5 Items | 40.6 kB | 0 |
allpts.png wasn't made with this program, but it's made with data saved by it. It's a demonstration of why you might want more than 4 hours worth of data. The big/easy money in bitcoin trading is long term stuff, not minute by minute. All my investing was done in January when the price was low.
Fetching is done by getprice() which uses the URL in daturl. The constructor for the app, btc_constructor, sets up a string wgstr that gets fed to system(). It's saved as /tmp/btcdat which inside looks like: {"data":{"base":"BTC","currency":"USD","amount":"6170.72"}} Getprice() uses strstr to look for SEARCH which is by default defined as "amount". strstr returns a pointer if it finds it, that pointer gets advanced by SKIP which is 9, to the beginning of the number. The pointer from strstr is to the beginning of the string amount, you need to advance it past the other stuff. For other data you'd put some label in SEARCH and how much to skip over in SKIP. If keepdata is set to 1 the files are kept. I mostly wrote getprice for the text version and replaced the acquisition routine in cpumonitor with it.
I'm watching the buy price in US dollars on Coinbase. That's in the url. You could fetch something else with a different URL and search string, like a Litecoin price, or the Litecoin/Bitcoin exchange ratio. I mine Litecoin a little, but checking once a week is enough.