Пример #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ETF历史数据
"""

import numpy as np
from uqer import Client, DataAPI
import sys
sys.path.append(r'D:\CXM\Project\SQLLINK')
sys.path.append(r'D:\CXM\Project\ScenarioAnalysis')
import SASQL
import Constant

login = Client(token=Constant.token)
df_all = DataAPI.FundGet(etfLof="ETF", listStatusCd="L", field="", pandas="1")
df = df_all[(df_all.tradeAbbrName.str.contains('上证50ETF') == True) |
            (df_all.tradeAbbrName.str.contains('中证500ETF') == True) |
            (df_all.tradeAbbrName.str.contains('沪深300ETF') == True)][[
                'secID', 'tradeAbbrName'
            ]]
#
dbsa = SASQL.ScenarioAnalysis()
#
#
col_query = "select name from syscolumns where id = object_id('{}')".format(
    'HistData_Stock')
cols = dbsa.ExecQuery(col_query)

for i in range(0, df.shape[0]):
    # query = "delete from HistData_Stock where InstrumentID=''".format(df.iat[i,0])
Пример #2
0
 def connect(self):
     if not self.is_connected():
         self.client = Client(token=self.token)
Пример #3
0
from uqer import Client

uqer = Client(username='******', password='******')

#files = uqer.list_data()
#print(files)
uqer.download_data('HKI.csv')
uqer.download_data(filename='HKRawQ/HKD2CNY.csv')
uqer.download_data(filename='HKRawQ/USD2CNY.csv')

tickers = [
    '00811', '00902', '00939', '00966', '00998', '01071', '01177', '01288',
    '01336', '01339', '01398', '01816', '01918', '01963', '01988', '02318',
    '02328', '02333', '02601', '02799', '02883', '03328', '03618', '03899',
    '03900', '03968', '03988', '06818'
]
#for ticker in tickers:
#    uqer.download_data( filename='HKQuotes/HK{0}.txt'.format(ticker) )

for ticker in tickers:
    uqer.download_data(filename='HKRawQ/{0}.csv'.format(ticker))

#uqer.download_data( 'StocksFin2B.xlsx' )

#import mercury

#uqer = mercury.Client(uqername, uqerpwd)
## all_files = uqer.list_data()
#uqer.download_data(filename)
Пример #4
0
from uqer import Client

uqer = Client(username='******', password='******')

#files = uqer.list_data()
#print(files)

#tickers = ['00811','00902','00939','00966','00998', '01071', '01177','01288','01336','01339','01398','01816','01918','01988',
#           '02318','02328','02333','02601','02883','03328','03618','03899','03968','03988','06818']
##for ticker in tickers:
##    uqer.download_data( filename='HKQuotes/HK{0}.txt'.format(ticker) )
#
#for ticker in tickers:
#    uqer.download_data( filename='HKRawQ/{0}.csv'.format(ticker) )
#
#uqer.download_data( filename='HKRawQ/HKD2CNY.csv' ) 
#uqer.download_data( 'HKI.csv' )

uqer.download_data( 'StocksSelB.xlsx' )
#uqer.download_data( 'selected_stocks.csv' )
Пример #5
0
# -*- coding: utf-8 -*-

from uqer import Client
import pandas as pd

uqer = Client(username='******', password='******')

#files = uqer.list_data()
#print(files)
uqer.download_data( 'HKI.csv' )
uqer.download_data( filename='HKRawQ/HKD2CNY.csv' ) 
uqer.download_data( filename='HKRawQ/USD2CNY.csv' ) 
uqer.download_data( filename='HKRawQ/SHHK.csv' ) 

HKD2CNY = pd.read_csv('D:\\GitHub\\QuantSamples\\HK\\HKRawQ\\HKD2CNY.csv', delimiter=',',usecols=[1,2], parse_dates=[0],index_col=[0])
SHHK = pd.read_csv('D:\\GitHub\\QuantSamples\\HK\\HKRawQ\\SHHK.csv', delimiter=',',usecols=[1,2,3], parse_dates=[0],index_col=[0])
SHHK['midRate'] = ( SHHK['stlBid'] + SHHK['stlAsk'] ) * 0.5

HKD2CNY = HKD2CNY[HKD2CNY.index < SHHK.index[0]]
SHHK = SHHK[['midRate']]

SHHK = pd.concat( [HKD2CNY,SHHK] , axis=0 )

SHHK.to_csv('D:\\GitHub\\QuantSamples\\HK\\HKRawQ\\SHHKEX.csv',encoding='gbk', float_format='%.5f' , date_format='%Y-%m-%d')


tickers = ['00811','00902','00939','00966','00998', '01071', '01177','01288','01336','01339','01398','01816','01918','01963','01988',
           '02318','02328','02333','02601','02799','02883','03328','03618','03899','03900','03968','03988','06818']
#for ticker in tickers:
#    uqer.download_data( filename='HKQuotes/HK{0}.txt'.format(ticker) )