phBot Crypto
  • Introduction
  • Disclaimer
  • Purchasing
  • Download
  • Updating
  • Supported Operating Systems
  • Wallets
  • Tax
  • Frequently Asked Questions
  • DCA Calculator
  • Configuration
    • Introduction
    • Main
    • Pairs
    • Proxy
    • Examples
  • Exchanges
    • Introduction
    • Binance
    • Coinbase
    • Gemini
    • Alpaca (stocks/crypto)
    • Kraken
  • Python
    • Introduction
    • API
    • Functions
    • Example
    • Libs
Powered by GitBook
On this page
  • get_bars(exchange, pair, granularity)
  • Usage
  • Returns
  • get_dominance()
  • Usage
  • Returns
  • get_fear_greed()
  • Usage
  • Returns
  1. Python

API

Python functions for phBot Crypto

get_bars(exchange, pair, granularity)

This function retrieves historical bars for a given pair from an exchange. Granularity is in seconds.

Usage

get_bars(EX_COINBASE, 'BTC-USD', 60)

Returns

None or a list containing the historical bars in JSON.

[{
   't': 1663858740,
   'o': 18865.76,
   'h': 18891.17,
   'l': 18855.5,
   'c': 18879.53,
   'v': 41.84053623
}, {
   't': 1663858680,
   'o': 18893.84,
   'h': 18900.26,
   'l': 18862.77,
   'c': 18866.74,
   'v': 41.47941474
}, {
   't': 1663858620,
   'o': 18896.58,
   'h': 18904.81,
   'l': 18882.33,
   'c': 18892.81,
   'v': 50.05292682
}, {
   't': 1663858560,
   'o': 18908.72,
   'h': 18917.8,
   'l': 18878.35,
   'c': 18898.82,
   'v': 29.25498139
}, {
   't': 1663858500,
   'o': 18911.94,
   'h': 18912.82,
   'l': 18883.5,
   'c': 18909.35,
   'v': 38.71486704
}

...etc

]

get_dominance()

Usage

get_dominance()

Returns

Noneor a dict containing dominance data from CMC. Data is cached for 2 minutes before being refreshed.

{
   "btc_dominance":54.95772073293,
   "eth_dominance":13.109460109462,
   "btc_dominance_24h_percentage_change":0.13599359293,
   "eth_dominance_24h_percentage_change":0.148275599462,
   "btc_dominance_yesterday":54.82172714,
   "eth_dominance_yesterday":12.96118451,
   "last_updated":"2024-12-13T05:14:59.999Z"
}

get_fear_greed()

This function returns the crypto fear and greed index from CoinMarketCap.

Usage

get_fear_greed()

Returns

Noneor a dictcontaining the latest fear/greed index from CMC. Data is cached for 2 minutes before being refreshed.

{
   "timestamp":1733961600,
   "value":80,
   "classification":"Extreme greed"
}

Last updated 4 months ago

This function returns the Bitcoin and Ethereum dominance values from . A CMC API key must be configured in the phBot.inifile.

CoinMarketCap