Formulae: Difference between revisions

From Bittylicious
Jump to navigation Jump to search
No edit summary
 
(27 intermediate revisions by 2 users not shown)
Line 8: Line 8:


Figures from other Bitcoin markets can be used in the equation, and these take the form ''market''_''currency''_''type'', e.g. ''mtgox_GBP_2bsr''.
Figures from other Bitcoin markets can be used in the equation, and these take the form ''market''_''currency''_''type'', e.g. ''mtgox_GBP_2bsr''.
The current maximum length of a formula is 1024 characters.
No guarantees are provided regarding any of the data and these functions are provided for convenience only. Do note that it is common for API calls to get external prices to fail or provide outdated information.


==Special Functions==
==Special Functions==
Line 26: Line 30:


* Matching other seller offers with a minimum price of 600 and a maximum of 800: ''min(max(bitty_lowest(0.01), 600), 800)''
* Matching other seller offers with a minimum price of 600 and a maximum of 800: ''min(max(bitty_lowest(0.01), 600), 800)''
* Beating other seller offers by 5 down to a minimum price of 600 but a maximum of 800 in any case ''min(max(bitty_lowest(0.01) - 5, 60), 80)''
* Beating other seller offers by 5 down to a minimum price of 600 but a maximum of 800 in any case ''min(max(bitty_lowest(0.01) - 5, 600), 800)''


===bitty_num_lowest(''<num BTC>'', ''<num brokers>'')===
===bitty_num_lowest(''<num BTC>'', ''<num brokers>'')===
Line 41: Line 45:
===median(''<price 1>'', ''<price 2>'', ''<price 3>'', ...)===
===median(''<price 1>'', ''<price 2>'', ''<price 3>'', ...)===


This will return the media price between the set of prices in the brackets. If there is an even number, the mid-point of the two mid-point values is returned.
This will return the median price between the set of prices in the brackets. If there is an even number, the mid-point of the two mid-point values is returned.


This is particularly useful to shield yourself from exchanges that are returning incorrect values, or have suffered a crash of some sort.
This is particularly useful to shield yourself from exchanges that are returning incorrect values, or have suffered a crash of some sort.
Line 47: Line 51:
As an example:
As an example:


* Kraken EUR in GBP: ((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP)
* Kraken EUR in GBP: ''((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP)''
* Bitstamp USD in GBP: (bitstamp_USD_bid * fx_USD_GBP)
* Bitstamp USD in GBP: ''(bitstamp_USD_bid * fx_USD_GBP)''
* Bitcoin Average USD in GBP: (btcavg_BTCUSD_last * fx_USD_GBP)
* Bitcoin Average USD in GBP: ''(btcavg_BTCUSD_last * fx_USD_GBP)''
   
   
Therefore the median (midpoint) of all Exchanges Above is calcuated by:
Therefore the median (midpoint) of all Exchanges Above is calcuated by:
   
   
median(((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP),(bitstamp_USD_bid * fx_USD_GBP),(btcavg_BTCUSD_last * fx_USD_GBP))
''median(((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP),(bitstamp_USD_bid * fx_USD_GBP),(btcavg_BTCUSD_last * fx_USD_GBP))''


==Foreign Exchange Rates==
==Foreign Exchange Rates==
Line 69: Line 73:
Bitcoin Average actually tracks multiple cryptocurrencies, so the format is ''<cryptocurrency><fiat currency>'', e.g. BTCGBP for the costs of Bitcoin in British pounds.
Bitcoin Average actually tracks multiple cryptocurrencies, so the format is ''<cryptocurrency><fiat currency>'', e.g. BTCGBP for the costs of Bitcoin in British pounds.


There are dozens of fiat currencies support, and I believe it uses up to date conversion rates.
There are dozens of fiat currencies supported, and I believe it uses up to date conversion rates.


This is only updated approximately every ten minutes.
This is updated approximately every two minutes.


As an example, use btcavg_BTCGBP_last
As an example, use btcavg_BTCGBP_last
Line 84: Line 88:
===[https://www.bitstamp.net/ Bitstamp]===
===[https://www.bitstamp.net/ Bitstamp]===


* ''bitstamp_USD''
* ''bitstamp_BCHUSD''
* ''bitstamp_BCHEUR''
* ''bitstamp_BTCUSD''
* ''bitstamp_BTCEUR''
* ''bitstamp_ETHUSD''
* ''bitstamp_ETHEUR''
* ''bitstamp_LTCUSD''
* ''bitstamp_LTCEUR''
* ''bitstamp_XRPUSD''
* ''bitstamp_XRPEUR''
* ''bitstamp_BTCGBP''
* ''bitstamp_ETHGBP''
* ''bitstamp_LTCGBP''


====Types====
====Types====
Line 104: Line 120:


* ''bpi'' - The Blended Price Index current price
* ''bpi'' - The Blended Price Index current price
===[https://www.coinfloor.co.uk/ Coinfloor]===
* ''coinfloor_BTCEUR''
* ''coinfloor_BTCGBP''
====Types====
* ''last'' - last BTC price
* ''high'' - last 24 hours price high
* ''low'' - last 24 hours price low
* ''vwap'' - last 24 hours volume weighted average price
* ''volume'' - last 24 hours volume
* ''bid'' - highest buy order
* ''ask'' - lowest sell order
===[https://www.coingecko.com/ CoinGecko] - Overall coin data===
* ''coingecko_XXXYYY_last' - Price of XXX against YYY.
** XXX is any of the top 1000 virtual currencies as listed on CoinGecko. More than three characters are supported, e.g. START.
** YYY is BTC (Bitcoin) as al of these are priced against Bitcoin.
===[https://www.coingecko.com/ CoinGecko] - Exchange pricing===
* ''coingecko_XXXYYY_ZZZ' - Price of XXX against YYY on exchange ZZZ.
** XXX and YYY are a currency pair (e.g. BTCUSDT for BTC vs USD Tether)
** ZZZ is an exchange. Currently supported exchanges are:
*** binance
*** bitfinex
*** bittrex*
*** gdax
*** huobi
By default, the top 100 tickers on each exchange are listed only. For exchanges above with an asterisk *, we get all available tickers.
We can add any exchange as required, as long as it's on CoinGecko.


===[http://coinmarketcap.com/ Coin Market Cap]===
===[http://coinmarketcap.com/ Coin Market Cap]===


Coin Market Cap provides a list of almost every altcoin in existence and aggregates data from the major marketplaces and exchanges. This data is pulled from [http://coinmarketcap-nexuist.rhcloud.com/ a RedHat cloud server] and is updated every five minutes.
Because Coin Market Cap charges a lot for API access, we now only pull cryptocurrencies that are listed on Bittylicious and only provide the conversion rate to BTC and USD. For instance, we would pull the LTC to BTC or USD conversion rates.


* ''coinmarketcap_XXXYYY' - Price of XXX against YYY.
''The data is pulled every ten minutes so should not be strongly relied on.''
** XXX is any of the virtual currencies traded on Coin Market Cap. More than three characters are supported, e.g. START.
 
** YYY is a 'currency' and one of USD or BTC (Bitcoin).
* ''coinmarketcap_XXXYYY_last' - Price of XXX against YYY.
** XXX is any of the virtual currencies traded on Bittylicious. More than three characters are supported, e.g. START.
** YYY is a 'currency' and must be BTC (Bitcoin) or USD.


Sometimes, there are cryptocurrencies with the same ticker. In these instances, you should not rely on this data. Let us know if this is actually an issue for you.
Sometimes, there are cryptocurrencies with the same ticker. In these instances, you should not rely on this data. Let us know if this is actually an issue for you.
Line 118: Line 172:


* ''last'' - The blended price as listed on Coin Market Cap.
* ''last'' - The blended price as listed on Coin Market Cap.
===[https://www.independentreserve.com/ Independent Reserve]===
This is primarily an Australasian exchange, with the following markets supported:
* ''indreserve_BCHAUD''
* ''indreserve_BTCAUD''
* ''indreserve_ETHAUD''
====Types====
* ''last'' - Last traded price
* ''ask'' - Current lowest offer on order book
* ''bid'' - Current highest bid on order book


===[https://kraken.com/ Kraken]===
===[https://kraken.com/ Kraken]===
Line 125: Line 193:
* ''kraken_BTCUSD''
* ''kraken_BTCUSD''
* ''kraken_BTCJPY''
* ''kraken_BTCJPY''
* ''kraken_DASHBTC''
* ''kraken_DASHEUR''
* ''kraken_DASHUSD''
* ''kraken_ETHGBP''
* ''kraken_ETHGBP''
* ''kraken_ETHEUR''
* ''kraken_ETHEUR''
Line 131: Line 202:
* ''kraken_LTCUSD''
* ''kraken_LTCUSD''
* ''kraken_LTCEUR''
* ''kraken_LTCEUR''
* ''kraken_DOGEEUR''
* ''kraken_DOGEUSD''


====Types====
====Types====
Line 142: Line 215:
* ''24h_avg'' - Weighted average price in the last rolling 24 hours
* ''24h_avg'' - Weighted average price in the last rolling 24 hours


===[https://shapeshift.io Shapeshift.io]===
===[https://binance.com/ Binance]===
 
* ''binance_XXXBTC'' - any supported Bittylicious coin against BTC
* ''binance_XXXUSDT'' - any supported Bittylicious coin against USDT (Tether)
 
====Types====
 
* ''last''
 
===[https://coinbase.com/ Coinbase]===
 
* ''coinbase_XXXUSD'' - any supported Bittylicious coin against USD


Shapeshift.io is a service that converts one altcoin to another with no registration. Bittylicious only records currency pairs that involves BTC at some point, e.g. LTC -> BTC or BTC -> LTC, but not LTC -> DOGE.
====Types====
 
* ''last''
 
===Fees===
 
These are the network fees for sending cryptocurrencies.
 
* ''feeSats'' - the fee in satoshis / the most divisible unit for this cryptocurrency


====Types====
====Types====


* ''XXX'' - XXX is another coin ticker symbol, e.g. LTC.
* ''avg'' - The average fee rate of the below, taking into account only fees fetched less than one hour ago
* ''bitcoiner'' - Fee from Bitcoiner (BTC only)
* ''blockchair'' - Fee from Blockchair (BTC, ETH, LTC, DOGE, GRS, DASH)
* ''etherscan'' - Fee from Etherscan (ETH only)
* ''blockcypher'' - Fee from BlockCypher (BTC, DASH, LTC, DOGE)


====Examples====
====Examples====


* ''shapeshiftio_LTC_BTC'' which is approximately 0.012 at the time of writing.
* ''feeSats_BTC_avg'' which is approximately 48000 at the time of writing.
* ''btcavg_GBP_bid * shapeshiftio_LTC_BTC'' which is the average GBP price to sell one Bitcoin multiplied by the amount of Bitcoins that 1 Litecoin buys.
 
===X - Internally generated figures===
 
Bittylicious tries to put a best guess on pricing based on the median of some of the above market figures. It is not recommended you use these values in any formulae, but they are used internally in Bittylicious.
 
* ''xaverage_XXX_YYY'' where XXX is a currency from GBP, EUR and USD, and YYY is a coin from BTC and ETH.

Latest revision as of 21:39, 14 June 2023

The price formula text box allow for the price of your Bitcoins to dynamically alter as market conditions change.

The calculation process allows for a wide variety of mathematical operators typical in computing terminology (e.g. * for multiplied by and ^ for to the power of). Other available functions include:

  • max - Maximum value from the parameters, e.g. max(80, mtgox_GBP_buy)
  • min - Minimum value from the parameters
  • average - Average (mean) value from the parameters

Figures from other Bitcoin markets can be used in the equation, and these take the form market_currency_type, e.g. mtgox_GBP_2bsr.

The current maximum length of a formula is 1024 characters.

No guarantees are provided regarding any of the data and these functions are provided for convenience only. Do note that it is common for API calls to get external prices to fail or provide outdated information.

Special Functions

bitty_lowest(<num BTC>)

Returns the price of the best value active broker (excluding yourself) with same offer characteristics as your offer. They must have at least <num BTC> available for sale.

Important notes:

  • This returns the lowest price offered by sellers if you are selling coins. If you are buying coins, it returns the highest price offered by sellers.
  • This is updated every time the formulae are updated (every ten seconds) so it may take a few iterations for this value to stabilise.
  • If you undercut others, you must undercut by at least 0.1% of the value. Anything significantly less than this and done repeatedly will be considered spammy.
  • If you undercut others, you should couple this with a max(...) modifier because your price could be dragged all the way down to 0 (or infinity when buying coins)
  • bitty_lowest should never be used on its own as it will return 999,999.99 if you are the only active offer (0 if you are buying coins). Make sure you use it in combination with a min(...).

Three recommended ways of using bitty_lowest other functions are:

  • Matching other seller offers with a minimum price of 600 and a maximum of 800: min(max(bitty_lowest(0.01), 600), 800)
  • Beating other seller offers by 5 down to a minimum price of 600 but a maximum of 800 in any case min(max(bitty_lowest(0.01) - 5, 600), 800)

bitty_num_lowest(<num BTC>, <num brokers>)

Returns a 1 or 0 based on the number of distinct brokers matching each other:

  • Returns 1 if there are at least num brokers, each offering at least num BTC coins, that all have exactly the same price (and this price is the cheapest price for this offer).
  • Returns 0 otherwise.

This call is particularly useful if you want to undercut others when you would be sharing trades with 5+ others offering 0.01 BTC, but you are happy to share with 0-4 others. This would be done, undercutting by 5, by using bitty_lowest(0.01) - (bitty_num_lowest(0.01, 5) * 5).

Remember that any formula using bitty_lowest should be coupled with appropriate mins and maxs as above.

median(<price 1>, <price 2>, <price 3>, ...)

This will return the median price between the set of prices in the brackets. If there is an even number, the mid-point of the two mid-point values is returned.

This is particularly useful to shield yourself from exchanges that are returning incorrect values, or have suffered a crash of some sort.

As an example:

  • Kraken EUR in GBP: ((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP)
  • Bitstamp USD in GBP: (bitstamp_USD_bid * fx_USD_GBP)
  • Bitcoin Average USD in GBP: (btcavg_BTCUSD_last * fx_USD_GBP)

Therefore the median (midpoint) of all Exchanges Above is calcuated by:

median(((kraken_BTCEUR_bid/ fx_USD_EUR) * fx_USD_GBP),(bitstamp_USD_bid * fx_USD_GBP),(btcavg_BTCUSD_last * fx_USD_GBP))

Foreign Exchange Rates

Use fx_USD_code, e.g. fx_USD_GBP to get the number of GBP that make one USD (usually between 0.50 and 0.80). code can be almost any three character currency code.

Foreign exchange rates are derived from openexchangerates.org and are updated every hour.

Markets

Remember, you have to use the market, currency and type, e.g. btcavg_BTCGBP_ask.

BitcoinAverage

Bitcoin Average actually tracks multiple cryptocurrencies, so the format is <cryptocurrency><fiat currency>, e.g. BTCGBP for the costs of Bitcoin in British pounds.

There are dozens of fiat currencies supported, and I believe it uses up to date conversion rates.

This is updated approximately every two minutes.

As an example, use btcavg_BTCGBP_last

  • btcavg_...

Types

  • 24h_avg - Weighted average price in the last rolling 24 hours
  • last - Weighted average last price that coins are sold at on the market

Bitstamp

  • bitstamp_BCHUSD
  • bitstamp_BCHEUR
  • bitstamp_BTCUSD
  • bitstamp_BTCEUR
  • bitstamp_ETHUSD
  • bitstamp_ETHEUR
  • bitstamp_LTCUSD
  • bitstamp_LTCEUR
  • bitstamp_XRPUSD
  • bitstamp_XRPEUR
  • bitstamp_BTCGBP
  • bitstamp_ETHGBP
  • bitstamp_LTCGBP

Types

  • ask - Highest price that coins are bought at on the market
  • bid - Lowest price that coins are sold at on the market
  • high
  • low
  • last - The last price a trade was completed at
  • volume

CoinDesk BPI

  • coindesk_USD
  • coindesk_EUR
  • coindesk_GBP

Types

  • bpi - The Blended Price Index current price

Coinfloor

  • coinfloor_BTCEUR
  • coinfloor_BTCGBP

Types

  • last - last BTC price
  • high - last 24 hours price high
  • low - last 24 hours price low
  • vwap - last 24 hours volume weighted average price
  • volume - last 24 hours volume
  • bid - highest buy order
  • ask - lowest sell order

CoinGecko - Overall coin data

  • coingecko_XXXYYY_last' - Price of XXX against YYY.
    • XXX is any of the top 1000 virtual currencies as listed on CoinGecko. More than three characters are supported, e.g. START.
    • YYY is BTC (Bitcoin) as al of these are priced against Bitcoin.

CoinGecko - Exchange pricing

  • coingecko_XXXYYY_ZZZ' - Price of XXX against YYY on exchange ZZZ.
    • XXX and YYY are a currency pair (e.g. BTCUSDT for BTC vs USD Tether)
    • ZZZ is an exchange. Currently supported exchanges are:
      • binance
      • bitfinex
      • bittrex*
      • gdax
      • huobi

By default, the top 100 tickers on each exchange are listed only. For exchanges above with an asterisk *, we get all available tickers.

We can add any exchange as required, as long as it's on CoinGecko.

Coin Market Cap

Because Coin Market Cap charges a lot for API access, we now only pull cryptocurrencies that are listed on Bittylicious and only provide the conversion rate to BTC and USD. For instance, we would pull the LTC to BTC or USD conversion rates.

The data is pulled every ten minutes so should not be strongly relied on.

  • coinmarketcap_XXXYYY_last' - Price of XXX against YYY.
    • XXX is any of the virtual currencies traded on Bittylicious. More than three characters are supported, e.g. START.
    • YYY is a 'currency' and must be BTC (Bitcoin) or USD.

Sometimes, there are cryptocurrencies with the same ticker. In these instances, you should not rely on this data. Let us know if this is actually an issue for you.

Types

  • last - The blended price as listed on Coin Market Cap.

Independent Reserve

This is primarily an Australasian exchange, with the following markets supported:

  • indreserve_BCHAUD
  • indreserve_BTCAUD
  • indreserve_ETHAUD

Types

  • last - Last traded price
  • ask - Current lowest offer on order book
  • bid - Current highest bid on order book

Kraken

  • kraken_BTCGBP
  • kraken_BTCEUR
  • kraken_BTCUSD
  • kraken_BTCJPY
  • kraken_DASHBTC
  • kraken_DASHEUR
  • kraken_DASHUSD
  • kraken_ETHGBP
  • kraken_ETHEUR
  • kraken_ETHUSD
  • kraken_ETHJPY
  • kraken_LTCUSD
  • kraken_LTCEUR
  • kraken_DOGEEUR
  • kraken_DOGEUSD

Types

  • ask
  • bid
  • last
  • vol
  • low
  • high
  • 24h_avg - Weighted average price in the last rolling 24 hours

Binance

  • binance_XXXBTC - any supported Bittylicious coin against BTC
  • binance_XXXUSDT - any supported Bittylicious coin against USDT (Tether)

Types

  • last

Coinbase

  • coinbase_XXXUSD - any supported Bittylicious coin against USD

Types

  • last

Fees

These are the network fees for sending cryptocurrencies.

  • feeSats - the fee in satoshis / the most divisible unit for this cryptocurrency

Types

  • avg - The average fee rate of the below, taking into account only fees fetched less than one hour ago
  • bitcoiner - Fee from Bitcoiner (BTC only)
  • blockchair - Fee from Blockchair (BTC, ETH, LTC, DOGE, GRS, DASH)
  • etherscan - Fee from Etherscan (ETH only)
  • blockcypher - Fee from BlockCypher (BTC, DASH, LTC, DOGE)

Examples

  • feeSats_BTC_avg which is approximately 48000 at the time of writing.

X - Internally generated figures

Bittylicious tries to put a best guess on pricing based on the median of some of the above market figures. It is not recommended you use these values in any formulae, but they are used internally in Bittylicious.

  • xaverage_XXX_YYY where XXX is a currency from GBP, EUR and USD, and YYY is a coin from BTC and ETH.