CONFIG_PARSER = configparser.ConfigParser() CONFIG_PARSER.read("gtja_trade.ini", encoding="utf-8") ACCOUNT_NAME = CONFIG_PARSER['Account'].get('account_name') PASSWORD = CONFIG_PARSER['Account'].get('password') CONNECTION_STRING = CONFIG_PARSER['Database'].get('connection') LOGGING_PATH = CONFIG_PARSER["Logging"].get("path") # logger setup logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) logging.getLogger('selenium.webdriver.remote.remote_connection').setLevel( logging.WARNING) # set the DB connection string stock_db.db_connection.default_connection_string = CONNECTION_STRING STOCK_PROCESSOR = StockProcessor(ACCOUNT_NAME, PASSWORD) logging.info("account: " + ACCOUNT_NAME) logging.info("password: "******"600115", "601390", "600584", "000568", "601998", "002367", "601111", "601398", "600019", "601857" ]) def is_transaction_time(): '''
# logger setup logger = logging.getLogger() logger.setLevel(logging.DEBUG) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) logging.getLogger('selenium.webdriver.remote.remote_connection').setLevel(logging.WARNING) fh = logging.FileHandler(logging_filename, encoding="utf-8") formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.addHandler(fh) # set the DB connection string stock_db.db_connection.default_connection_string = connection_string #commission_id = trade.get_last_commission_id("601398", 100) stock_processor = StockProcessor(account_name, password) print(account_name, password) stock_processor.login() time.sleep(3) stock_processor.set_stock_symbol_list(["600115"]) def is_transaction_time(): td = datetime.datetime.now() t1 = td.time() t2 = datetime.time(9,30,0) t3 = datetime.time(11,30,0) t4 = datetime.time(13,0,0) t5= datetime.time(15,0,0)
# read configuration config = configparser.ConfigParser() config.read("gtja_trade.ini", encoding="utf-8") account_name = config['Account'].get('account_name') password = config['Account'].get('password') connection_string = config['Database'].get('connection') # set the DB connection string stock_db.db_connection.default_connection_string = connection_string #commission_id = trade.get_last_commission_id("601398", 100) #test stock_processor = StockProcessor(account_name, password) print(account_name, password) #stock_processor.login() #time.sleep(3) symbol_list = ['600115'] stock_processor.set_stock_symbol_list(["600115"]) for symbol in symbol_list: total = stock_processor.get_stock_current_value(symbol) print("Stock symbol: {0}\t\tTotal Value: {1}".format(symbol, total)) stock_processor.close()
# logger setup LOGGER = logging.getLogger() LOGGER.setLevel(logging.DEBUG) logging.getLogger('sqlalchemy.engine').setLevel(logging.WARNING) logging.getLogger('selenium.webdriver.remote.remote_connection').setLevel(logging.WARNING) FH = logging.FileHandler(LOGGING_FILENAME, encoding="utf-8") FORMATTER = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') FH.setFormatter(FORMATTER) LOGGER.addHandler(FH) # set the DB connection string stock_db.db_connection.default_connection_string = CONNECTION_STRING #commission_id = trade.get_last_commission_id("601398", 100) STOCK_PROCESSOR = StockProcessor(ACCOUNT_NAME, PASSWORD) print(ACCOUNT_NAME, PASSWORD) STOCK_PROCESSOR.login() time.sleep(3) STOCK_PROCESSOR.set_stock_symbol_list( ["600115", "601390", "600584", "000568", "601998", "002367", "601111", "601398", "600019", "601857"]) def is_transaction_time(): ''' is_transaction_time ''' time_now = datetime.datetime.now()