TopPairsReply#
API documentation for tradingstrategy.top.TopPairsReply Python class in Trading Strategy framework.
- class TopPairsReply[source]#
Bases:
object
/top endpoint reply.
Get a list of trading pairs, both included and excluded
- __init__(included, excluded)#
- Parameters:
included (list[tradingstrategy.top.TopPairData]) –
excluded (list[tradingstrategy.top.TopPairData]) –
- Return type:
None
Methods
__init__
(included, excluded)Make base token address lookupable data.
find_pair_data_for_token
(token_address)Get token data.
from_dict
(kvs, *[, infer_missing])from_json
(s, *[, parse_float, parse_int, ...])schema
(*[, infer_missing, only, exclude, ...])to_dict
([encode_json])to_json
(*[, skipkeys, ensure_ascii, ...])Attributes
The top list at the point of time the request was made
Tokens that were considered for top list, but excluded for some reason
- included: list[tradingstrategy.top.TopPairData]#
The top list at the point of time the request was made
- excluded: list[tradingstrategy.top.TopPairData]#
Tokens that were considered for top list, but excluded for some reason
They had enough liquidity, but they failed e.g. TokenSniffer scam check, or had a trading pair for the same base token with better fees, etc.
- as_token_address_map()[source]#
Make base token address lookupable data.
Includes both excluded and included pairs. Included takes priority if multiple pairs.
- Returns:
Map with all token addresses lowercase.
- Return type:
- find_pair_data_for_token(token_address)[source]#
Get token data.
Can be excluded or included pair
If there are multiple trading pairs for the same token, get the first one
Example:
import logging import sys from tradingstrategy.chain import ChainId from tradingstrategy.client import Client from tradingstrategy.top import TopPairMethod logging.basicConfig( level=logging.INFO, stream=sys.stdout, ) client = Client.create_live_client() chain_id = ChainId.binance token_address = "0xb1aed8969439efb4ac70d7397ba90b276587b27d" token_addresses = {token_address} top_pair_reply = client.fetch_top_pairs( {chain_id}, addresses=token_addresses, method=TopPairMethod.by_token_addresses, min_volume_24h_usd=0, risk_score_threshold=0, ) pair_data = top_pair_reply.find_pair_data_for_token(token_address) print(pair_data)
- Parameters:
token_address (str) –
- Return type:
- __init__(included, excluded)#
- Parameters:
included (list[tradingstrategy.top.TopPairData]) –
excluded (list[tradingstrategy.top.TopPairData]) –
- Return type:
None