/** This sample adds Bitcoin exchange rates using the symbols BTC, XBT, or "bitcoin", or ₿ (Unicode \u20bf), the Unicode symbol. (XBT is more likely to be used as an ISO-4217-compatible symbol. See http://www.coindesk.com/bitcoin-gaining-market-based-legitimacy-xbt/ ) This uses the site: https://blockchain.info/stats?format=json The data source is in JSON format ( http://www.json.org/ ) so this requires Frink version 2014-02-17 or later which includes the parseJSON[string] function. See: https://frinklang.org/#ParsingJSON The value of bitcoins are captured when this file is parsed, and not updated over the course of a run, to avoid swamping the server for requests. */ // NOTE: The := operator creates a new globally-available unit that also gets // prefix- and suffix-checking, so you can write "millibitcoin" or "bitcoins". // Check out this parsing and declaration of a new Frink unit (with correct // dimensions of currency, due to multiplying by USD) in one line: bitcoin := parseJSON[read["https://blockchain.info/stats?format=json"]]@"market_price_usd" USD BTC := bitcoin // Add a common alias XBT := bitcoin // Add a newer alias that will fit ISO-4217 standard. // \u20bf := bitcoin // Unicode symbol ₿ (this doesn't work as a standalone symbol) // TODO: Check what Unicode type that is (Currency Symbol) 20a0 - 20cf // https://www.compart.com/en/unicode/block/U+20A0 satoshi := 1e-8 bitcoin // One ten-millionth of a Bitcoin. // Calculate estimated time to find a bitcoin given the difficulty // (as a dimensionless number) // your hashing rate (e.g. 8 billion/s) // The factor of 2^32 arises because each work unit requires you to hash // 2^32 values. bitcoinTime[difficulty is dimensionless, hashrate is frequency] := difficulty * 2^32 / hashrate