瀏覽代碼

freemaker, stock 추가

tobby48 5 年之前
父節點
當前提交
90992549fb

+ 13
- 22
src/main/java/kr/co/swh/lecture/opensource/sparkjava/FreeMarkerTemplateEngine.java 查看文件

@@ -1,10 +1,8 @@
1 1
 package kr.co.swh.lecture.opensource.sparkjava;
2 2
 
3
-import java.io.File;
4 3
 import java.io.IOException;
5 4
 import java.io.StringWriter;
6 5
 
7
-import freemarker.cache.FileTemplateLoader;
8 6
 import freemarker.template.Configuration;
9 7
 import freemarker.template.Template;
10 8
 import freemarker.template.TemplateException;
@@ -14,27 +12,14 @@ import spark.TemplateEngine;
14 12
 public class FreeMarkerTemplateEngine extends TemplateEngine {
15 13
 
16 14
     private Configuration configuration;
17
-    private final String PATH = "src/main/resources/freemaker";
18
-    		
19
-    public FreeMarkerTemplateEngine() throws IOException {
20
-//        this.configuration = createFreemarkerConfiguration();
21
-    	configuration.setClassForTemplateLoading(FreeMarkerTemplateEngine.class, "/");
22
-        FileTemplateLoader templateLoader = new FileTemplateLoader(new File("resources"));
23
-        configuration.setTemplateLoader(templateLoader);
24
-
25
-//        Template helloTemp= configuration.getTemplate("hello.ftl");
26
-    }
27 15
 
28
-//    private Configuration createFreemarkerConfiguration() {
29
-//        Configuration retVal = new Configuration();
30
-//        retVal.setClassForTemplateLoading(FreeMarkerTemplateEngine.class, "freemarker");
31
-//        return retVal;
32
-//    }
16
+    protected FreeMarkerTemplateEngine() {
17
+        this.configuration = createFreemarkerConfiguration();
18
+    }
33 19
 
34
-	@Override
35
-	public String render(ModelAndView modelAndView) {
36
-		// TODO Auto-generated method stub
37
-		try {
20
+    @Override
21
+    public String render(ModelAndView modelAndView) {
22
+        try {
38 23
             StringWriter stringWriter = new StringWriter();
39 24
 
40 25
             Template template = configuration.getTemplate(modelAndView.getViewName());
@@ -46,5 +31,11 @@ public class FreeMarkerTemplateEngine extends TemplateEngine {
46 31
         } catch (TemplateException e) {
47 32
             throw new IllegalArgumentException(e);
48 33
         }
49
-	}
34
+    }
35
+
36
+    private Configuration createFreemarkerConfiguration() {
37
+        Configuration retVal = new Configuration();
38
+        retVal.setClassForTemplateLoading(FreeMarkerTemplateEngine.class, "/freemarker/");	//	수정할 것.
39
+        return retVal;
40
+    }
50 41
 }

+ 1236
- 0
src/main/python/kr/co/swh/lecture/opensource/stock/project/NSE-TATAGLOBAL11.csv
文件差異過大導致無法顯示
查看文件


+ 2
- 0
src/main/python/kr/co/swh/lecture/opensource/stock/project/step1.py 查看文件

@@ -0,0 +1,2 @@
1
+import numpy as np
2
+np.__version__

+ 28
- 0
src/main/python/kr/co/swh/lecture/opensource/stock/project/step2.py 查看文件

@@ -0,0 +1,28 @@
1
+# pip install scikit-learn
2
+# pip install pandas
3
+# pip install numpy
4
+# pip install matplotlib
5
+
6
+from comtypes.npsupport import numpy
7
+
8
+#import packages
9
+import pandas as pd
10
+import numpy as np
11
+
12
+#to plot within notebook
13
+import matplotlib.pyplot as plt
14
+#%matplotlib inline
15
+
16
+#setting figure size
17
+from matplotlib.pylab import rcParams
18
+rcParams['figure.figsize'] = 20,10
19
+
20
+#for normalizing data
21
+from sklearn.preprocessing import MinMaxScaler
22
+scaler = MinMaxScaler(feature_range=(0, 1))
23
+
24
+#read the file
25
+df = pd.read_csv('NSE-TATAGLOBAL(1).csv')
26
+
27
+#print the head
28
+df.head()

+ 6
- 0
src/main/python/kr/co/swh/lecture/opensource/stock/stock_list.py 查看文件

@@ -0,0 +1,6 @@
1
+import pandas as pd
2
+
3
+df = pd.read_html('http://kind.krx.co.kr/corpgeneral/corpList.do?method=download&searchType=13', header=0)[0]
4
+
5
+print(df)
6
+df.head()

+ 13
- 0
src/main/python/kr/co/swh/lecture/opensource/stock/stock_list2.py 查看文件

@@ -0,0 +1,13 @@
1
+from pykrx import stock
2
+
3
+tickers = stock.get_market_ticker_list()
4
+print(tickers)
5
+
6
+tickers = stock.get_market_ticker_list("200115")
7
+print(tickers)
8
+
9
+종목 = stock.get_market_ticker_name("000660")
10
+print(종목)
11
+
12
+df = stock.get_market_ohlcv_by_date("20200101", "20200116", "000660")
13
+print(df.head(3))

+ 1
- 0
src/main/resources/freemarker/hello.ftl 查看文件

@@ -0,0 +1 @@
1
+<h1>${message}</h1>