Exemplo n.º 1
0
Arquivo: JQ4LL.py Projeto: Ceilopty/LL
 def _auth():
     # Sensitive information is saved separately. Load & Delete to keep them safe.
     from _AUTH import AUTH_ID, AUTH_PASSWORD
     # For many reason such as poor network connection, auth session may fail.
     try:
         jq.auth(AUTH_ID, AUTH_PASSWORD) if not jq.is_auth() else None
     except Exception as e:
         print(f'AUTH FAILED {e}')
     del AUTH_ID, AUTH_PASSWORD
Exemplo n.º 2
0
 def login(self):
     if not self.is_logged_in:
         with utils.NullPrinter():
             jq.auth(self.mobile, self.password)
         if jq.is_auth():
             self.is_logged_in = True
         else:
             raise ValueError(
                 'JQDataLoginError: Wrong mobile number or password')
Exemplo n.º 3
0
 def log(self):
     """
     登录
     :return:
     """
     flog.FinanceLoger.logger.info("准备登录聚宽数据")
     jq.auth(self.conf["JQData"]["UserName"], self.conf["JQData"]["Pwd"])
     self.log_status = jq.is_auth()
     flog.FinanceLoger.logger.info("登录结果:{0}".format(self.log_status))
Exemplo n.º 4
0
def login(user_name, password):
    try:
        jq.auth(user_name, password)
    except Exception as e:
        logger.info(e)
        return False
    # 判断是否登录成功
    if not jq.is_auth():
        return False
    return True
Exemplo n.º 5
0
 def __init__(self, account, password, retry=3, timeout=30, interval=0.5):
     self.login_status = False
     self.account = account
     self.password = password
     self.retry = retry
     self.timeout = timeout
     self.interval = interval
     jq.auth(self.account, self.password)
     if jq.is_auth():
         self.login_status = True
Exemplo n.º 6
0
 def init(self, username=None, password=None):
     if (username == None):
         username = str(input('RD Username:'))
     if (password == None):
         password = str(input("RD Password : "******"Log : jq auth login", self.name)
         self.login = True
     else:
         self.log.log("ERROR : jq login fail", self.name)
Exemplo n.º 7
0
def pytest_sessionstart(session):
    logging.basicConfig(
        stream=sys.stdout,
        level=logging.DEBUG,
        format="%(asctime)s - %(levelname)s - %(message)s",
    )

    proj_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
    sys.path.insert(0, proj_dir)

    import jqdatasdk
    client = jqdatasdk.JQDataClient.instance()
    client.ensure_auth()
    assert jqdatasdk.is_auth()
Exemplo n.º 8
0
 def connect(self):
     try:
         self.conn = connect(host=self.cfg.host,
                             user=self.cfg.user,
                             password=self.cfg.pwd,
                             database=self.cfg.db,
                             charset="UTF-8")
         self.conn.autocommit(True)
         self.cur = self.conn.cursor()
         if not self.cur:
             return False
         jq.auth(self.cfg.jqUser, self.cfg.jqPwd)
         return jq.is_auth()
     except:
         return False
Exemplo n.º 9
0
def getJQTickData(jqID, intSDate, intEDate=0):
    if not jq.is_auth():
        return None
    if intEDate == 0:
        intEDate = nextIntDay(intSDate)
    tickPdData = jq.get_ticks(jqID,
                              start_dt=str(intSDate),
                              end_dt=str(intEDate),
                              count=None)
    tickPdData.rename(columns={
        'time': 'tm',
        'current': 'clast',
        'money': 'amnt'
    },
                      inplace=True)
    tickPdData.insert(0, 'id', jqID)
    return tickPdData
Exemplo n.º 10
0
def jq_auth():
    try:
        global jq_index
        account = 'jq_username{}'.format(jq_index)
        password = '******'.format(jq_index)
        if not is_auth():
            logger.info("auth with {}:{}".format(zvt_env[account],
                                                 zvt_env[password]))
            auth(zvt_env[account], zvt_env[password])
        else:
            logger.info("already auth, attempt with {}:{}".format(
                zvt_env[account], zvt_env[password]))
        return True
    except Exception as e:
        logger.warning(
            f'joinquant account not ok,the timestamp(publish date) for finance would be not correct',
            e)
    return False
Exemplo n.º 11
0
import jqdatasdk as jq

from ths_slj.config import JQ_CONFIG, DATA_PATH

train_start_date = '2017-01-01'
train_end_date = '2018-12-31'

padding = 150
test_start_date = '2019-01-01'
test_end_date = '2019-12-31'

if __name__ == '__main__':


    if not jq.is_auth():
        jq.auth(JQ_CONFIG.get('id'), JQ_CONFIG.get('password'))

    codes = jq.get_index_stocks('000852.XSHG', date=test_end_date)
    all_codes = jq.get_all_securities('stock')

    active_codes = []
    # 筛选所有的股票
    for code in codes:
        _temp = all_codes.loc[code]
        code_start = pd.Timestamp(_temp.start_date)
        code_end = pd.Timestamp(_temp.end_date)
        if code_start < pd.Timestamp(train_start_date) and code_end > pd.Timestamp(test_end_date):
            active_codes.append(code)

    # 剩余846只
Exemplo n.º 12
0
    import QUANTAXIS as QA
except:
    print('PLEASE run "pip install QUANTAXIS" to call these modules')
    pass

if __name__ == '__main__':
    #password = pd.DataFrame({'host':['jqdatasdk'],
    #    'username':['13981813381'],
    #    'password':['813381']}, columns=['host',
    #                                   'username', 
    #                                   'password'])
    # 用上面的代码保存密码到用户配置 .GolemQ 目录下面
    password = load_settings('password.hdf5')
    auth(password.username[0], password.password[0]) #ID是申请时所填写的手机号;Password为聚宽官网登录密码,新申请用户默认为手机号后6位
    asset = u'000001.XSHE'
    is_auth = is_auth()

    # 查询当日剩余可调用条数
    print(get_query_count())
    print(is_auth)
    codelist = ['000876']
    code = codelist[0]

    # 创建数据下载目录
    index_path = mkdirs(os.path.join(mkdirs('datastore'), 'kline', 'index'))
    print(index_path)

    for year in range(2005, 2017):
        start_date = '{}-01-01'
        end_date = '{}-01-02'
        for code in indexlist:
Exemplo n.º 13
0
# outside module
import random
import numpy as np
import pandas as pd
import statsmodels.api as sm
import linearmodels
from loguru import logger
import matplotlib.pyplot as plt
import datetime
from jqdatasdk import auth, is_auth, get_price

auth("18622056381", "1510103Yhw")
logger.info("Connected to JQData: {}".format(is_auth()))

# inside module
from Utils import format_for_print
from Pipeline import rets, sector_rets, market_cap_raw_value, market_cap, pe, pe_lyr, pb, ps, pcf, turnover

# In sample fit
X_in = pd.concat([
    market_cap.stack(),
    pe.stack(),
    pe_lyr.stack(),
    pb.stack(),
    ps.stack(),
    pcf.stack(),
    turnover.stack()
],
                 axis=1)
X_in.columns = ["market_cap", "pe", "pe_lyr", "pb", "ps", "pcf", "turnover"]
y_in = rets.stack()
Exemplo n.º 14
0
def jq_get_query_count():
    if is_auth():
        count = get_query_count()
        return count['spare']
    return 0
Exemplo n.º 15
0
Arquivo: JQ4LL.py Projeto: Ceilopty/LL
 def _get_count(self):
     self._count = jq.get_query_count() if jq.is_auth() else None
Exemplo n.º 16
0
                          open_interest=open_interest,
                          gateway_name="DB")
            bars.append(bar)
        print("save size:%d" % bars.__len__())
        database_manager.save_bar_data(bars)
        batch_start = batch_end  #+ timedelta(days = 1)
        pass


# start main

start_day = datetime.strptime("2018-03-29", "%Y-%m-%d")
end_day = datetime.strptime("2020-03-29", "%Y-%m-%d")
database_manager.clean("600519.")

if (not jq.is_auth()):
    jq.auth('13530336157',
            'Qwer4321')  #ID是申请时所填写的手机号;Password为聚宽官网登录密码,新申请用户默认为手机号后6位

if (not jq.is_auth()):
    print('jq is not auth,exist')
    exit()
print('jq is auth')

code = '600519'
database_manager.clean(code)
save_bar_data_from_jqdata(code,
                          Interval.MINUTE,
                          start_date=start_day,
                          end_date=end_day)
Exemplo n.º 17
0
 def __init__(self):
     if not jq.is_auth():
         jq.auth('15982102544', 'kevinxli_035')
Exemplo n.º 18
0
                     end_date='2015-12-02 12:00:00',
                     frequency='1m'))


def before_trading_start(context):
    print('##### before_trading_start #####')


def handle_tick(context, tick):
    print('##### handle_tick #####')
    print(tick.current)
    # order('600519.XSHG', 100)


def after_trading_end(context):
    print('##### after_trading_end #####')
    unsubscribe_all()


# 初始化jqdatasdk
jq.auth('13011026551', 'ize4sg')
# 查询是否连接成功
is_auth = jq.is_auth()
# 初始化实盘模块
init_trader(g, context, '63310050878', '550660', 29, r'D:\中泰证券独立下单\xiadan.exe')
# init_trader(g, context, '100301002901', '147258', 1 , r'D:\中泰证券独立下单\xiadan.exe')
print("登陆账号成功")
# 初始化实时tick行情
init_current_bundle(initialize, before_trading_start, after_trading_end,
                    handle_tick)
Exemplo n.º 19
0
 def is_auth(self):
     return jqdatasdk.is_auth()