Difference between revisions of "Formulae"
|Line 202:||Line 202:|
Revision as of 15:50, 22 June 2021
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.
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.
- 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.
Remember, you have to use the market, currency and type, e.g. btcavg_BTCGBP_ask.
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
- 24h_avg - Weighted average price in the last rolling 24 hours
- last - Weighted average last price that coins are sold at on the market
- ask - Highest price that coins are bought at on the market
- bid - Lowest price that coins are sold at on the market
- last - The last price a trade was completed at
- bpi - The Blended Price Index current price
- 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:
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.
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.
- last - The blended price as listed on Coin Market Cap.
This is primarily an Australasian exchange, with the following markets supported:
- last - Last traded price
- ask - Current lowest offer on order book
- bid - Current highest bid on order book
- 24h_avg - Weighted average price in the last rolling 24 hours
Shapeshift.io is a service that converts one altcoin to another. Bittylicious only records currency pairs that are live in Bittylicious, and has BTC as the "convert to" point, e.g. LTC -> BTC, but not BTC -> LTC or LTC -> DOGE.
You can see the valid list of pairs at Shapeshift itself here so any that end in _BTC and have an existing coin on Bittylicious is usable.
- XXX - XXX is another coin ticker symbol, e.g. LTC.
- shapeshiftio_LTC_BTC which is approximately 0.007 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.