[增强功能] tdx下载普通合约;增加远程服务器文件访问;股票砖图支持使用1分钟生成
This commit is contained in:
parent
fb8bd779b2
commit
74d156b3ae
@ -16,7 +16,7 @@ from vnpy.data.renko.rebuild_stock import *
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
print(u'请输入三个参数 host symbol pricetick')
|
||||
print(u'请输入三个参数 host symbol pricetick [ bar]')
|
||||
exit()
|
||||
print(sys.argv)
|
||||
host = sys.argv[1]
|
||||
@ -24,14 +24,24 @@ if __name__ == "__main__":
|
||||
setting = {
|
||||
"host": host,
|
||||
"db_name": STOCK_RENKO_DB_NAME,
|
||||
"cache_folder": os.path.join(vnpy_root, 'tick_data', 'tdx', 'stock')
|
||||
"cache_folder": os.path.join(vnpy_root, 'tick_data', 'tdx', 'stock'),
|
||||
'bar_folder': os.path.join(vnpy_root,'bar_data')
|
||||
}
|
||||
builder = StockRenkoRebuilder(setting)
|
||||
|
||||
symbol = sys.argv[2]
|
||||
price_tick = float(sys.argv[3])
|
||||
if len(sys.argv) >= 5 and sys.argv[4] == 'bar':
|
||||
using_bar = True
|
||||
else:
|
||||
using_bar = False
|
||||
|
||||
print(f'启动期货renko补全,数据库:{host}/{STOCK_RENKO_DB_NAME} 合约:{symbol}')
|
||||
if using_bar:
|
||||
print(f'启动股票bar=> renko补全,数据库:{host}/{STOCK_RENKO_DB_NAME} 合约:{symbol}')
|
||||
builder.start_with_bar(symbol=symbol, price_tick=price_tick, height=['K3', 'K5', 'K10'])
|
||||
|
||||
else:
|
||||
print(f'启动股票tick=> renko补全,数据库:{host}/{STOCK_RENKO_DB_NAME} 合约:{symbol}')
|
||||
builder.start(symbol=symbol, price_tick=price_tick, height=['K3', 'K5', 'K10'], refill=True)
|
||||
|
||||
print(f'exit refill {symbol} renkos')
|
||||
|
@ -35,7 +35,7 @@ stock_list = load_json('stock_list.json')
|
||||
|
||||
symbol_dict = api_01.symbol_dict
|
||||
|
||||
# 逐一指数合约下载并更新
|
||||
# 逐一合约下载并更新
|
||||
for stock_code in stock_list:
|
||||
market_id = get_tdx_market_code(stock_code)
|
||||
if market_id == 0:
|
||||
@ -108,6 +108,5 @@ for stock_code in stock_list:
|
||||
|
||||
print(f'更新{stock_code} {stock_name} 数据 => 文件{bar_file_path}, 最后记录:{bars[-1]}')
|
||||
|
||||
|
||||
print('更新完毕')
|
||||
os._exit(0)
|
||||
|
@ -300,8 +300,13 @@ class TdxFutureData(object):
|
||||
if '.' in symbol:
|
||||
symbol = symbol.split('.')[0]
|
||||
tdx_symbol = symbol.upper().replace('_', '')
|
||||
tdx_symbol = tdx_symbol.replace('99', 'L9')
|
||||
underlying_symbol = get_underlying_symbol(symbol).upper()
|
||||
|
||||
if '99' in tdx_symbol:
|
||||
tdx_symbol = tdx_symbol.replace('99', 'L9')
|
||||
else:
|
||||
tdx_symbol = get_full_symbol(symbol).upper()
|
||||
|
||||
tdx_index_symbol = underlying_symbol + 'L9'
|
||||
vn_exchange = self._get_vn_exchange(underlying_symbol)
|
||||
|
||||
|
@ -1404,3 +1404,28 @@ def get_bars(csv_file: str,
|
||||
count += 1
|
||||
|
||||
return bars
|
||||
|
||||
|
||||
def get_remote_file(remote_ip, remote_file_path, mode='rb'):
|
||||
"""
|
||||
获取远程服务器的文件
|
||||
:param remote_ip: 服务器ip地址
|
||||
:param remote_file_path:服务器上文件路径
|
||||
:param mode: 打开文件目录
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
import paramiko
|
||||
pkey = '/home/trade/.ssh/id_rsa'
|
||||
key = paramiko.RSAKey.from_private_key_file(pkey)
|
||||
paramiko.util.log_to_file('log/paramiko.log')
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
# ssh.load_system_host_keys()
|
||||
ssh.connect(remote_ip, username='trade', pkey=key)
|
||||
sftp_client = ssh.open_sftp()
|
||||
remote_file = sftp_client.open(remote_file_path, mode)
|
||||
return remote_file
|
||||
except Exception as ex:
|
||||
print(u'打开远程目录异常:{}'.format(str(ex)))
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user