mns-common 1.4.40__py3-none-any.whl → 1.5.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mns-common might be problematic. Click here for more details.
- mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py +4 -2
- mns_common/api/k_line/stock_k_line_data_api.py +11 -1
- mns_common/component/deal/deal_service_v2_api.py +167 -0
- {mns_common-1.4.40.dist-info → mns_common-1.5.0.1.dist-info}/METADATA +1 -1
- {mns_common-1.4.40.dist-info → mns_common-1.5.0.1.dist-info}/RECORD +7 -6
- {mns_common-1.4.40.dist-info → mns_common-1.5.0.1.dist-info}/WHEEL +0 -0
- {mns_common-1.4.40.dist-info → mns_common-1.5.0.1.dist-info}/top_level.txt +0 -0
|
@@ -166,7 +166,8 @@ def sync_stock_gdfx_free_top_10(stock_gdfx_free_top_10_em_df, period, symbol, st
|
|
|
166
166
|
stock_gdfx_free_top_10_em_df['str_day'] = str_day
|
|
167
167
|
|
|
168
168
|
stock_gdfx_free_top_10_em_df['symbol'] = symbol
|
|
169
|
-
stock_gdfx_free_top_10_em_df[
|
|
169
|
+
stock_gdfx_free_top_10_em_df[
|
|
170
|
+
'_id'] = symbol + '_' + period + '_' + stock_gdfx_free_top_10_em_df.shareholder_name
|
|
170
171
|
stock_gdfx_free_top_10_em_df['period'] = period
|
|
171
172
|
|
|
172
173
|
query_exist = {'symbol': symbol, 'period': period}
|
|
@@ -187,7 +188,7 @@ def sync_stock_gdfx_top_10(stock_gdfx_top_10_em_df, period, symbol, str_day):
|
|
|
187
188
|
if stock_gdfx_top_10_em_df is not None and stock_gdfx_top_10_em_df.shape[0] > 0:
|
|
188
189
|
stock_gdfx_top_10_em_df['str_day'] = str_day
|
|
189
190
|
stock_gdfx_top_10_em_df['symbol'] = symbol
|
|
190
|
-
stock_gdfx_top_10_em_df['_id'] = symbol +
|
|
191
|
+
stock_gdfx_top_10_em_df['_id'] = symbol + '_' + period + '_' + stock_gdfx_top_10_em_df.shareholder_name
|
|
191
192
|
stock_gdfx_top_10_em_df['period'] = period
|
|
192
193
|
|
|
193
194
|
query_exist = {'symbol': symbol, 'period': period}
|
|
@@ -213,6 +214,7 @@ def sync_stock_gdfx_free_top_10_one_day(str_day):
|
|
|
213
214
|
get_stock_gdfx_free_top_10_em(str_day, real_time_one.symbol)
|
|
214
215
|
except BaseException as e:
|
|
215
216
|
logger.error('同步所有股票前十大流通股本异常:{},{}', real_time_one.symbol, e)
|
|
217
|
+
logger.info('同步所有股票股东列表完成:{}', str_day)
|
|
216
218
|
|
|
217
219
|
|
|
218
220
|
from datetime import datetime
|
|
@@ -16,6 +16,7 @@ def stock_k_line_hist(
|
|
|
16
16
|
end_date: str = "20500101",
|
|
17
17
|
adjust: str = "",
|
|
18
18
|
timeout: float = None,
|
|
19
|
+
proxies: str = None
|
|
19
20
|
) -> pd.DataFrame:
|
|
20
21
|
"""
|
|
21
22
|
东方财富网-行情首页-沪深京 A 股-每日行情
|
|
@@ -32,6 +33,9 @@ def stock_k_line_hist(
|
|
|
32
33
|
:type adjust: str
|
|
33
34
|
:param timeout: choice of None or a positive float number
|
|
34
35
|
:type timeout: float
|
|
36
|
+
:param proxies: 代理ip
|
|
37
|
+
:type proxies: str
|
|
38
|
+
|
|
35
39
|
:return: 每日行情
|
|
36
40
|
:rtype: pandas.DataFrame
|
|
37
41
|
"""
|
|
@@ -49,7 +53,12 @@ def stock_k_line_hist(
|
|
|
49
53
|
"end": end_date,
|
|
50
54
|
"_": "1623766962675",
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
|
|
57
|
+
if proxies is None:
|
|
58
|
+
|
|
59
|
+
r = requests.get(url, params=params, timeout=timeout)
|
|
60
|
+
else:
|
|
61
|
+
r = requests.get(url, params=params, proxies=proxies, timeout=timeout)
|
|
53
62
|
data_json = r.json()
|
|
54
63
|
if not (data_json["data"] and data_json["data"]["klines"]):
|
|
55
64
|
return pd.DataFrame()
|
|
@@ -103,4 +112,5 @@ if __name__ == '__main__':
|
|
|
103
112
|
"19700101",
|
|
104
113
|
"20500101",
|
|
105
114
|
"",
|
|
115
|
+
None,
|
|
106
116
|
None)
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 16
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
import json
|
|
9
|
+
import requests
|
|
10
|
+
|
|
11
|
+
'''
|
|
12
|
+
|
|
13
|
+
'''
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def trade_buy(symbol, buy_price, buy_volume, terminal):
|
|
17
|
+
'''
|
|
18
|
+
买入
|
|
19
|
+
:param symbol:
|
|
20
|
+
:param buy_price:
|
|
21
|
+
:param buy_volume:
|
|
22
|
+
:param terminal:
|
|
23
|
+
:return:
|
|
24
|
+
'''
|
|
25
|
+
param_buy = {
|
|
26
|
+
'symbol': symbol,
|
|
27
|
+
'buy_price': buy_price,
|
|
28
|
+
'buy_volume': buy_volume,
|
|
29
|
+
'terminal': terminal}
|
|
30
|
+
param_json = json.dumps(param_buy)
|
|
31
|
+
response = request_trader_post('/buy', param_json)
|
|
32
|
+
if response.status_code != 200:
|
|
33
|
+
buy_result = {"message": '买入失败'}
|
|
34
|
+
else:
|
|
35
|
+
buy_result = response.json()
|
|
36
|
+
return buy_result
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def trade_sell(symbol, sell_price, sell_volume, terminal):
|
|
40
|
+
'''
|
|
41
|
+
卖出
|
|
42
|
+
:param symbol:
|
|
43
|
+
:param sell_price:
|
|
44
|
+
:param sell_volume:
|
|
45
|
+
:param terminal:
|
|
46
|
+
:return:
|
|
47
|
+
'''
|
|
48
|
+
param_sell = {
|
|
49
|
+
'symbol': symbol,
|
|
50
|
+
'sell_price': sell_price,
|
|
51
|
+
'sell_volume': sell_volume,
|
|
52
|
+
'terminal': terminal}
|
|
53
|
+
param_json = json.dumps(param_sell)
|
|
54
|
+
response = request_trader_post('/sell', param_json)
|
|
55
|
+
if response.status_code != 200:
|
|
56
|
+
sell_result = {"message": '卖出失败'}
|
|
57
|
+
else:
|
|
58
|
+
sell_result = response.json()
|
|
59
|
+
return sell_result
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def auto_ipo_buy(terminal):
|
|
63
|
+
'''
|
|
64
|
+
自动打新
|
|
65
|
+
:param terminal:
|
|
66
|
+
:return:
|
|
67
|
+
'''
|
|
68
|
+
param_auto_ipo = {
|
|
69
|
+
'terminal': terminal}
|
|
70
|
+
param_json = json.dumps(param_auto_ipo)
|
|
71
|
+
response = request_trader_get('/auto/ipo/buy', param_json)
|
|
72
|
+
if response.status_code != 200:
|
|
73
|
+
result = {"message": '自动打新失败'}
|
|
74
|
+
else:
|
|
75
|
+
result = response.json()
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def get_position(terminal):
|
|
80
|
+
'''
|
|
81
|
+
获取持仓
|
|
82
|
+
:param terminal:
|
|
83
|
+
:return:
|
|
84
|
+
'''
|
|
85
|
+
param_position = {
|
|
86
|
+
'terminal': terminal}
|
|
87
|
+
param_json = json.dumps(param_position)
|
|
88
|
+
response = request_trader_get('/position', param_json)
|
|
89
|
+
if response.status_code != 200:
|
|
90
|
+
result = {"message": '获取持仓失败'}
|
|
91
|
+
else:
|
|
92
|
+
result = response.json()
|
|
93
|
+
return result
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def order_cancel(entrust_no, terminal):
|
|
97
|
+
'''
|
|
98
|
+
撤单
|
|
99
|
+
:param entrust_no:
|
|
100
|
+
:param terminal:
|
|
101
|
+
:return:
|
|
102
|
+
'''
|
|
103
|
+
param_cancel = {
|
|
104
|
+
"entrust_no": entrust_no,
|
|
105
|
+
'terminal': terminal}
|
|
106
|
+
param_json = json.dumps(param_cancel)
|
|
107
|
+
response = request_trader_post('/cancel', param_json)
|
|
108
|
+
if response.status_code != 200:
|
|
109
|
+
result = {"message": '撤单失败'}
|
|
110
|
+
else:
|
|
111
|
+
result = response.json()
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# 自动登陆接口
|
|
116
|
+
def auto_login(terminal):
|
|
117
|
+
'''
|
|
118
|
+
自动登陆客户端
|
|
119
|
+
:param terminal:
|
|
120
|
+
:return:
|
|
121
|
+
'''
|
|
122
|
+
param_position = {
|
|
123
|
+
'terminal': terminal}
|
|
124
|
+
param_json = json.dumps(param_position)
|
|
125
|
+
response = request_trader_post('/auto/login', param_json)
|
|
126
|
+
if response.status_code != 200:
|
|
127
|
+
result = {"message": '获取持仓失败'}
|
|
128
|
+
else:
|
|
129
|
+
result = response.json()
|
|
130
|
+
return result
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def request_trader_post(url, param):
|
|
134
|
+
total_url = "http://127.0.0.1:5002/api/trade" + url
|
|
135
|
+
headers = {
|
|
136
|
+
"Content-Type": "application/json"
|
|
137
|
+
}
|
|
138
|
+
return requests.post(total_url, data=param, headers=headers)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def request_trader_get(url, param):
|
|
142
|
+
total_url = "http://127.0.0.1:5002/api/trade" + url
|
|
143
|
+
headers = {
|
|
144
|
+
"Content-Type": "application/json"
|
|
145
|
+
}
|
|
146
|
+
return requests.get(total_url, data=param, headers=headers)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if __name__ == '__main__':
|
|
150
|
+
# auto_login('qmt')
|
|
151
|
+
# get_position('qmt')
|
|
152
|
+
# terminal_test = 'easy_trader'
|
|
153
|
+
# order_cancel('251145121', terminal_test)
|
|
154
|
+
# get_position(terminal_test)
|
|
155
|
+
# auto_ipo_buy(terminal_test)
|
|
156
|
+
buy_result_test = trade_buy(
|
|
157
|
+
'688693.SH',
|
|
158
|
+
36.39,
|
|
159
|
+
1000,
|
|
160
|
+
'ths')
|
|
161
|
+
entrust_no_test = buy_result_test['entrust_no']
|
|
162
|
+
order_cancel(entrust_no_test, 'ths')
|
|
163
|
+
# trade_sell(
|
|
164
|
+
# '301314',
|
|
165
|
+
# 35.77,
|
|
166
|
+
# 100,
|
|
167
|
+
# 'easy_trader')
|
|
@@ -11,7 +11,7 @@ mns_common/api/em/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0
|
|
|
11
11
|
mns_common/api/em/concept/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
12
12
|
mns_common/api/em/concept/em_concept_index_api.py,sha256=PP87ES8a_y0o3SKLzBsPrc7DCPI3MBCD-4SmoUUirl0,8285
|
|
13
13
|
mns_common/api/em/gd/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
14
|
-
mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py,sha256=
|
|
14
|
+
mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py,sha256=m0zMMAOaeSKyJniIQxnIP2KC3Q3MNp7ZSEOEkaMwBR0,10604
|
|
15
15
|
mns_common/api/em/real_time/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
16
16
|
mns_common/api/em/real_time/east_money_debt_api.py,sha256=jMvMZtlrDfExl_4jZ1hepHX8rUoeVLoLSOIhRBjkUGk,14753
|
|
17
17
|
mns_common/api/em/real_time/east_money_etf_api.py,sha256=tCyH4fNx-KfVRFuNGkgM8d_xkvR0oAfr8T3e7_XrjTM,14414
|
|
@@ -22,7 +22,7 @@ mns_common/api/em/real_time/east_money_stock_us_api.py,sha256=RiTrdZDuDgTOtiMSD1
|
|
|
22
22
|
mns_common/api/hk/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
23
23
|
mns_common/api/hk/ths_hk_company_info_api.py,sha256=Cxlbuccopa0G1s8o0uTnnyLn2QaxOvbDpJQJOj7J8a8,5360
|
|
24
24
|
mns_common/api/k_line/__init__.py,sha256=itoGlqKhsx7EVXQoD1vchDKQ5GPB16vDjofTSuQtrXg,161
|
|
25
|
-
mns_common/api/k_line/stock_k_line_data_api.py,sha256=
|
|
25
|
+
mns_common/api/k_line/stock_k_line_data_api.py,sha256=oOtgSRik-F36FWdcWVIRlyYC2rCePvmZEjONFh1yjkk,3724
|
|
26
26
|
mns_common/api/k_line/stock_minute_data_api.py,sha256=FNe9I_lvgdyEsKQVzdA0vZ5CWeB-KGtJiCpj0YPRuwY,5322
|
|
27
27
|
mns_common/api/kpl/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
28
28
|
mns_common/api/kpl/common/__init__.py,sha256=8b2PuXJM5fLoq71cWPXp695czQuaRtyR6OVHajGjDPc,161
|
|
@@ -92,6 +92,7 @@ mns_common/component/data/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3
|
|
|
92
92
|
mns_common/component/data/data_init_api.py,sha256=VFPmjk_Js16q42l3h1o__6DU1Dpnbf0BJlCBksU12q8,5355
|
|
93
93
|
mns_common/component/deal/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
94
94
|
mns_common/component/deal/deal_service_api.py,sha256=XV_L8qfeTPbojmNXFjnUe-5ZTp3ADT3ett0j-gPuPVI,3806
|
|
95
|
+
mns_common/component/deal/deal_service_v2_api.py,sha256=QmiMQeaCGV8Izuilihp_1_h3s2rCQUg8Lf6Qay5qX3A,4184
|
|
95
96
|
mns_common/component/deal/terminal_enum.py,sha256=JUkSTXLQW1fob05PCCzIBg_VKlGmqaJEa0GOvrQH6e0,275
|
|
96
97
|
mns_common/component/em/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
97
98
|
mns_common/component/em/em_real_time_quotes_api.py,sha256=9VAwzj_am-Jd4zG57bhrVjXrrsytzymSu8CIs7T7Lc0,2144
|
|
@@ -156,7 +157,7 @@ mns_common/utils/date_handle_util.py,sha256=XS-MyA8_7k35LOCFAYOHgVcVkMft_Kc4Wa9U
|
|
|
156
157
|
mns_common/utils/db_util.py,sha256=hSmfNAN4vEeEaUva6_cicZEhb2jSnib-Gvk2reke1vc,2590
|
|
157
158
|
mns_common/utils/file_util.py,sha256=egWu6PenGPRp_ixrNTHKarT4dAnOT6FETR82EHUZJnQ,1042
|
|
158
159
|
mns_common/utils/ip_util.py,sha256=UTcYfz_uytB__6nlBf7T-izuI7hi4XdB6ET0sJgEel4,969
|
|
159
|
-
mns_common-1.
|
|
160
|
-
mns_common-1.
|
|
161
|
-
mns_common-1.
|
|
162
|
-
mns_common-1.
|
|
160
|
+
mns_common-1.5.0.1.dist-info/METADATA,sha256=s39Ru9_jwa3fZ315Ua1TJAyY-RoWdtrZwilleSyjI40,61
|
|
161
|
+
mns_common-1.5.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
162
|
+
mns_common-1.5.0.1.dist-info/top_level.txt,sha256=ZC58kAR-8Hvc6U2xhYNBNLAh3mb6sZazbdj5nZpvEkQ,11
|
|
163
|
+
mns_common-1.5.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|