main.py 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
# import pandas as pd
# import numpy as np
# import matplotlib.pyplot as plt
# import seaborn as sns
# import urllib.request as urllib2
# import json

# def findPairs():
#     ids = ['rb1903', 'rb1904', 'rb1905', 'rb1906', 'rb1907', 'rb1908']
#     url_5m = 'http://stock2.finance.sina.com.cn/futures/api/json.php/IndexService.getInnerFuturesMiniKLine5m?symbol='
#     result = []

#     for id in ids:
#         url = url_5m + id
#         # print(url)
#         req = urllib2.Request(url)
#         rsp = urllib2.urlopen(req)
#         res = rsp.read()
#         res_json = json.loads(res)
#         result.append(res_json)

#     close_result = []
#     for instrument in result:
#         oneDay_list = []
#         for oneDay in instrument:
#             oneDay_list.append(float(oneDay[-2]))
#         close_result.append(np.array(oneDay_list))
#     close_result = np.array(close_result)
#     close_result = close_result.T
#     df = pd.DataFrame(data=close_result, columns=ids)
#     df.plot()
#     plt.show()

# if __name__ == "__main__":
#     findPairs()

from IPython.display import display
import matplotlib.pyplot as plt

# 您的绘图代码
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.title("Sample Plot")

# 强制显示图形
display(plt.gcf())