市场通
# 市场通(沪港通,深港通和港股通)
# 市场通交易日历
xtdata.get_trading_dates(market, start_time='', end_time='', count=-1)
1
获取交易日列表
参数:
market
- string 市场代码start_time
- string 起始时间end_time
- string 结束时间count
- int 数据个数
返回
list
时间戳列表,[ date1, date2, ... ]
# 获取沪港通交易日历
xtdata.get_trading_dates(market = "HGT", start_time='', end_time='', count=-1)
# 获取上海市场交易日历
xtdata.get_trading_dates(market = "SH", start_time='', end_time='', count=-1)
1
2
3
4
5
2
3
4
5
# 获取对应周期的北向数据(仅支持内部python)
C.get_north_finance_change(period)
1
获取对应周期的北向数据
参数:
- period:1d日线数据1m一分钟数据
返回结果:
- 根据period返回一个dict,该字典的key值是北向数据的时间戳,其值仍然是一个dict,其值的key值是北向数据的字段类型,其值是对应字段的值。该字典数据key值有:
字段名 | 描述 |
---|---|
hgtNorthBuyMoney | HGT北向买入资金 |
hgtNorthSellMoney | HGT北向卖出资金 |
hgtSouthBuyMoney | HGT南向买入资金 |
hgtSouthSellMoney | HGT南向卖出资金 |
sgtNorthBuyMoney | SGT北向买入资金 |
sgtNorthSellMoney | SGT北向卖出资金 |
sgtSouthBuyMoney | SGT南向买入资金 |
sgtSouthSellMoney | SGT南向卖出资金 |
hgtNorthNetInFlow | HGT北向资金净流入 |
hgtNorthBalanceByDay | HGT北向当日资金余额 |
hgtSouthNetInFlow | HGT南向资金净流入 |
hgtSouthBalanceByDay | HGT南向当日资金余额 |
sgtNorthNetInFlow | SGT北向资金净流入 |
sgtNorthBalanceByDay | SGT北向当日资金余额 |
sgtSouthNetInFlow | SGT南向资金净流入 |
sgtSouthBalanceByDay | SGT南向当日资金余额 |
示例:
# 获取市场北向数据
def handlebar(ContextInfo):
ContextInfo.get_north_finance_change('1d')
# 返回
'''
{1416153600000: {'hgtNorthBuyMoney': 120820000, 'hgtNorthSellMoney': 0,
'hgtSouthBuyMoney': 1772000000, 'hgtSouthSellMoney': 84000000,
'sgtNorthBuyMoney': 0, 'sgtNorthSellMoney': 0, 'sgtSouthBuyMoney': 0,
'sgtSouthSellMoney': 0, 'hgtNorthNetInFlow': 13000000000, 'hgtNorthBalanceByDay': 0,
'hgtSouthNetInFlow': 1768000000, 'hgtSouthBalanceByDay': 8732000000,
'sgtNorthNetInFlow': 0, 'sgtNorthBalanceByDay': 0, 'sgtSouthNetInFlow': 0, 'sgtSouthBalanceByDay': 0}}
'''
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 市场通汇率(仅支持内部python)
get_hkt_exchange_rate(accountID,accountType)
1
获取沪深港通汇率数据
参数:
- accountID:string,账号
- accountType:string,账号类型,必须填HUGANGTONG或者SHENGANGTONG
返回: dict
,字段释义:
- bidReferenceRate:买入参考汇率
- askReferenceRate:卖出参考汇率
- dayBuyRiseRate:日间买入参考汇率浮动比例
- daySaleRiseRate:日间卖出参考汇率浮动比例
示例:
def init(ContextInfo):
data=get_hkt_exchange_rate('6000000248','HUGANGTONG')
print(data)
1
2
3
4
2
3
4
# 沪深港通持股数据
C.get_hkt_details(stockcode)
1
获取指定品种的持股明细
参数:
- stockcode:string,必须是'stock.market'形式
返回结果:
- 根据stockcode返回一个dict,该字典的key值是北向持股明细数据的时间戳,其值仍然是一个dict,其值的key值是北向持股明细数据的字段类型,其值是对应字段的值,该字典数据key值有:
示例:
def handlebar(C):
data = C.get_hkt_details('600000.SH')
print(data)
# 返回值
'''
{1696694400053: {'stockCode': '600000.SH', 'ownSharesCompany': '香港中央结算有限公司',
'ownSharesAmount': 15, 'ownSharesMarketValue': 106.50000000000001,
'ownSharesRatio': 0.0, 'ownSharesNetBuy': 0.0}}
'''
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
上次更新: 2023/10/12, 10:46:32