-
Notifications
You must be signed in to change notification settings - Fork 17
API Reference
Aaron edited this page Nov 9, 2021
·
6 revisions
ticker(symbols='BINANCE:BTCUSDT', save=False, database_name='database.db', split_symbols=False, verbose=False)
Returns a ticker object
- symbols (str | list: required) - Symbol(s) that you want to track
- save (bool: optional) - Save ticker data to SQlite database?
- database_name (str: optional) - If saving ticker data, specify database file name
- split_symbols (bool: optional) - If True, will split tracker data into separate tables
- verbose (bool: optional) - Sends update messages to console with the amount of updates received in the past 5 seconds
Starts new thread and makes websocket connection.
import time
from ticker import ticker
tick = ticker("BINANCE:BTCUSDT")
tick.start()
while (True): # Print out prices & volumes every 2 seconds
print(tick.states)
time.sleep(2)
Returns an object with all the ticker states with prices & volumes.
ticker.states # {'BINANCE:BTCUSDT': {'volume': 2089.98057, 'price': 67715.07, 'change': 189.24, 'changePercentage': 0.28}}
##### OR #####
ticker.states # {'BINANCE:BTCUSDT': {'volume': 2089.98057, 'price': 67715.07, 'change': 189.24, 'changePercentage': 0.28}, 'TVC:GOLD': {'volume': 0, 'price': 1823.84, 'change': -0.04, 'changePercentage': 0.0}}
Stops the ticker thread
By Hattorius 2021