util.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. import bus from '@/api/bus'
  2. // console.log(bus.$i18nt.t('EtaBasePage.future_common_edb'))
  3. /* 公用校验 计算指标 */
  4. export const formRules= {
  5. targetName: [
  6. { required: true, message: bus.$i18nt.t('Edb.Valids.name_msg'), trigger: 'blur' },
  7. ],
  8. unit: [
  9. { required: true, message: /* '单位不能为空' */bus.$i18nt.t('Edb.Valids.unit_msg'), trigger: ['blur','change'] },
  10. ],
  11. menu: [
  12. { required: true, message: /* '指标目录不能为空' */bus.$i18nt.t('Edb.Valids.menu_msg'), trigger: 'blur' },
  13. ],
  14. frequency: [
  15. { required: true, message: /* '频度不能为空' */bus.$i18nt.t('Edb.Valids.fre_msg'), trigger: 'blur' },
  16. ],
  17. n_num: [
  18. { required: true, message: /* 'N不能为空' */bus.$i18nt.t('Edb.Valids.n_msg'), trigger: 'blur' },
  19. ],
  20. moveVal: [
  21. { required: true, message: /* '移动方式参数不能为空' */bus.$i18nt.t('Edb.Valids.move_msg'),trigger: 'blur' }
  22. ],
  23. calendar_type: [
  24. { required: true, message: /* '日历不能为空' */bus.$i18nt.t('Edb.Valids.calendar_msg'),trigger: 'blur' }
  25. ],
  26. alphaValue:[
  27. { validator:(rule,value,callback)=>{
  28. if(Number(value)<=0||Number(value)>=1){
  29. callback(new Error(bus.$i18nt.t('Edb.Valids.alpha_value_vaild')))
  30. }else{
  31. callback()
  32. }
  33. },trigger:['change','blur']},
  34. { required:true,message:/* 'alpha值不能为空' */bus.$i18nt.t('Edb.Valids.alpha_msg'),trigger:'blur'},
  35. ]
  36. }
  37. //计算指标弹窗类型
  38. export const computedTypes = [
  39. {
  40. name:/* '指标运算' */bus.$i18nt.t('Edb.CalculatesAll.calculate'),
  41. type:4
  42. },
  43. {
  44. name:/* '累计值转月/季值' */bus.$i18nt.t('Edb.CalculatesAll.to_month_quarter'),
  45. type:'toMonthSeason'
  46. },
  47. {
  48. name:/* '同比值' */bus.$i18nt.t('Edb.CalculatesAll.on_year'),
  49. type:6
  50. },
  51. {
  52. name:/* '同差值' */bus.$i18nt.t('Edb.CalculatesAll.differ'),
  53. type:7
  54. },
  55. {
  56. name:/* 'N数值移动平均计算' */bus.$i18nt.t('Edb.CalculatesAll.n_move_average'),
  57. type:8
  58. },
  59. {
  60. name:/* 'N数值环比值' */bus.$i18nt.t('Edb.CalculatesAll.n_rate'),
  61. type:12
  62. },
  63. {
  64. name:/* 'N数值环差值' */bus.$i18nt.t('Edb.CalculatesAll.n_differ'),
  65. type:13
  66. },
  67. {
  68. name:/* '升频' */bus.$i18nt.t('Edb.CalculatesAll.up_conver'),
  69. type:14
  70. },
  71. {
  72. name:/* '指标拼接' */bus.$i18nt.t('Edb.CalculatesAll.splic'),
  73. type: 'joint'
  74. },
  75. {
  76. name: /* '时间移位' */bus.$i18nt.t('Edb.CalculatesAll.time_move'),
  77. type: 22
  78. },
  79. {
  80. name: /* '超季节性' */bus.$i18nt.t('Edb.CalculatesAll.super_season'),
  81. type: 35
  82. },
  83. {
  84. name: /* '拟合残差' */bus.$i18nt.t('Edb.CalculatesAll.fit_residu'),
  85. type: 37
  86. },
  87. {
  88. name: /* '年化' */bus.$i18nt.t('Edb.CalculatesAll.annual'),
  89. type: 52
  90. },
  91. {
  92. name: /* '降频' */bus.$i18nt.t('Edb.CalculatesAll.down_conver'),
  93. type: 51
  94. },
  95. {
  96. name: /* '扩散指数' */bus.$i18nt.t('Edb.CalculatesAll.diff_index'),
  97. type: 53
  98. },
  99. {
  100. name: /* '累计值' */bus.$i18nt.t('Edb.CalculatesAll.cumulate'),
  101. type: 'accumulate'
  102. },
  103. {
  104. name:/* '指数修匀' */bus.$i18nt.t('Edb.CalculatesAll.ex_smooth'),
  105. type:'alpha'
  106. },
  107. {
  108. name:/* '日均值' */bus.$i18nt.t('Edb.CalculatesAll.day_mean'),
  109. type: 75
  110. }
  111. ]
  112. //批量指标类型
  113. export const computedBatchTypes = [
  114. {
  115. name:/* '同比值' */bus.$i18nt.t('Edb.CalculatesAll.on_year'),
  116. type:6
  117. },
  118. {
  119. name:/* '同差值' */bus.$i18nt.t('Edb.CalculatesAll.differ'),
  120. type:7
  121. },
  122. {
  123. name:/* 'N数值移动平均计算' */bus.$i18nt.t('Edb.CalculatesAll.n_move_average'),
  124. type:8
  125. },
  126. {
  127. name:/* 'N数值环比值' */bus.$i18nt.t('Edb.CalculatesAll.n_rate'),
  128. type:12
  129. },
  130. {
  131. name:/* 'N数值环差值' */bus.$i18nt.t('Edb.CalculatesAll.n_differ'),
  132. type:13
  133. },
  134. {
  135. name:/* '升频' */bus.$i18nt.t('Edb.CalculatesAll.up_conver'),
  136. type:14
  137. },
  138. {
  139. name:/* '累计值转月/季值' */bus.$i18nt.t('Edb.CalculatesAll.to_month_quarter'),
  140. type:'toMonthSeason'
  141. },
  142. {
  143. name: /* '累计值' */bus.$i18nt.t('Edb.CalculatesAll.cumulate'),
  144. type: 'accumulate'
  145. },
  146. {
  147. name:/* '指数修匀' */bus.$i18nt.t('Edb.CalculatesAll.ex_smooth'),
  148. type:'alpha'
  149. },
  150. {
  151. name:/* '日均值' */bus.$i18nt.t('Edb.CalculatesAll.day_mean'),
  152. type: 75
  153. }
  154. ]
  155. //批量指标类型
  156. export const computedBatchTypesV2=[
  157. {
  158. name:'同比值',
  159. type:6
  160. },
  161. {
  162. name:'同差值',
  163. type:7
  164. },
  165. {
  166. name:'累计值转月/季值',
  167. type:'toMonthSeason'
  168. },
  169. {
  170. name:'N期移动均值',
  171. type:8
  172. },
  173. {
  174. name:'N期环比值',
  175. type:12
  176. },
  177. {
  178. name:'N期环差值',
  179. type:13
  180. },
  181. {
  182. name:'升频',
  183. type:14
  184. },
  185. {
  186. name:'超级季节性',
  187. type:35
  188. },
  189. {
  190. name:'年化值',
  191. type:52
  192. },
  193. {
  194. name:'降频',
  195. type:51
  196. },
  197. {
  198. name: '累计值',
  199. type: 'accumulate'
  200. },
  201. {
  202. name:'指数修匀',
  203. type:72
  204. },
  205. {
  206. name:'日均值',
  207. type: 75
  208. },
  209. {
  210. name:'与常数计算',
  211. type:'withNum'
  212. },
  213. {
  214. name:'与单指标计算',
  215. type:'withEDB'
  216. },
  217. {
  218. name:'多指标求和/平均',
  219. type:'multipleEDB',//81求和 82求平均
  220. },
  221. ]
  222. //频度
  223. export const frequencyArr = ['日度','周度','旬度','月度','季度','年度'];
  224. //添加基础指标来源 已改为从接口获取 datamanage/edb_source/list
  225. export const fromArr = ['wind','同花顺','彭博','彭博财务','路透','手工指标','隆众指标','SMM','Mysteel','郑商所',
  226. '大商所','上期所','中金所','上期能源','欧洲天然气','中国煤炭市场网','谷歌出行指数','EIA STEO报告','UN','卓创数据(红桃3)',
  227. '百川盈孚','国家统计局','富宝数据'];
  228. // 已改为从接口获取 datamanage/edb_source/list
  229. export const fromCode = new Map([
  230. ['同花顺','1'],
  231. ['wind','2'],
  232. ['SMM','11'],
  233. ['彭博','3'],
  234. ['彭博财务','28'],
  235. ['路透','25'],
  236. ['手工指标','9'],
  237. ['隆众指标','10'],
  238. ['Mysteel','15'],
  239. ['郑商所','16'],
  240. ['大商所','17'],
  241. ['上期所','18'],
  242. ['中金所','19'],
  243. ['上期能源','20'],
  244. ['欧洲天然气','21'],
  245. ['中国煤炭市场网','26'],
  246. ['谷歌出行指数','29'],
  247. ['EIA STEO报告','36'],
  248. ['UN','38'],
  249. ['卓创数据(红桃3)','41'],
  250. ['百川盈孚','57'],
  251. ['国家统计局','60'],
  252. ['富宝数据','71']
  253. ]);
  254. //所有来源 只用于pycode代码运算 别问我我也不知道为什么每个地方要用不一样的来源
  255. export const allFromArr = [
  256. { name: 'wind',key: 2 },
  257. { name: '同花顺',key: 1 },
  258. { name: '彭博',key: 3 },
  259. { name:'彭博财务',key:28},
  260. { name: '路透', key: 25 },
  261. { name: '手工指标', key: 9 },
  262. { name: '隆众指标', key: 10 },
  263. { name: 'SMM', key: 11 },
  264. { name: 'Mysteel', key: 15 },
  265. { name: '郑商所', key: 16 },
  266. { name: '大商所', key: 17 },
  267. { name: '上期所', key: 18 },
  268. { name: '中金所', key: 19 },
  269. { name: '上期能源', key: 20 },
  270. { name: '欧洲天然气', key: 21 },
  271. { name: '中国煤炭网', key: 26 },
  272. { name: '指标运算',key: 4 },
  273. { name: '累计值转月',key: 5 },
  274. { name: '同比值', key: 6 },
  275. { name: '同差值', key: 7 },
  276. { name: 'N数值移动平均计算', key: 8 },
  277. { name: '环比值', key: 12 },
  278. { name: '环差值', key: 13 },
  279. { name: '变频',key: 14 },
  280. { name: '时间移位', key: 22 },
  281. { name: '直接拼接', key: 23 },
  282. { name: '累计值同比拼接', key: 24 },
  283. { name: 'python代码', key: 27 },
  284. { name: '谷歌出行指数' ,key:29},
  285. { name: '钢联化工' ,key:34},
  286. { name: 'EIA STEO报告' ,key:36},
  287. { name: 'UN' ,key:38},
  288. { name: '卓创数据(红桃3)' ,key:41},
  289. { name:'百川盈孚',key:57},
  290. { name: '存量装置',key:58 },
  291. { name:'国家统计局',key:60}
  292. ]
  293. //公式说明 eta指标库
  294. export const formulaTip = new Map([
  295. [4,bus.$i18nt.t('Edb.FormulaTips.calculate')], //指标运算
  296. [5,bus.$i18nt.t('Edb.FormulaTips.to_month')], //累计转月
  297. ['toMonthSeason',bus.$i18nt.t('Edb.FormulaTips.to_month_quarter')], //累计转月、转季
  298. [6,bus.$i18nt.t('Edb.FormulaTips.on_year')], //同比
  299. [7,bus.$i18nt.t('Edb.FormulaTips.differ')], //同差
  300. [8,bus.$i18nt.t('Edb.FormulaTips.n_move_average')], //n数值移动平均
  301. [12,bus.$i18nt.t('Edb.FormulaTips.n_rate')], //n数值环比
  302. [13,bus.$i18nt.t('Edb.FormulaTips.n_differ')],//n数值环差
  303. [14,bus.$i18nt.t('Edb.FormulaTips.up_conver')], //升频
  304. ['joint',bus.$i18nt.t('Edb.FormulaTips.splic')], //指标拼接
  305. [22,bus.$i18nt.t('Edb.FormulaTips.time_move')], //时间移位
  306. [35,bus.$i18nt.t('Edb.FormulaTips.super_season')], //超季节性
  307. [37,bus.$i18nt.t('Edb.FormulaTips.fit_residu')], //拟合残差
  308. [40,bus.$i18nt.t('Edb.FormulaTips.adjust_data')], //数据调整
  309. [52,bus.$i18nt.t('Edb.FormulaTips.annual')], //年化
  310. [51,bus.$i18nt.t('Edb.FormulaTips.down_conver')], //降频
  311. [53,bus.$i18nt.t('Edb.FormulaTips.diff_index')], //扩散指数
  312. ['accumulate',bus.$i18nt.t('Edb.FormulaTips.cumulate_and_toyear')], //累计值、年初至今累计
  313. [61,bus.$i18nt.t('Edb.FormulaTips.to_quarter')], //累计转季
  314. [62,bus.$i18nt.t('Edb.FormulaTips.cumulate_val')], //累计值
  315. [63,bus.$i18nt.t('Edb.FormulaTips.cumulate_to_year')], //年初至今累计值
  316. ['alpha',bus.$i18nt.t('Edb.FormulaTips.ex_smooth')], //指数修匀
  317. [75,bus.$i18nt.t('Edb.FormulaTips.day_mean')], //日均值
  318. ])
  319. // wind 日期序列常见指标代码
  320. export const windCommonIndexCodeArr=[
  321. {value:'pre_close',label:bus.$i18nt.t('EtaBasePage.pre_price')},
  322. {value:'open',label:bus.$i18nt.t('EtaBasePage.op_price')/* "开盘价" */},
  323. {value:'high',label:bus.$i18nt.t('EtaBasePage.high_price')/* "最高价" */},
  324. {value:'low',label:bus.$i18nt.t('EtaBasePage.low_price')/* "最低价" */},
  325. {value:'close',label:bus.$i18nt.t('EtaBasePage.close_price')/* "收盘价" */},
  326. {value:'settle',label:bus.$i18nt.t('EtaBasePage.settle_price')/* "结算价" */},
  327. {value:'volume',label:bus.$i18nt.t('EtaBasePage.trade_volume')/* "成交量" */},
  328. {value:'amt',label:bus.$i18nt.t('EtaBasePage.turnover')/* "成交额" */},
  329. {value:'pct_chg',label:bus.$i18nt.t('EtaBasePage.incre_decre')/* "涨跌幅" */},
  330. {value:'swing',label:bus.$i18nt.t('EtaBasePage.fluctua')/* "振幅" */},
  331. {value:'turn',label:bus.$i18nt.t('EtaBasePage.turn_rate')/* "换手率" */},
  332. {value:'oi',label:bus.$i18nt.t('EtaBasePage.open_inter')/* "持仓量" */},
  333. {value:'oiamount',label:bus.$i18nt.t('EtaBasePage.open_val')/* "持仓额" */}
  334. ]
  335. // 同花顺 日期序列常见 股票指标代码
  336. export const THSCommonIndexStockCodeArr=[
  337. {value:'ths_pre_close_stock',label:bus.$i18nt.t('EtaBasePage.pre_price')/* "前收盘价" */},
  338. {value:'ths_open_price_stock',label:bus.$i18nt.t('EtaBasePage.op_price')/* "开盘价" */},
  339. {value:'ths_high_price_stock',label:bus.$i18nt.t('EtaBasePage.high_price')/* "最高价" */},
  340. {value:'ths_low_stock',label:bus.$i18nt.t('EtaBasePage.low_price')/* "最低价" */},
  341. {value:'ths_close_price_stock',label:bus.$i18nt.t('EtaBasePage.close_price')/* "收盘价" */},
  342. {value:'ths_vol_stock',label:bus.$i18nt.t('EtaBasePage.trade_volume')/* "成交量" */},
  343. {value:'ths_amt_stock',label:bus.$i18nt.t('EtaBasePage.turnover')/* "成交额" */},
  344. {value:'ths_chg_ratio_stock',label:bus.$i18nt.t('EtaBasePage.incre_decre')/* "涨跌幅" */},
  345. {value:'ths_swing_stock',label:bus.$i18nt.t('EtaBasePage.fluctua')/* "振幅" */},
  346. {value:'ths_turnover_ratio_stock',label:bus.$i18nt.t('EtaBasePage.turn_rate')/* "换手率" */},
  347. ]
  348. // 同花顺 日期序列常见 指标代码
  349. export const THSCommonIndexFuturesCodeArr=[
  350. {value:'ths_pre_close_future',label:bus.$i18nt.t('EtaBasePage.pre_price')/* "前收盘价" */},
  351. {value:'ths_open_price_future',label:bus.$i18nt.t('EtaBasePage.op_price')/* "开盘价" */},
  352. {value:'ths_high_price_future',label:bus.$i18nt.t('EtaBasePage.high_price')/* "最高价" */},
  353. {value:'ths_low_future',label:bus.$i18nt.t('EtaBasePage.low_price')/* "最低价" */},
  354. {value:'ths_close_price_future',label:bus.$i18nt.t('EtaBasePage.close_price')/* "收盘价" */},
  355. {value:'ths_settle_future',label:bus.$i18nt.t('EtaBasePage.settle_price')/* "结算价" */},
  356. {value:'ths_vol_future',label:bus.$i18nt.t('EtaBasePage.trade_volume')/* "成交量" */},
  357. {value:'ths_amt_future',label:bus.$i18nt.t('EtaBasePage.turnover')/* "成交额" */},
  358. {value:'ths_chg_ratio_future',label:bus.$i18nt.t('EtaBasePage.incre_decre')/* "涨跌幅" */},
  359. {value:'ths_swing_d_future',label:bus.$i18nt.t('EtaBasePage.fluctua_day')/* "日振幅" */},
  360. {value:'ths_open_interest_future',label:bus.$i18nt.t('EtaBasePage.open_inter')/* "持仓量" */},
  361. ]
  362. // 生成序列数组
  363. export function generateSeriesArray(){
  364. let result = [];
  365. const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  366. for(let i=0;i<26;i++) result.push(String.fromCharCode(65+i))
  367. for (let i = 0; i < 26; i++) {
  368. const firstChar = alphabet[i];
  369. for (let j = 0; j < 26; j++) {
  370. const secondChar = alphabet[j];
  371. result.push(firstChar + secondChar);
  372. }
  373. }
  374. return result;
  375. }