[增强] 增加期货保证金
This commit is contained in:
parent
6a6a3408dd
commit
0ef6fc2151
@ -10,4 +10,4 @@ python -m pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-a
|
|||||||
python -m pip install -r requirements.txt
|
python -m pip install -r requirements.txt
|
||||||
|
|
||||||
:: Install vn.py
|
:: Install vn.py
|
||||||
python -m pip install .
|
:: python -m pip install .
|
||||||
|
@ -42,4 +42,4 @@ $python -m pip install -r requirements.txt
|
|||||||
locale-gen zh_CN.GB18030
|
locale-gen zh_CN.GB18030
|
||||||
|
|
||||||
# Install vn.py
|
# Install vn.py
|
||||||
$python -m pip install . $@
|
# $python -m pip install . $@
|
||||||
|
103
vnpy/api/ctp/setup.py
Normal file
103
vnpy/api/ctp/setup.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import platform
|
||||||
|
|
||||||
|
from setuptools import Extension, setup
|
||||||
|
|
||||||
|
# 编译前
|
||||||
|
# pip install -U setuptools,pybind11
|
||||||
|
# 在ctp目录下,
|
||||||
|
# activate py37
|
||||||
|
# python setup.py build
|
||||||
|
dir_path = "ctp"
|
||||||
|
runtime_library_dirs = []
|
||||||
|
if platform.uname().system == "Windows":
|
||||||
|
compiler_flags = [
|
||||||
|
"/MP", "/std:c++17", # standard
|
||||||
|
"/O2", "/Ob2", "/Oi", "/Ot", "/Oy", "/GL", # Optimization
|
||||||
|
"/wd4819" # 936 code page
|
||||||
|
]
|
||||||
|
extra_link_args = []
|
||||||
|
|
||||||
|
else:
|
||||||
|
compiler_flags = [
|
||||||
|
"-std=c++17", # standard
|
||||||
|
"-O3", # Optimization
|
||||||
|
"-Wno-delete-incomplete", "-Wno-sign-compare", "-pthread"
|
||||||
|
]
|
||||||
|
extra_link_args = ["-lstdc++"]
|
||||||
|
runtime_library_dirs = ["$ORIGIN"]
|
||||||
|
|
||||||
|
vnctpmd = Extension(
|
||||||
|
# 编译对象
|
||||||
|
"vnctpmd",
|
||||||
|
# 指定 vnctpmd 的位置
|
||||||
|
[
|
||||||
|
f"vnctp/vnctpmd/vnctpmd.cpp",
|
||||||
|
],
|
||||||
|
# 编译需要的头文件
|
||||||
|
include_dirs=[
|
||||||
|
f"include",
|
||||||
|
f"vnctp",
|
||||||
|
],
|
||||||
|
# 指定为c plus plus
|
||||||
|
language="cpp",
|
||||||
|
define_macros=[],
|
||||||
|
undef_macros=[],
|
||||||
|
# 依赖目录
|
||||||
|
library_dirs=[f"libs", f"."],
|
||||||
|
# 依赖项
|
||||||
|
libraries=["thostmduserapi_se", "thosttraderapi_se", ],
|
||||||
|
extra_compile_args=compiler_flags,
|
||||||
|
extra_link_args=extra_link_args,
|
||||||
|
depends=[],
|
||||||
|
runtime_library_dirs=runtime_library_dirs,
|
||||||
|
)
|
||||||
|
vnctptd = Extension(
|
||||||
|
"vnctptd",
|
||||||
|
[
|
||||||
|
f"vnctp/vnctptd/vnctptd.cpp",
|
||||||
|
],
|
||||||
|
include_dirs=[
|
||||||
|
f"include",
|
||||||
|
f"vnctp",
|
||||||
|
],
|
||||||
|
define_macros=[],
|
||||||
|
undef_macros=[],
|
||||||
|
library_dirs=[f"libs", f"."],
|
||||||
|
libraries=["thostmduserapi_se", "thosttraderapi_se"],
|
||||||
|
extra_compile_args=compiler_flags,
|
||||||
|
extra_link_args=extra_link_args,
|
||||||
|
runtime_library_dirs=runtime_library_dirs,
|
||||||
|
depends=[],
|
||||||
|
language="cpp",
|
||||||
|
)
|
||||||
|
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
# use pre-built pyd for windows ( support python 3.7 only )
|
||||||
|
ext_modules = [vnctptd, vnctpmd]
|
||||||
|
elif platform.system() == "Darwin":
|
||||||
|
ext_modules = []
|
||||||
|
else:
|
||||||
|
ext_modules = [vnctptd, vnctpmd]
|
||||||
|
|
||||||
|
pkgs = ['']
|
||||||
|
install_requires = []
|
||||||
|
setup(
|
||||||
|
name='ctp',
|
||||||
|
version='1.0',
|
||||||
|
description="good luck",
|
||||||
|
author='incenselee',
|
||||||
|
author_email='incenselee@hotmail.com',
|
||||||
|
license="MIT",
|
||||||
|
packages=pkgs,
|
||||||
|
install_requires=install_requires,
|
||||||
|
platforms=["Windows", "Linux", "Mac OS-X"],
|
||||||
|
package_dir={'ctp': 'ctp'},
|
||||||
|
package_data={'ctp': ['*', ]},
|
||||||
|
ext_modules=ext_modules,
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 4 - Beta',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
|
]
|
||||||
|
)
|
@ -9,7 +9,7 @@ from typing import Any, Callable
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from logging import INFO, ERROR, DEBUG
|
from logging import INFO
|
||||||
|
|
||||||
from vnpy.event import Event, EventEngine
|
from vnpy.event import Event, EventEngine
|
||||||
from vnpy.trader.engine import BaseEngine, MainEngine
|
from vnpy.trader.engine import BaseEngine, MainEngine
|
||||||
|
1277
vnpy/app/cta_strategy_pro/backtesting.py
Normal file
1277
vnpy/app/cta_strategy_pro/backtesting.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
""""""
|
""""""
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import csv
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@ -8,6 +9,7 @@ from collections import defaultdict
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from collections import OrderedDict
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
@ -38,7 +40,8 @@ from vnpy.trader.constant import (
|
|||||||
Offset,
|
Offset,
|
||||||
Status
|
Status
|
||||||
)
|
)
|
||||||
from vnpy.trader.utility import load_json, save_json, extract_vt_symbol, round_to, get_folder_path, get_underlying_symbol
|
from vnpy.trader.utility import load_json, save_json, extract_vt_symbol, round_to, get_folder_path, \
|
||||||
|
get_underlying_symbol
|
||||||
from vnpy.trader.util_logger import setup_logger, logging
|
from vnpy.trader.util_logger import setup_logger, logging
|
||||||
from vnpy.trader.converter import OffsetConverter
|
from vnpy.trader.converter import OffsetConverter
|
||||||
|
|
||||||
@ -125,6 +128,31 @@ class CtaEngine(BaseEngine):
|
|||||||
self.register_event()
|
self.register_event()
|
||||||
self.write_log("CTA策略引擎初始化成功")
|
self.write_log("CTA策略引擎初始化成功")
|
||||||
|
|
||||||
|
def append_data(self, file_name: str, dict_data: dict, field_names: list = []):
|
||||||
|
"""
|
||||||
|
添加数据到csv文件中
|
||||||
|
:param file_name: csv的文件全路径
|
||||||
|
:param dict_data: OrderedDict
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
dict_fieldnames = sorted(list(dict_data.keys())) if len(field_names) == 0 else field_names
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not os.path.exists(file_name):
|
||||||
|
self.write_log(u'create csv file:{}'.format(file_name))
|
||||||
|
with open(file_name, 'a', encoding='utf8', newline='\n') as csvWriteFile:
|
||||||
|
writer = csv.DictWriter(f=csvWriteFile, fieldnames=dict_fieldnames, dialect='excel')
|
||||||
|
self.write_log(u'write csv header:{}'.format(dict_fieldnames))
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerow(dict_data)
|
||||||
|
else:
|
||||||
|
with open(file_name, 'a', encoding='utf8', newline='\n') as csvWriteFile:
|
||||||
|
writer = csv.DictWriter(f=csvWriteFile, fieldnames=dict_fieldnames, dialect='excel',
|
||||||
|
extrasaction='ignore')
|
||||||
|
writer.writerow(dict_data)
|
||||||
|
except Exception as ex:
|
||||||
|
self.write_error(u'append_data exception:{}'.format(str(ex)))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""停止所属有的策略"""
|
"""停止所属有的策略"""
|
||||||
self.stop_all_strategies()
|
self.stop_all_strategies()
|
||||||
@ -210,10 +238,40 @@ class CtaEngine(BaseEngine):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Update strategy pos before calling on_trade method
|
# Update strategy pos before calling on_trade method
|
||||||
if trade.direction == Direction.LONG:
|
# 取消外部干预策略pos,由策略自行完成更新
|
||||||
strategy.pos += trade.volume
|
# if trade.direction == Direction.LONG:
|
||||||
else:
|
# strategy.pos += trade.volume
|
||||||
strategy.pos -= trade.volume
|
# else:
|
||||||
|
# strategy.pos -= trade.volume
|
||||||
|
# 根据策略名称,写入 data\straetgy_name_trade.csv文件
|
||||||
|
strategy_name = getattr(strategy, 'name')
|
||||||
|
trade_fields = ['time', 'symbol', 'exchange', 'vt_symbol', 'tradeid', 'vt_tradeid', 'orderid', 'vt_orderid',
|
||||||
|
'direction', 'offset', 'price', 'volume', 'idx_price']
|
||||||
|
trade_dict = OrderedDict()
|
||||||
|
try:
|
||||||
|
for k in trade_fields:
|
||||||
|
if k == 'time':
|
||||||
|
trade_dict[k] = datetime.now().strftime('%Y-%m-%d') + ' ' + getattr(trade, k, '')
|
||||||
|
if k in ['exchange', 'direction', 'offset']:
|
||||||
|
trade_dict[k] = getattr(trade, k).value
|
||||||
|
else:
|
||||||
|
trade_dict[k] = getattr(trade, k, '')
|
||||||
|
|
||||||
|
# 添加指数价格
|
||||||
|
symbol = trade_dict.get('symbol')
|
||||||
|
idx_symbol = get_underlying_symbol(symbol).upper() + '99.' + trade_dict.get('exchange')
|
||||||
|
idx_price = self.get_price(idx_symbol)
|
||||||
|
if idx_price:
|
||||||
|
trade_dict.update({'idx_price': idx_price})
|
||||||
|
else:
|
||||||
|
trade_dict.update({'idx_price': trade_dict.get('price')})
|
||||||
|
|
||||||
|
if strategy_name is not None:
|
||||||
|
trade_file = os.path.abspath(
|
||||||
|
os.path.join(get_folder_path('data'), '{}_trade.csv'.format(strategy_name)))
|
||||||
|
self.append_data(file_name=trade_file, dict_data=trade_dict)
|
||||||
|
except Exception as ex:
|
||||||
|
self.write_error(u'写入交易记录csv出错:{},{}'.format(str(ex), traceback.format_exc()))
|
||||||
|
|
||||||
self.call_strategy_func(strategy, strategy.on_trade, trade)
|
self.call_strategy_func(strategy, strategy.on_trade, trade)
|
||||||
|
|
||||||
@ -264,7 +322,8 @@ class CtaEngine(BaseEngine):
|
|||||||
self.main_engine.subscribe(req, gateway_name)
|
self.main_engine.subscribe(req, gateway_name)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.write_error(u'重新订阅{}.{}异常:{},{}'.format(gateway_name, vt_symbol, str(ex), traceback.format_exc()))
|
self.write_error(
|
||||||
|
u'重新订阅{}.{}异常:{},{}'.format(gateway_name, vt_symbol, str(ex), traceback.format_exc()))
|
||||||
return
|
return
|
||||||
|
|
||||||
def check_stop_order(self, tick: TickData):
|
def check_stop_order(self, tick: TickData):
|
||||||
@ -407,6 +466,32 @@ class CtaEngine(BaseEngine):
|
|||||||
gateway_name
|
gateway_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def send_fak_order(
|
||||||
|
self,
|
||||||
|
strategy: CtaTemplate,
|
||||||
|
contract: ContractData,
|
||||||
|
direction: Direction,
|
||||||
|
offset: Offset,
|
||||||
|
price: float,
|
||||||
|
volume: float,
|
||||||
|
lock: bool,
|
||||||
|
gateway_name: str = None
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Send a limit order to server.
|
||||||
|
"""
|
||||||
|
return self.send_server_order(
|
||||||
|
strategy,
|
||||||
|
contract,
|
||||||
|
direction,
|
||||||
|
offset,
|
||||||
|
price,
|
||||||
|
volume,
|
||||||
|
OrderType.FAK,
|
||||||
|
lock,
|
||||||
|
gateway_name
|
||||||
|
)
|
||||||
|
|
||||||
def send_server_stop_order(
|
def send_server_stop_order(
|
||||||
self,
|
self,
|
||||||
strategy: CtaTemplate,
|
strategy: CtaTemplate,
|
||||||
@ -462,7 +547,7 @@ class CtaEngine(BaseEngine):
|
|||||||
stop_orderid=stop_orderid,
|
stop_orderid=stop_orderid,
|
||||||
strategy_name=strategy.strategy_name,
|
strategy_name=strategy.strategy_name,
|
||||||
lock=lock,
|
lock=lock,
|
||||||
gateway_name = gateway_name
|
gateway_name=gateway_name
|
||||||
)
|
)
|
||||||
|
|
||||||
self.stop_orders[stop_orderid] = stop_order
|
self.stop_orders[stop_orderid] = stop_order
|
||||||
@ -521,6 +606,7 @@ class CtaEngine(BaseEngine):
|
|||||||
volume: float,
|
volume: float,
|
||||||
stop: bool,
|
stop: bool,
|
||||||
lock: bool,
|
lock: bool,
|
||||||
|
order_type: OrderType = OrderType.LIMIT,
|
||||||
gateway_name: str = None
|
gateway_name: str = None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
@ -540,9 +626,13 @@ class CtaEngine(BaseEngine):
|
|||||||
|
|
||||||
if stop:
|
if stop:
|
||||||
if contract.stop_supported:
|
if contract.stop_supported:
|
||||||
return self.send_server_stop_order(strategy, contract, direction, offset, price, volume, lock, gateway_name)
|
return self.send_server_stop_order(strategy, contract, direction, offset, price, volume, lock,
|
||||||
|
gateway_name)
|
||||||
else:
|
else:
|
||||||
return self.send_local_stop_order(strategy, vt_symbol, direction, offset, price, volume, lock, gateway_name)
|
return self.send_local_stop_order(strategy, vt_symbol, direction, offset, price, volume, lock,
|
||||||
|
gateway_name)
|
||||||
|
if order_type == OrderType.FAK:
|
||||||
|
return self.send_fak_order(strategy, contract, direction, offset, price, volume, lock, gateway_name)
|
||||||
else:
|
else:
|
||||||
return self.send_limit_order(strategy, contract, direction, offset, price, volume, lock, gateway_name)
|
return self.send_limit_order(strategy, contract, direction, offset, price, volume, lock, gateway_name)
|
||||||
|
|
||||||
|
2036
vnpy/app/cta_strategy_pro/portfolio_testing.py
Normal file
2036
vnpy/app/cta_strategy_pro/portfolio_testing.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,511 +4,575 @@
|
|||||||
"mi_symbol": "a2005",
|
"mi_symbol": "a2005",
|
||||||
"full_symbol": "A2005",
|
"full_symbol": "A2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"AG": {
|
"AG": {
|
||||||
"underlying_symbol": "AG",
|
"underlying_symbol": "AG",
|
||||||
"mi_symbol": "ag2007",
|
"mi_symbol": "ag2007",
|
||||||
"full_symbol": "AG2007",
|
"full_symbol": "AG2007",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "15",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "1"
|
"symbol_size": 15,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"AL": {
|
"AL": {
|
||||||
"underlying_symbol": "AL",
|
"underlying_symbol": "AL",
|
||||||
"mi_symbol": "al2002",
|
"mi_symbol": "al2003",
|
||||||
"full_symbol": "AL2002",
|
"full_symbol": "AL2003",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"AP": {
|
"AP": {
|
||||||
"underlying_symbol": "AP",
|
"underlying_symbol": "AP",
|
||||||
"mi_symbol": "AP005",
|
"mi_symbol": "AP005",
|
||||||
"full_symbol": "AP2005",
|
"full_symbol": "AP2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"AU": {
|
"AU": {
|
||||||
"underlying_symbol": "AU",
|
"underlying_symbol": "AU",
|
||||||
"mi_symbol": "au2006",
|
"mi_symbol": "au2006",
|
||||||
"full_symbol": "AU2006",
|
"full_symbol": "AU2006",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "1000",
|
"margin_rate": 0.06,
|
||||||
"price_tick": "0.05"
|
"symbol_size": 1000,
|
||||||
|
"price_tick": 0.02
|
||||||
},
|
},
|
||||||
"B": {
|
"B": {
|
||||||
"underlying_symbol": "B",
|
"underlying_symbol": "B",
|
||||||
"mi_symbol": "b2003",
|
"mi_symbol": "b2003",
|
||||||
"full_symbol": "B2003",
|
"full_symbol": "B2003",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"BB": {
|
"BB": {
|
||||||
"underlying_symbol": "BB",
|
"underlying_symbol": "BB",
|
||||||
"mi_symbol": "bb2012",
|
"mi_symbol": "bb2012",
|
||||||
"full_symbol": "BB2012",
|
"full_symbol": "BB2012",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "500",
|
"margin_rate": 0.2,
|
||||||
"price_tick": "0.05"
|
"symbol_size": 500,
|
||||||
|
"price_tick": 0.05
|
||||||
},
|
},
|
||||||
"BU": {
|
"BU": {
|
||||||
"underlying_symbol": "BU",
|
"underlying_symbol": "BU",
|
||||||
"mi_symbol": "bu2006",
|
"mi_symbol": "bu2006",
|
||||||
"full_symbol": "BU2006",
|
"full_symbol": "BU2006",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.09,
|
||||||
"price_tick": "2"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"C": {
|
"C": {
|
||||||
"underlying_symbol": "C",
|
"underlying_symbol": "C",
|
||||||
"mi_symbol": "c2005",
|
"mi_symbol": "c2005",
|
||||||
"full_symbol": "C2005",
|
"full_symbol": "C2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"CF": {
|
"CF": {
|
||||||
"underlying_symbol": "CF",
|
"underlying_symbol": "CF",
|
||||||
"mi_symbol": "CF005",
|
"mi_symbol": "CF005",
|
||||||
"full_symbol": "CF2005",
|
"full_symbol": "CF2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"CJ": {
|
"CJ": {
|
||||||
"underlying_symbol": "CJ",
|
"underlying_symbol": "CJ",
|
||||||
"mi_symbol": "CJ005",
|
"mi_symbol": "CJ005",
|
||||||
"full_symbol": "CJ2005",
|
"full_symbol": "CJ2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"CS": {
|
"CS": {
|
||||||
"underlying_symbol": "CS",
|
"underlying_symbol": "CS",
|
||||||
"mi_symbol": "cs2005",
|
"mi_symbol": "cs2005",
|
||||||
"full_symbol": "CS2005",
|
"full_symbol": "CS2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"CU": {
|
"CU": {
|
||||||
"underlying_symbol": "CU",
|
"underlying_symbol": "CU",
|
||||||
"mi_symbol": "cu2003",
|
"mi_symbol": "cu2003",
|
||||||
"full_symbol": "CU2003",
|
"full_symbol": "CU2003",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "10"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 10.0
|
||||||
},
|
},
|
||||||
"CY": {
|
"CY": {
|
||||||
"underlying_symbol": "CY",
|
"underlying_symbol": "CY",
|
||||||
"mi_symbol": "CY005",
|
"mi_symbol": "CY005",
|
||||||
"full_symbol": "CY2005",
|
"full_symbol": "CY2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"EB": {
|
"EB": {
|
||||||
"underlying_symbol": "EB",
|
"underlying_symbol": "EB",
|
||||||
"mi_symbol": "eb2005",
|
"mi_symbol": "eb2005",
|
||||||
"full_symbol": "EB2005",
|
"full_symbol": "EB2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"EG": {
|
"EG": {
|
||||||
"underlying_symbol": "EG",
|
"underlying_symbol": "EG",
|
||||||
"mi_symbol": "eg2005",
|
"mi_symbol": "eg2005",
|
||||||
"full_symbol": "EG2005",
|
"full_symbol": "EG2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.06,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"FB": {
|
"FB": {
|
||||||
"underlying_symbol": "FB",
|
"underlying_symbol": "FB",
|
||||||
"mi_symbol": "fb2005",
|
"mi_symbol": "fb2005",
|
||||||
"full_symbol": "FB2005",
|
"full_symbol": "FB2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "500",
|
"margin_rate": 0.1,
|
||||||
"price_tick": "0.05"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 0.5
|
||||||
},
|
},
|
||||||
"FG": {
|
"FG": {
|
||||||
"underlying_symbol": "FG",
|
"underlying_symbol": "FG",
|
||||||
"mi_symbol": "FG005",
|
"mi_symbol": "FG005",
|
||||||
"full_symbol": "FG2005",
|
"full_symbol": "FG2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"FU": {
|
"FU": {
|
||||||
"underlying_symbol": "FU",
|
"underlying_symbol": "FU",
|
||||||
"mi_symbol": "fu2005",
|
"mi_symbol": "fu2005",
|
||||||
"full_symbol": "FU2005",
|
"full_symbol": "FU2005",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.1,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"HC": {
|
"HC": {
|
||||||
"underlying_symbol": "HC",
|
"underlying_symbol": "HC",
|
||||||
"mi_symbol": "hc2005",
|
"mi_symbol": "hc2005",
|
||||||
"full_symbol": "HC2005",
|
"full_symbol": "HC2005",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"I": {
|
"I": {
|
||||||
"underlying_symbol": "I",
|
"underlying_symbol": "I",
|
||||||
"mi_symbol": "i2005",
|
"mi_symbol": "i2005",
|
||||||
"full_symbol": "I2005",
|
"full_symbol": "I2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "100",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "0.5"
|
"symbol_size": 100,
|
||||||
|
"price_tick": 0.5
|
||||||
},
|
},
|
||||||
"IC": {
|
"IC": {
|
||||||
"underlying_symbol": "IC",
|
"underlying_symbol": "IC",
|
||||||
"mi_symbol": "IC2003",
|
"mi_symbol": "IC2003",
|
||||||
"full_symbol": "IC2003",
|
"full_symbol": "IC2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "200",
|
"margin_rate": 0.12,
|
||||||
"price_tick": "0.2"
|
"symbol_size": 200,
|
||||||
|
"price_tick": 0.2
|
||||||
},
|
},
|
||||||
"IF": {
|
"IF": {
|
||||||
"underlying_symbol": "IF",
|
"underlying_symbol": "IF",
|
||||||
"mi_symbol": "IF2003",
|
"mi_symbol": "IF2003",
|
||||||
"full_symbol": "IF2003",
|
"full_symbol": "IF2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "300",
|
"margin_rate": 0.1,
|
||||||
"price_tick": "0.2"
|
"symbol_size": 300,
|
||||||
|
"price_tick": 0.2
|
||||||
},
|
},
|
||||||
"IH": {
|
"IH": {
|
||||||
"underlying_symbol": "IH",
|
"underlying_symbol": "IH",
|
||||||
"mi_symbol": "IH2003",
|
"mi_symbol": "IH2003",
|
||||||
"full_symbol": "IH2003",
|
"full_symbol": "IH2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "300",
|
"margin_rate": 0.1,
|
||||||
"price_tick": "0.2"
|
"symbol_size": 300,
|
||||||
|
"price_tick": 0.2
|
||||||
},
|
},
|
||||||
"J": {
|
"J": {
|
||||||
"underlying_symbol": "J",
|
"underlying_symbol": "J",
|
||||||
"mi_symbol": "j2005",
|
"mi_symbol": "j2005",
|
||||||
"full_symbol": "J2005",
|
"full_symbol": "J2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "100",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "0.5"
|
"symbol_size": 100,
|
||||||
|
"price_tick": 0.5
|
||||||
},
|
},
|
||||||
"JD": {
|
"JD": {
|
||||||
"underlying_symbol": "JD",
|
"underlying_symbol": "JD",
|
||||||
"mi_symbol": "jd2005",
|
"mi_symbol": "jd2005",
|
||||||
"full_symbol": "JD2005",
|
"full_symbol": "JD2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"JM": {
|
"JM": {
|
||||||
"underlying_symbol": "JM",
|
"underlying_symbol": "JM",
|
||||||
"mi_symbol": "jm2005",
|
"mi_symbol": "jm2005",
|
||||||
"full_symbol": "JM2005",
|
"full_symbol": "JM2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "60",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "0.5"
|
"symbol_size": 60,
|
||||||
|
"price_tick": 0.5
|
||||||
},
|
},
|
||||||
"JR": {
|
"JR": {
|
||||||
"underlying_symbol": "JR",
|
"underlying_symbol": "JR",
|
||||||
"mi_symbol": "JR011",
|
"mi_symbol": "JR011",
|
||||||
"full_symbol": "JR2011",
|
"full_symbol": "JR2011",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"L": {
|
"L": {
|
||||||
"underlying_symbol": "L",
|
"underlying_symbol": "L",
|
||||||
"mi_symbol": "l2005",
|
"mi_symbol": "l2005",
|
||||||
"full_symbol": "L2005",
|
"full_symbol": "L2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"LR": {
|
"LR": {
|
||||||
"underlying_symbol": "LR",
|
"underlying_symbol": "LR",
|
||||||
"mi_symbol": "LR007",
|
"mi_symbol": "LR007",
|
||||||
"full_symbol": "LR2007",
|
"full_symbol": "LR2007",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"M": {
|
"M": {
|
||||||
"underlying_symbol": "M",
|
"underlying_symbol": "M",
|
||||||
"mi_symbol": "m2005",
|
"mi_symbol": "m2005",
|
||||||
"full_symbol": "M2005",
|
"full_symbol": "M2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"MA": {
|
"MA": {
|
||||||
"underlying_symbol": "MA",
|
"underlying_symbol": "MA",
|
||||||
"mi_symbol": "MA005",
|
"mi_symbol": "MA005",
|
||||||
"full_symbol": "MA2005",
|
"full_symbol": "MA2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"NI": {
|
"NI": {
|
||||||
"underlying_symbol": "NI",
|
"underlying_symbol": "NI",
|
||||||
"mi_symbol": "ni2003",
|
"mi_symbol": "ni2003",
|
||||||
"full_symbol": "NI2003",
|
"full_symbol": "NI2003",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "1",
|
"margin_rate": 0.1,
|
||||||
"price_tick": "10"
|
"symbol_size": 1,
|
||||||
|
"price_tick": 10.0
|
||||||
},
|
},
|
||||||
"NR": {
|
"NR": {
|
||||||
"underlying_symbol": "NR",
|
"underlying_symbol": "NR",
|
||||||
"mi_symbol": "nr2004",
|
"mi_symbol": "nr2004",
|
||||||
"full_symbol": "NR2004",
|
"full_symbol": "NR2004",
|
||||||
"exchange": "INE",
|
"exchange": "INE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.09,
|
||||||
"price_tick": "5"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"OI": {
|
"OI": {
|
||||||
"underlying_symbol": "OI",
|
"underlying_symbol": "OI",
|
||||||
"mi_symbol": "OI005",
|
"mi_symbol": "OI005",
|
||||||
"full_symbol": "OI2005",
|
"full_symbol": "OI2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"P": {
|
"P": {
|
||||||
"underlying_symbol": "P",
|
"underlying_symbol": "P",
|
||||||
"mi_symbol": "p2005",
|
"mi_symbol": "p2005",
|
||||||
"full_symbol": "P2005",
|
"full_symbol": "P2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "2"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"PB": {
|
"PB": {
|
||||||
"underlying_symbol": "PB",
|
"underlying_symbol": "PB",
|
||||||
"mi_symbol": "pb2002",
|
"mi_symbol": "pb2003",
|
||||||
"full_symbol": "PB2002",
|
"full_symbol": "PB2003",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"PM": {
|
"PM": {
|
||||||
"underlying_symbol": "PM",
|
"underlying_symbol": "PM",
|
||||||
"mi_symbol": "PM011",
|
"mi_symbol": "PM011",
|
||||||
"full_symbol": "PM2011",
|
"full_symbol": "PM2011",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "50",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 50,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"PP": {
|
"PP": {
|
||||||
"underlying_symbol": "PP",
|
"underlying_symbol": "PP",
|
||||||
"mi_symbol": "pp2005",
|
"mi_symbol": "pp2005",
|
||||||
"full_symbol": "PP2005",
|
"full_symbol": "PP2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RB": {
|
"RB": {
|
||||||
"underlying_symbol": "RB",
|
"underlying_symbol": "RB",
|
||||||
"mi_symbol": "rb2005",
|
"mi_symbol": "rb2005",
|
||||||
"full_symbol": "RB2005",
|
"full_symbol": "RB2005",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RI": {
|
"RI": {
|
||||||
"underlying_symbol": "RI",
|
"underlying_symbol": "RI",
|
||||||
"mi_symbol": "RI011",
|
"mi_symbol": "RI011",
|
||||||
"full_symbol": "RI2011",
|
"full_symbol": "RI2011",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RM": {
|
"RM": {
|
||||||
"underlying_symbol": "RM",
|
"underlying_symbol": "RM",
|
||||||
"mi_symbol": "RM005",
|
"mi_symbol": "RM005",
|
||||||
"full_symbol": "RM2005",
|
"full_symbol": "RM2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.06,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RR": {
|
"RR": {
|
||||||
"underlying_symbol": "RR",
|
"underlying_symbol": "RR",
|
||||||
"mi_symbol": "rr2005",
|
"mi_symbol": "rr2005",
|
||||||
"full_symbol": "RR2005",
|
"full_symbol": "RR2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RS": {
|
"RS": {
|
||||||
"underlying_symbol": "RS",
|
"underlying_symbol": "RS",
|
||||||
"mi_symbol": "RS011",
|
"mi_symbol": "RS011",
|
||||||
"full_symbol": "RS2011",
|
"full_symbol": "RS2011",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.2,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"RU": {
|
"RU": {
|
||||||
"underlying_symbol": "RU",
|
"underlying_symbol": "RU",
|
||||||
"mi_symbol": "ru2005",
|
"mi_symbol": "ru2005",
|
||||||
"full_symbol": "RU2005",
|
"full_symbol": "RU2005",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.09,
|
||||||
"price_tick": "5"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"SA": {
|
"SA": {
|
||||||
"underlying_symbol": "SA",
|
"underlying_symbol": "SA",
|
||||||
"mi_symbol": "SA005",
|
"mi_symbol": "SA005",
|
||||||
"full_symbol": "SA2005",
|
"full_symbol": "SA2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"SC": {
|
"SC": {
|
||||||
"underlying_symbol": "SC",
|
"underlying_symbol": "SC",
|
||||||
"mi_symbol": "sc2003",
|
"mi_symbol": "sc2003",
|
||||||
"full_symbol": "SC2003",
|
"full_symbol": "SC2003",
|
||||||
"exchange": "INE",
|
"exchange": "INE",
|
||||||
"symbol_size": "1000",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "0.1"
|
"symbol_size": 1000,
|
||||||
|
"price_tick": 0.1
|
||||||
},
|
},
|
||||||
"SF": {
|
"SF": {
|
||||||
"underlying_symbol": "SF",
|
"underlying_symbol": "SF",
|
||||||
"mi_symbol": "SF005",
|
"mi_symbol": "SF005",
|
||||||
"full_symbol": "SF2005",
|
"full_symbol": "SF2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "2"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"SM": {
|
"SM": {
|
||||||
"underlying_symbol": "SM",
|
"underlying_symbol": "SM",
|
||||||
"mi_symbol": "SM005",
|
"mi_symbol": "SM005",
|
||||||
"full_symbol": "SM2005",
|
"full_symbol": "SM2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "2"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"SN": {
|
"SN": {
|
||||||
"underlying_symbol": "SN",
|
"underlying_symbol": "SN",
|
||||||
"mi_symbol": "sn2006",
|
"mi_symbol": "sn2006",
|
||||||
"full_symbol": "SN2006",
|
"full_symbol": "SN2006",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "1",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "10"
|
"symbol_size": 1,
|
||||||
|
"price_tick": 10.0
|
||||||
},
|
},
|
||||||
"SP": {
|
"SP": {
|
||||||
"underlying_symbol": "SP",
|
"underlying_symbol": "SP",
|
||||||
"mi_symbol": "sp2005",
|
"mi_symbol": "sp2005",
|
||||||
"full_symbol": "SP2005",
|
"full_symbol": "SP2005",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "2"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"SR": {
|
"SR": {
|
||||||
"underlying_symbol": "SR",
|
"underlying_symbol": "SR",
|
||||||
"mi_symbol": "SR005",
|
"mi_symbol": "SR005",
|
||||||
"full_symbol": "SR2005",
|
"full_symbol": "SR2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"SS": {
|
"SS": {
|
||||||
"underlying_symbol": "SS",
|
"underlying_symbol": "SS",
|
||||||
"mi_symbol": "ss2006",
|
"mi_symbol": "ss2006",
|
||||||
"full_symbol": "SS2006",
|
"full_symbol": "SS2006",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"T": {
|
"T": {
|
||||||
"underlying_symbol": "T",
|
"underlying_symbol": "T",
|
||||||
"mi_symbol": "T2003",
|
"mi_symbol": "T2003",
|
||||||
"full_symbol": "T2003",
|
"full_symbol": "T2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "10000",
|
"margin_rate": 0.02,
|
||||||
"price_tick": "0.005"
|
"symbol_size": 10000,
|
||||||
|
"price_tick": 0.005
|
||||||
},
|
},
|
||||||
"TA": {
|
"TA": {
|
||||||
"underlying_symbol": "TA",
|
"underlying_symbol": "TA",
|
||||||
"mi_symbol": "TA005",
|
"mi_symbol": "TA005",
|
||||||
"full_symbol": "TA2005",
|
"full_symbol": "TA2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.06,
|
||||||
"price_tick": "2"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"TF": {
|
"TF": {
|
||||||
"underlying_symbol": "TF",
|
"underlying_symbol": "TF",
|
||||||
"mi_symbol": "TF2003",
|
"mi_symbol": "TF2003",
|
||||||
"full_symbol": "TF2003",
|
"full_symbol": "TF2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "10000",
|
"margin_rate": 0.012,
|
||||||
"price_tick": "0.005"
|
"symbol_size": 10000,
|
||||||
|
"price_tick": 0.005
|
||||||
},
|
},
|
||||||
"TS": {
|
"TS": {
|
||||||
"underlying_symbol": "TS",
|
"underlying_symbol": "TS",
|
||||||
"mi_symbol": "TS2003",
|
"mi_symbol": "TS2003",
|
||||||
"full_symbol": "TS2003",
|
"full_symbol": "TS2003",
|
||||||
"exchange": "CFFEX",
|
"exchange": "CFFEX",
|
||||||
"symbol_size": "20000",
|
"margin_rate": 0.005,
|
||||||
"price_tick": "0.005"
|
"symbol_size": 20000,
|
||||||
|
"price_tick": 0.005
|
||||||
},
|
},
|
||||||
"UR": {
|
"UR": {
|
||||||
"underlying_symbol": "UR",
|
"underlying_symbol": "UR",
|
||||||
"mi_symbol": "UR005",
|
"mi_symbol": "UR005",
|
||||||
"full_symbol": "UR2005",
|
"full_symbol": "UR2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"V": {
|
"V": {
|
||||||
"underlying_symbol": "V",
|
"underlying_symbol": "V",
|
||||||
"mi_symbol": "v2005",
|
"mi_symbol": "v2005",
|
||||||
"full_symbol": "V2005",
|
"full_symbol": "V2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
},
|
},
|
||||||
"WH": {
|
"WH": {
|
||||||
"underlying_symbol": "WH",
|
"underlying_symbol": "WH",
|
||||||
"mi_symbol": "WH005",
|
"mi_symbol": "WH011",
|
||||||
"full_symbol": "WH2005",
|
"full_symbol": "WH2011",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "20",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "1"
|
"symbol_size": 20,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"WR": {
|
"WR": {
|
||||||
"underlying_symbol": "WR",
|
"underlying_symbol": "WR",
|
||||||
"mi_symbol": "wr2012",
|
"mi_symbol": "wr2012",
|
||||||
"full_symbol": "WR2012",
|
"full_symbol": "WR2012",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.08,
|
||||||
"price_tick": "1"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 1.0
|
||||||
},
|
},
|
||||||
"Y": {
|
"Y": {
|
||||||
"underlying_symbol": "Y",
|
"underlying_symbol": "Y",
|
||||||
"mi_symbol": "y2005",
|
"mi_symbol": "y2005",
|
||||||
"full_symbol": "Y2005",
|
"full_symbol": "Y2005",
|
||||||
"exchange": "DCE",
|
"exchange": "DCE",
|
||||||
"symbol_size": "10",
|
"margin_rate": 0.05,
|
||||||
"price_tick": "2"
|
"symbol_size": 10,
|
||||||
|
"price_tick": 2.0
|
||||||
},
|
},
|
||||||
"ZC": {
|
"ZC": {
|
||||||
"underlying_symbol": "ZC",
|
"underlying_symbol": "ZC",
|
||||||
"mi_symbol": "ZC005",
|
"mi_symbol": "ZC005",
|
||||||
"full_symbol": "ZC2005",
|
"full_symbol": "ZC2005",
|
||||||
"exchange": "CZCE",
|
"exchange": "CZCE",
|
||||||
"symbol_size": "100",
|
"margin_rate": 0.06,
|
||||||
"price_tick": "0.2"
|
"symbol_size": 100,
|
||||||
|
"price_tick": 0.2
|
||||||
},
|
},
|
||||||
"ZN": {
|
"ZN": {
|
||||||
"underlying_symbol": "ZN",
|
"underlying_symbol": "ZN",
|
||||||
"mi_symbol": "zn2003",
|
"mi_symbol": "zn2003",
|
||||||
"full_symbol": "ZN2003",
|
"full_symbol": "ZN2003",
|
||||||
"exchange": "SHFE",
|
"exchange": "SHFE",
|
||||||
"symbol_size": "5",
|
"margin_rate": 0.07,
|
||||||
"price_tick": "5"
|
"symbol_size": 5,
|
||||||
|
"price_tick": 5.0
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ from vnpy.data.tdx.tdx_future_data import *
|
|||||||
bar_data_folder = os.path.abspath(os.path.join(vnpy_root, 'bar_data'))
|
bar_data_folder = os.path.abspath(os.path.join(vnpy_root, 'bar_data'))
|
||||||
|
|
||||||
# 开始日期(每年大概需要几分钟)
|
# 开始日期(每年大概需要几分钟)
|
||||||
start_date = '20190101'
|
start_date = '20160101'
|
||||||
|
|
||||||
# 创建API对象
|
# 创建API对象
|
||||||
api_01 = TdxFutureData()
|
api_01 = TdxFutureData()
|
||||||
@ -29,7 +29,7 @@ api_01 = TdxFutureData()
|
|||||||
api_01.update_mi_contracts()
|
api_01.update_mi_contracts()
|
||||||
|
|
||||||
# 逐一指数合约下载并更新
|
# 逐一指数合约下载并更新
|
||||||
for underlying_symbol in api_01.future_contracts.keys():
|
for underlying_symbol in ['RB', 'J']: #api_01.future_contracts.keys():
|
||||||
index_symbol = underlying_symbol + '99'
|
index_symbol = underlying_symbol + '99'
|
||||||
print(f'开始更新:{index_symbol}')
|
print(f'开始更新:{index_symbol}')
|
||||||
# csv数据文件名
|
# csv数据文件名
|
||||||
@ -76,4 +76,6 @@ for underlying_symbol in api_01.future_contracts.keys():
|
|||||||
print(data_df.tail())
|
print(data_df.tail())
|
||||||
data_df.to_csv(bar_file_path, index=True)
|
data_df.to_csv(bar_file_path, index=True)
|
||||||
print(f'更新{index_symbol}数据 => 文件{bar_file_path}')
|
print(f'更新{index_symbol}数据 => 文件{bar_file_path}')
|
||||||
break
|
|
||||||
|
print('更新完毕')
|
||||||
|
os._exit(0)
|
||||||
|
@ -773,14 +773,14 @@ class TdxFutureData(object):
|
|||||||
should_save = True
|
should_save = True
|
||||||
else:
|
else:
|
||||||
# 添加到新合约中
|
# 添加到新合约中
|
||||||
# todo 这里缺少size和price_tick
|
# 这里缺少size和price_tick, margin_rate,当ctp_gateway启动时,会自动补充和修正完毕
|
||||||
info = {
|
info = {
|
||||||
"underlying_symbol": underlying_symbol,
|
"underlying_symbol": underlying_symbol,
|
||||||
"mi_symbol": mi_symbol,
|
"mi_symbol": mi_symbol,
|
||||||
"full_symbol": full_symbol,
|
"full_symbol": full_symbol,
|
||||||
"exchange": vn_exchange.value
|
"exchange": vn_exchange.value
|
||||||
}
|
}
|
||||||
self.write_log(u'新合约:{}'.format(info))
|
self.write_log(u'新合约:{}, 需要待ctp连接后更新合约的size/price_tick/margin_rate'.format(info))
|
||||||
self.future_contracts.update({underlying_symbol: info})
|
self.future_contracts.update({underlying_symbol: info})
|
||||||
should_save = True
|
should_save = True
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ str_markets = json.dumps(markets, indent=1, ensure_ascii=False)
|
|||||||
print(u'{}'.format(str_markets))
|
print(u'{}'.format(str_markets))
|
||||||
|
|
||||||
# 获取所有的期货合约明细
|
# 获取所有的期货合约明细
|
||||||
# api_01.qry_instrument()
|
api_01.qry_instrument()
|
||||||
|
|
||||||
# 获取某个合约得最新价
|
# 获取某个合约得最新价
|
||||||
# price = api_01.get_price('rb2005')
|
price = api_01.get_price('rb2005')
|
||||||
# print('price={}'.format(price))
|
print('price={}'.format(price))
|
||||||
|
|
||||||
|
|
||||||
# 获取主力合约
|
# 获取主力合约
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import traceback
|
import traceback
|
||||||
import json
|
import json
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from copy import copy
|
from copy import copy,deepcopy
|
||||||
|
|
||||||
from vnpy.api.ctp import (
|
from vnpy.api.ctp import (
|
||||||
MdApi,
|
MdApi,
|
||||||
@ -76,6 +76,7 @@ from vnpy.amqp.consumer import subscriber
|
|||||||
from vnpy.data.tdx.tdx_common import (
|
from vnpy.data.tdx.tdx_common import (
|
||||||
TDX_FUTURE_HOSTS,
|
TDX_FUTURE_HOSTS,
|
||||||
get_future_contracts,
|
get_future_contracts,
|
||||||
|
save_future_contracts,
|
||||||
get_cache_json,
|
get_cache_json,
|
||||||
save_cache_json,
|
save_cache_json,
|
||||||
TDX_FUTURE_CONFIG)
|
TDX_FUTURE_CONFIG)
|
||||||
@ -137,7 +138,9 @@ OPTIONTYPE_CTP2VT = {
|
|||||||
symbol_exchange_map = {}
|
symbol_exchange_map = {}
|
||||||
symbol_name_map = {}
|
symbol_name_map = {}
|
||||||
symbol_size_map = {}
|
symbol_size_map = {}
|
||||||
|
index_contracts = {}
|
||||||
|
# tdx 期货配置本地缓存
|
||||||
|
future_contracts = get_future_contracts()
|
||||||
|
|
||||||
class CtpGateway(BaseGateway):
|
class CtpGateway(BaseGateway):
|
||||||
"""
|
"""
|
||||||
@ -479,6 +482,7 @@ class CtpTdApi(TdApi):
|
|||||||
self.trade_data = []
|
self.trade_data = []
|
||||||
self.positions = {}
|
self.positions = {}
|
||||||
self.sysid_orderid_map = {}
|
self.sysid_orderid_map = {}
|
||||||
|
self.future_contract_changed = False
|
||||||
|
|
||||||
def onFrontConnected(self):
|
def onFrontConnected(self):
|
||||||
""""""
|
""""""
|
||||||
@ -665,9 +669,40 @@ class CtpTdApi(TdApi):
|
|||||||
symbol_name_map[contract.symbol] = contract.name
|
symbol_name_map[contract.symbol] = contract.name
|
||||||
symbol_size_map[contract.symbol] = contract.size
|
symbol_size_map[contract.symbol] = contract.size
|
||||||
|
|
||||||
|
if contract.product == Product.FUTURES:
|
||||||
|
# 生成指数合约信息
|
||||||
|
underlying_symbol = data["ProductID"] # 短合约名称
|
||||||
|
underlying_symbol = underlying_symbol.upper()
|
||||||
|
# 只推送普通合约的指数
|
||||||
|
if len(underlying_symbol) <= 2:
|
||||||
|
idx_contract = index_contracts.get(underlying_symbol, None)
|
||||||
|
if idx_contract is None:
|
||||||
|
idx_contract = deepcopy(contract)
|
||||||
|
idx_contract.symbol = '{}99'.format(underlying_symbol)
|
||||||
|
idx_contract.name = u'{}指数'.format(underlying_symbol)
|
||||||
|
self.gateway.on_contract(idx_contract)
|
||||||
|
|
||||||
|
# 获取data/tdx/future_contracts.json中的合约记录
|
||||||
|
future_contract = future_contracts.get(underlying_symbol, {})
|
||||||
|
mi_contract_symbol = future_contract.get('mi_symbol', '')
|
||||||
|
margin_rate = float(future_contract.get('margin_rate', 0))
|
||||||
|
mi_margin_rate = round(idx_contract.margin_rate, 4)
|
||||||
|
if mi_contract_symbol == contract.symbol:
|
||||||
|
if margin_rate != mi_margin_rate:
|
||||||
|
self.gateway.write_log(f"{underlying_symbol}合约主力{mi_contract_symbol} 保证金{margin_rate}=>{mi_margin_rate}")
|
||||||
|
future_contract.update({'margin_rate': mi_margin_rate})
|
||||||
|
future_contract.update({'symbol_size': idx_contract.size})
|
||||||
|
future_contract.update({'price_tick': idx_contract.pricetick})
|
||||||
|
future_contracts.update({underlying_symbol: future_contract})
|
||||||
|
self.future_contract_changed = True
|
||||||
|
index_contracts.update({underlying_symbol: idx_contract})
|
||||||
if last:
|
if last:
|
||||||
self.gateway.write_log("合约信息查询成功")
|
self.gateway.write_log("合约信息查询成功")
|
||||||
|
|
||||||
|
if self.future_contract_changed:
|
||||||
|
self.gateway.write_log('更新vnpy/data/tdx/future_contracts.json')
|
||||||
|
save_future_contracts(future_contracts)
|
||||||
|
|
||||||
for data in self.order_data:
|
for data in self.order_data:
|
||||||
self.onRtnOrder(data)
|
self.onRtnOrder(data)
|
||||||
self.order_data.clear()
|
self.order_data.clear()
|
||||||
@ -902,7 +937,6 @@ class CtpTdApi(TdApi):
|
|||||||
if self.connect_status:
|
if self.connect_status:
|
||||||
self.exit()
|
self.exit()
|
||||||
|
|
||||||
|
|
||||||
class TdxMdApi():
|
class TdxMdApi():
|
||||||
"""
|
"""
|
||||||
通达信数据行情API实现
|
通达信数据行情API实现
|
||||||
@ -923,8 +957,7 @@ class TdxMdApi():
|
|||||||
self.symbol_vn_dict = {} # tdx合约与vtSymbol的对应
|
self.symbol_vn_dict = {} # tdx合约与vtSymbol的对应
|
||||||
self.symbol_tick_dict = {} # tdx合约与最后一个Tick得字典
|
self.symbol_tick_dict = {} # tdx合约与最后一个Tick得字典
|
||||||
|
|
||||||
# tdx 期货配置本地缓存
|
|
||||||
self.future_contracts = get_future_contracts()
|
|
||||||
|
|
||||||
self.registered_symbol_set = set()
|
self.registered_symbol_set = set()
|
||||||
|
|
||||||
@ -1180,7 +1213,7 @@ class TdxMdApi():
|
|||||||
underlying_symbol = get_underlying_symbol(vn_symbol)
|
underlying_symbol = get_underlying_symbol(vn_symbol)
|
||||||
|
|
||||||
if exchange is None:
|
if exchange is None:
|
||||||
symbol_info = self.future_contracts.get(underlying_symbol, None)
|
symbol_info = future_contracts.get(underlying_symbol, None)
|
||||||
if not symbol_info:
|
if not symbol_info:
|
||||||
continue
|
continue
|
||||||
exchange_value = symbol_info.get('exchange', None)
|
exchange_value = symbol_info.get('exchange', None)
|
||||||
|
@ -134,7 +134,7 @@ class Exchange(Enum):
|
|||||||
|
|
||||||
# Special Function
|
# Special Function
|
||||||
LOCAL = "LOCAL" # For local generated data
|
LOCAL = "LOCAL" # For local generated data
|
||||||
|
SPD = "SPD" # Customer Spread data
|
||||||
|
|
||||||
class Currency(Enum):
|
class Currency(Enum):
|
||||||
"""
|
"""
|
||||||
|
@ -301,3 +301,4 @@ class PositionHolding:
|
|||||||
req_list.append(req_open)
|
req_list.append(req_open)
|
||||||
|
|
||||||
return req_list
|
return req_list
|
||||||
|
|
||||||
|
@ -66,12 +66,14 @@ class MainEngine:
|
|||||||
self.engines[engine.engine_name] = engine
|
self.engines[engine.engine_name] = engine
|
||||||
return engine
|
return engine
|
||||||
|
|
||||||
def add_gateway(self, gateway_class: Type[BaseGateway]):
|
def add_gateway(self, gateway_class: Type[BaseGateway], gateway_name: str = None):
|
||||||
"""
|
"""
|
||||||
Add gateway.
|
Add gateway.
|
||||||
"""
|
"""
|
||||||
gateway = gateway_class(self.event_engine)
|
gateway = gateway_class(self.event_engine)
|
||||||
self.gateways[gateway.gateway_name] = gateway
|
if gateway_name is None:
|
||||||
|
gateway_name = gateway.gateway_name
|
||||||
|
self.gateways[gateway_name] = gateway
|
||||||
|
|
||||||
# Add gateway supported exchanges into engine
|
# Add gateway supported exchanges into engine
|
||||||
for exchange in gateway.exchanges:
|
for exchange in gateway.exchanges:
|
||||||
|
@ -137,6 +137,7 @@ class OrderData(BaseData):
|
|||||||
traded: float = 0
|
traded: float = 0
|
||||||
status: Status = Status.SUBMITTING
|
status: Status = Status.SUBMITTING
|
||||||
time: str = ""
|
time: str = ""
|
||||||
|
cancel_time: str = ""
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
""""""
|
""""""
|
||||||
@ -179,6 +180,8 @@ class TradeData(BaseData):
|
|||||||
price: float = 0
|
price: float = 0
|
||||||
volume: float = 0
|
volume: float = 0
|
||||||
time: str = ""
|
time: str = ""
|
||||||
|
datetime: datetime = None
|
||||||
|
strategy_name: str = ""
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
""""""
|
""""""
|
||||||
|
@ -177,6 +177,10 @@ def generate_vt_symbol(symbol: str, exchange: Exchange):
|
|||||||
"""
|
"""
|
||||||
return f"{symbol}.{exchange.value}"
|
return f"{symbol}.{exchange.value}"
|
||||||
|
|
||||||
|
def format_number(n):
|
||||||
|
"""格式化数字到字符串"""
|
||||||
|
rn = round(n, 2) # 保留两位小数
|
||||||
|
return format(rn, ',') # 加上千分符
|
||||||
|
|
||||||
def _get_trader_dir(temp_name: str):
|
def _get_trader_dir(temp_name: str):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user