Skip to content

MarketCollector

Amargedon edited this page Apr 1, 2023 · 5 revisions

MarketCollector bot helper named marketcollector.py

Type = trading pair

What does it do?

It will fetch data from multiple sources and create a local database to be used by other script(s).

How does it work?

When determining the correct pair(s) for your bots you want to filter on many parameters, for example use the coins which are ranked from 5 to 50 and have a volatility between 1% and 10%. With the previous scripts (Altrank, Galaxyscore, CoinMarketCap and BotAssistExplorer) this was not possible as they only contain a part of the data.

So, the MarketCollector is introduced to combine the data from different sources and make that available for other script(s). This script will only fetch the data from external sources and write it to a shared database (which is also why the SHAREDIR option is mandatory for this script).

Because this script supports fetching data from multiple sources, there are different sections in the configuration:

  • cmc_: fetch data from CoinMarketCap with the percent change compared to BTC, BNB, ETH or USD.
  • cg_: fetch data from CoinGecko with the percent change compared to BTC, BNB, ETH or USD.
  • altrank_ and galaxyscore_: fetch data from LunarCrush with the Altrank and/or GalaxyScore data.
  • volatility_: fetch data from 3c-tools with the volatility.

Because both CoinMarketCap and CoinGecko can be used, one of them needs to be configured (using index-provider) as the main indexer. This indexer is used to fetch the rank and coins from. The other source is only used to update the percent change in price for several periods for.

Because there can be a lot of updates in the background, the notify-succesfull-update can be set to False to prevent receiving a lot of notifications only reporting the update was succesfull. For warnings and errors, or other exceptions, a notification is always send (if configured).

NOTE: configure the timeinterval correctly. Each section has it's own timeinterval and will be examined based on each timeinterval as configured in settings. So, a section timeinterval should be equal or multiply of the timeinterval configured in settings.

Author of this script is amargedon.

Configuration

This is the layout of the config file used by the marketcollector.py bot helper:

  • [settings]

  • timezone - timezone. (default is 'Europe/Amsterdam')

  • timeinterval - update timeinterval in seconds. (default is 86400)

  • debug - set to True to enable debug logging to file. (default is False)

  • debug-log-query - set to True to log SQL queries. (default is False)

  • logrotate - number of days to keep logs. (default = 7)

  • cmc-apikey - your CoinMarketCap API key value.

  • cg-apikey - your CoinGecko API key value if you have a paid plan (not required).

  • index-provider - default index to use (CoinMarketCap or CoinGecko).

  • notifications - set to true to enable notifications. (default = False)

  • notify-urls - one or a list of apprise notify urls, each in " " seperated with commas. See Apprise website for more information.

  • [cmc_btc]

  • start-number - start number for the pairs to request (exclude first x). (default is 1)

  • end-number - end number for the pairs to request. (default is 200)

  • timeinterval - update timeinterval in seconds for this specific section. (default is 86400)

  • percent-change-compared-to - what to compare the percent change to (BTC, ETH, EUR or USD).

  • notify-succesful-update - send notification using Apprise on succesful update. (default = True)

  • [cg_btc]

  • start-number - start number for the pairs to request (exclude first x). (default is 1)

  • end-number - end number for the pairs to request. (default is 200)

  • timeinterval - update timeinterval in seconds for this specific section. (default is 86400)

  • percent-change-compared-to - what to compare the percent change to (BTC, ETH, EUR or USD).

  • notify-succesful-update - send notification using Apprise on succesful update. (default = True)

  • request-delay-sec - number of seconds between each request when fetching more than 250 coins. This property is not required in the configuration. (default = 1)

  • ratelimit-retry-sec - number of seconds to retry on after receiving a rate limit (429) error. This property is not required in the configuration. (default = 60)

  • [altrank_default]

  • timeinterval - update timeinterval in seconds for this specific section. (default is 86400)

  • lc-apikey - your LunarCrush API key value.

  • lc-fetchlimit - number of entries to fetch.

  • notify-succesful-update - send notification using Apprise on succesful update. (default = True)

  • [volatility_default]

  • timeinterval - update timeinterval in seconds for this specific section. (default is 86400)

  • lists - list with one or more list names. (default is "binance_spot_busd_highest_volatility_day", "binance_spot_usdt_highest_volatility_day", "coinbase_spot_usd_highest_volatility_day")

  • notify-succesful-update - send notification using Apprise on succesful update. (default = True)

Example: (keys are bogus)

[settings]
timezone = Europe/Amsterdam
timeinterval = 86400
debug = False
debug-log-query = False
logrotate = 14
cmc-apikey = 4czrn2yo3la4h4179grp2
cg-apikey = 
index-provider = CoinMarketCap
notifications = True
notify-urls = [ "tgram://9995888120:BoJPor6opeHyxx5VVZPX-BoJPor6opeHyxx5VVZPX/" ]

[cmc_btc]
start-number = 1
end-number = 200
timeinterval = 86400
percent-change-compared-to = BTC
notify-succesful-update = True

[cmc_usd]
start-number = 1
end-number = 200
timeinterval = 86400
percent-change-compared-to = USD
notify-succesful-update = True

[cg_usd]
start-number = 1
end-number = 200
timeinterval = 3600
percent-change-compared-to = USD
notify-succesful-update = True

[altrank_default]
timeinterval = 86400
lc-apikey = 1234
lc-fetchlimit = 200
notify-succesful-update = True

[galaxyscore_default]
timeinterval = 86400
lc-apikey = 1234
lc-fetchlimit = 200
notify-succesful-update = True

[volatility_default]
timeinterval = 86400
lists: ['binance_spot_busd_highest_volatility_day', 'binance_spot_usdt_highest_volatility_day', 'coinbase_spot_usd_highest_volatility_day']
notify-succesful-update = False

Example output

MarketCollector