Git Product home page Git Product logo

chan_lun_py's Introduction

chan_lun_util_py

A personal implement of Chan-Lun in Python, which is popular among Chinese stock investors. Just for fun.

For more detail: https://www.joinquant.com/post/4739

chan_lun_util.py 在joinquant上使用分笔功能的demo:

    from chan_lun_util import *
    import matplotlib as mat
    import numpy as np
    import datetime as dt
    import matplotlib.pyplot as plt
    import time

    start_date='2016-02-05'
    end_date='2017-02-07'
    stock_code = '601318.XSHG'
    df = get_price(stock_code, start_date, end_date, frequency='daily', fields=['open','close','high', 'low'],skip_paused=False,fq='pre')

    date_list = df.index.tolist()
    data_per_day = df.values.tolist()

    k_line_list = []
    ''' 将dataframe数据组装进入KLineDTO的列表中 '''
    for index in range(len(date_list)):
        date_time = date_list[index]
        open_price = data_per_day[index][0]
        close_price = data_per_day[index][1]
        high_price = data_per_day[index][2]
        low_price = data_per_day[index][3]
        k_line_dto = KLineDTO(date_time,
                                  date_time,
                                  date_time,
                                  open_price, high_price, low_price, close_price)
        k_line_list.append(k_line_dto)

    len(k_line_list)

    '''1.K线合并,确定顶分型和底分型,得出合并K线列表merge_line_list '''
    merge_line_list = find_peak_and_bottom(k_line_list, "down")

    '''2.分笔'''
    fenbi_result,final_result_array,fenbi_seq_list = fen_bi(merge_line_list)

其中:

  1. fenbi_result为boolean,True的话就是分笔成功了;False就是分笔失败后面的final_result_array和fenbi_seq_list都不用看了。
  2. final_result_array,fenbi_seq_list:如果final_result_array[i]为True,则对于merge_line_list来说,merge_line_list[fenbi_seq_list[i]]就为最终顶或者底对应的合并K线dto

chan_lun_py's People

Contributors

imspzero avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.