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() # another testqq
time_now = datetime.datetime.now() time_1 = time_now.time() time_2 = datetime.time(15, 0, 0) return bool(time_1 > time_2) while True: T = datetime.datetime.now() logging.debug(T) # check time if is_market_closed(): logging.info("market is closed!") break if not is_transaction_time(): logging.info("It's not transaction time now!") STOCK_PROCESSOR.keep_alive() time.sleep(60) continue STOCK_SYMBOL = STOCK_PROCESSOR.get_one_stock() STOCK_PROCESSOR.process_stock(STOCK_SYMBOL) time.sleep(59) update_keep_alive(app_name=APP_NAME) STOCK_PROCESSOR.close()
return bool(time_1 > time_2) while True: T = datetime.datetime.now() print(T) # check time if is_market_closed(): print("market is closed!") break if not is_transaction_time(): print("It's not transaction time now!") STOCK_PROCESSOR.keep_alive() time.sleep(60) continue STOCK_SYMBOL = STOCK_PROCESSOR.get_one_stock() STOCK_PROCESSOR.process_stock(STOCK_SYMBOL) time.sleep(59) # commission_id = STOCK_PROCESSOR.trade.buy_stock("601398", 4.20, 100) # STOCK_PROCESSOR.trade.cancel_commission(216527) # print(commission_id) #commission_id = trade.sell_stock("601398", 5.12, 200) STOCK_PROCESSOR.close()