def main(symbol: str, **kwargs): alog.set_level(logging.DEBUG) channels = [ # InstrumentChannels.quote, InstrumentChannels.trade, InstrumentChannels.orderBookL2 ] instrument = Instrument( symbol=symbol, channels=channels, **kwargs ) instrument.run_forever()
from os.path import join import logging import os import alog ######################################################################################################################## # Connection/Auth ######################################################################################################################## # API URL. BASE_URL = '' if os.environ.get('RUN_ENV') == 'development': BASE_URL = "https://testnet.bitmex.com/api/v1/" else: BASE_URL = "https://www.bitmex.com/api/v1/" # The BitMEX API requires permanent API keys. Go to https://testnet.bitmex.com/api/apiKeys to fill these out. #BITMEX_API_KEY = os.environ.get('BITMEX_API_KEY') BITMEX_API_KEY = "VjcxqcfTxwBPPluMIYkp0H_9" #BITMEX_API_SECRET = os.environ.get('BITMEX_API_SECRET') BITMEX_API_SECRET = "5J_jfDms6Cdw34Y5d9NWleZW3Z0dMZ7Npqksc4IkqK3qQBfj" # Available levels: logging.(DEBUG|INFO|WARN|ERROR) # LOG_LEVEL = os.environ.get('LOG_LEVEL') LOG_LEVEL = logging.INFO alog.set_level(LOG_LEVEL)
def test_set_level(self): alog.set_level("WARNING") assert alog.get_level() == logging.WARNING
#!/usr/bin/env python from bitmexPackage.bitmexWSDataHandle import BitMexDataHandle from bitmexPackage.mysqlDataHandle import MysqlDataHandle from bitmexPackage.Strategy import StrategyHandle from bitmexPackage.FibonacciStrategy import FibonacciStrategy from bitmexPackage.bitmexAccountSettings import bitmexAccountSettings import signal signal.signal(signal.SIGWINCH, signal.SIG_IGN) import queue import time import threading import alog print = alog.info debug = alog.debug alog.set_level(5) import time,datetime # import tulipy as ti import numpy as np import sqlite3,json # import contextlib # import pymysql.cursors from decimal import Decimal g = bitmexAccountSettings() g.from_config_file('luanlan') event_q = queue.PriorityQueue(0) datahandler = BitMexDataHandle(g) datahandler.set_symbols(['XBTUSD']) datahandler.add_event_engine(event_q)
import alog import logging import signal import websocket class Ticker(Instrument): def __init__(self, symbol='XBTUSD', **kwargs): websocket.enableTrace(True) channels = [ InstrumentChannels.quote, ] super().__init__(symbol=symbol, channels=channels, **kwargs) def on_action(self, message): alog.info(alog.pformat(message['data'])) def main(): emitter = Ticker('XBTUSD') emitter.run_forever() if __name__ == '__main__': alog.set_level(logging.DEBUG) signal.signal(signal.SIGINT, lambda: exit(0)) signal.signal(signal.SIGTERM, lambda: exit(0)) main()
return parser if __name__ == '__main__': md = HackMDNotify(DATABASE_PATH) md.load_db() parser = parse_args() args = parser.parse_args() md.threshold_words = args.words md.threshold_minutes = args.minutes if args.init_db: alog.info('Init database') md.init_db() md.save_db() elif args.import_hackmd: alog.info('Start parsing HackMD') md.parse_from_homework(args.import_hackmd) alog.info('Done, save the result to database') md.save_db() elif args.check_update: alog.info('Start to check all works in database') alog.set_level('CRITICAL') md.check_works_update() alog.set_level('INFO') alog.info('Done, save the update result to database') md.save_db() else: parser.print_help()