コード例 #1
0
def macd(cus_ticker_list):
    print("*******************************************************")
    print("Running MACD...")
    print("Get MACD on:")
    print("1) Hang Seng Index")
    print("2) Stocks")
    print("3) User Portfolio")
    ope = input()
    if ope == '1':
        macd_HSI()
    elif ope == '2':
        print("Stock ticker(e.g. 0001.HK): ")
        ticker = stock.tick_process(input("[Type 'hk' for Hong Kong tickers; 'us' for USA; 'cn' for China]"))
        if ticker == 'hk':
            stock.check_ticker_by_country('Hong Kong')
        elif ticker == 'us':
            stock.check_ticker_by_country('USA')
        elif ticker == 'cn':
            stock.check_ticker_by_country('China')
        elif ticker == '':
            print("Invalid ticker!")
        else:
            print("\n")
            macd_stocks(ticker)
    elif ope == '3':
        if len(cus_ticker_list) > 0:
            for tk in cus_ticker_list:
                macd_stocks(tk)
        else:
            print("No stock data!")

    print("Finish")
    print("\n")
コード例 #2
0
def kdj(cus_ticker_list):
    print("*******************************************************")
    print("Running Stochastic with %J...")
    print("Get KDJ on:")
    print("1) Stocks")
    print("2) User Portfolio")
    ope = input()
    if ope == '1':
        print("Stock ticker(e.g. 0001.HK): ")
        ticker = stock.tick_process(
            input(
                "[Type 'hk' for Hong Kong tickers; 'us' for USA; 'cn' for China]"
            ))
        if ticker == 'hk':
            stock.check_ticker_by_country('Hong Kong')
        elif ticker == 'us':
            stock.check_ticker_by_country('USA')
        elif ticker == 'cn':
            stock.check_ticker_by_country('China')
        elif ticker == '':
            print("Invalid ticker!")
        else:
            print("\n")
            cal_plot_kdj(ticker)
    elif ope == '2':
        if len(cus_ticker_list) > 0:
            for tk in cus_ticker_list:
                cal_plot_kdj(tk)
        else:
            print("No stock data!")

    print("Finish")
    print("\n")
コード例 #3
0
def psar(cus_ticker_list):
    print("*******************************************************")
    print("Running Parabolic Stop and Reverse...")
    print("Get Parabolic SAR on:")
    print("1) Stocks")
    print("2) User Portfolio")
    ope = input()
    if ope == '1':
        print("Stock ticker(e.g. 0001.HK): ")
        ticker = stock.tick_process(
            input(
                "[Type 'hk' for Hong Kong tickers; 'us' for USA; 'cn' for China]"
            ))
        if ticker == 'hk':
            stock.check_ticker_by_country('Hong Kong')
        elif ticker == 'us':
            stock.check_ticker_by_country('USA')
        elif ticker == 'cn':
            stock.check_ticker_by_country('China')
        elif ticker == '':
            print("Invalid ticker!")
        else:
            print("\n")
            print("Enter the Step and Max. Step (sepearted by ','):")
            step_max_step = input("[Enter d to use default: .02, .2] ")
            if step_max_step == 'd':
                cal_plot_psar(ticker)
            else:
                step, max_step = step_max_step.split(',')
                step = step.strip().replace('.', '', 1)
                max_step = max_step.strip().replace('.', '', 1)
                if step.isdigit() and max_step.isdigit():
                    cal_plot_psar(ticker, float(step), float(max_step))
                else:
                    print("Invalid Input!")
    elif ope == '2':
        print("Enter the Step and Max. Step (sepearted by ','):")
        step_max_step = input("[Enter d to use default: .02, .2] ")
        if step_max_step == 'd':
            if len(cus_ticker_list) > 0:
                for tk in cus_ticker_list:
                    cal_plot_psar(tk)
            else:
                print("No stock data!")
        else:
            step, max_step = step_max_step.split(',')
            step = step.strip().replace('.', '', 1)
            max_step = max_step.strip().replace('.', '', 1)
            if step.isdigit() and max_step.isdigit():
                if len(cus_ticker_list) > 0:
                    for tk in cus_ticker_list:
                        cal_plot_psar(tk, float(step), float(max_step))
                else:
                    print("No stock data!")
            else:
                print("Invalid Input!")
    print("Finish")
    print("\n")
コード例 #4
0
def cci(cus_ticker_list):
    print("*******************************************************")
    print("Running Commodity Channel Index...")
    print("Get CCI on:")
    print("1) Stocks")
    print("2) User Portfolio")
    ope = input()
    if ope == '1':
        period = input("Enter the number of days for CCI period: ")
        if period.isdigit():
            print("Stock ticker(e.g. 0001.HK): ")
            ticker = stock.tick_process(input("[Type 'hk' for Hong Kong tickers; 'us' for USA; 'cn' for China]"))
            if ticker == 'hk':
                stock.check_ticker_by_country('Hong Kong')
            elif ticker == 'us':
                stock.check_ticker_by_country('USA')
            elif ticker == 'cn':
                stock.check_ticker_by_country('China')
            elif ticker == '':
                print("Invalid ticker!")
            else:
                print("\n")
                cal_plot_cci(ticker, str(period))
        else:
            print("Invalid period!")
    elif ope == '2':
        period = input("Enter the number of days for CCI period: ")
        if period.isdigit():
            if len(cus_ticker_list) > 0:
                for tk in cus_ticker_list:
                    cal_plot_cci(tk, str(20))
            else:
                    print("No stock data!")
        else:
            print("Invalid period!")

    print("Finish")
    print("\n")