forked from waditu/tushare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
197 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
# -*- coding:utf-8 -*- | ||
''' | ||
Created on 2015/3/14 | ||
@author: Jimmy Liu | ||
''' | ||
import unittest | ||
import tushare.stock.classifying as fd | ||
|
||
import tushare.stock.classifying as ts | ||
class Test(unittest.TestCase): | ||
|
||
if __name__ == '__main__': | ||
# print ts.get_area_classified() | ||
# print ts.get_gem_classified() | ||
# print ts.get_sme_classified() | ||
# print ts.get_st_classified() | ||
# print ts.get_industry_classified() | ||
print ts.get_concept_classified() | ||
def set_data(self): | ||
self.code = '600848' | ||
self.start = '2015-01-03' | ||
self.end = '2015-04-07' | ||
self.year = 2014 | ||
self.quarter = 4 | ||
|
||
def test_get_industry_classified(self): | ||
print(fd.get_industry_classified()) | ||
|
||
def test_get_concept_classified(self): | ||
print(fd.get_concept_classified()) | ||
|
||
def test_get_area_classified(self): | ||
print(fd.get_area_classified()) | ||
|
||
def test_get_gem_classified(self): | ||
print(fd.get_gem_classified()) | ||
|
||
def test_get_sme_classified(self): | ||
print(fd.get_sme_classified()) | ||
|
||
def test_get_st_classified(self): | ||
print(fd.get_st_classified()) | ||
|
||
def test_get_hs300s(self): | ||
print(fd.get_hs300s()) | ||
|
||
def test_get_sz50s(self): | ||
print(fd.get_sz50s()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
|
||
# suite = unittest.TestSuite() | ||
# suite.addTest(Test('test_get_gem_classified')) | ||
# unittest.TextTestRunner(verbosity=2).run(suite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,50 @@ | ||
# -*- coding:utf-8 -*- | ||
''' | ||
Created on 2015/3/14 | ||
@author: Jimmy Liu | ||
''' | ||
import unittest | ||
import tushare.stock.macro as fd | ||
|
||
import tushare.stock.macro as mc | ||
class Test(unittest.TestCase): | ||
|
||
if __name__ == '__main__': | ||
# print mc.get_year_gdp() | ||
print mc.get_quarter_gdp() | ||
def test_get_gdp_year(self): | ||
print(fd.get_gdp_year()) | ||
|
||
def test_get_gdp_quarter(self): | ||
print(fd.get_gdp_quarter()) | ||
|
||
def test_get_gdp_for(self): | ||
print(fd.get_gdp_for()) | ||
|
||
def test_get_gdp_pull(self): | ||
print(fd.get_gdp_pull()) | ||
|
||
def test_get_gdp_contrib(self): | ||
print(fd.get_gdp_contrib()) | ||
|
||
def test_get_cpi(self): | ||
print(fd.get_cpi()) | ||
|
||
def test_get_ppi(self): | ||
print(fd.get_ppi()) | ||
|
||
def test_get_deposit_rate(self): | ||
print(fd.get_deposit_rate()) | ||
|
||
def test_get_loan_rate(self): | ||
print(fd.get_loan_rate()) | ||
|
||
def test_get_rrr(self): | ||
print(fd.get_rrr()) | ||
|
||
def test_get_money_supply(self): | ||
print(fd.get_money_supply()) | ||
|
||
def test_get_money_supply_bal(self): | ||
print(fd.get_money_supply_bal()) | ||
|
||
|
||
if __name__ == "__main__": | ||
#import sys;sys.argv = ['', 'Test.testName'] | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
# -*- coding:utf-8 -*- | ||
''' | ||
Created on 2015/3/14 | ||
@author: Jimmy Liu | ||
''' | ||
import unittest | ||
import tushare.stock.newsevent as fd | ||
|
||
import tushare.stock.newsevent as ns | ||
class Test(unittest.TestCase): | ||
|
||
if __name__ == '__main__': | ||
df = ns.get_latest_news(5,show_content=False) | ||
print df | ||
def set_data(self): | ||
self.code = '600848' | ||
self.start = '2015-01-03' | ||
self.end = '2015-04-07' | ||
self.year = 2014 | ||
self.quarter = 4 | ||
self.top = 60 | ||
self.show_content = True | ||
|
||
# url = df.ix[0,'url'] | ||
# print ns.latest_content(url) | ||
|
||
# nts = ns.get_notices('600848') | ||
# # print nts | ||
# url = nts.ix[0,'url'] | ||
# print ns.notice_content(url) | ||
|
||
def test_get_latest_news(self): | ||
self.set_data() | ||
print(fd.get_latest_news(self.top, self.show_content)) | ||
|
||
def test_get_notices(self): | ||
self.set_data() | ||
df = fd.get_notices(self.code) | ||
print(fd.notice_content(df.ix[0]['url'])) | ||
|
||
def test_guba_sina(self): | ||
self.set_data() | ||
print(fd.guba_sina(self.show_content)) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
# -*- coding:utf-8 -*- | ||
''' | ||
Created on 2015/3/14 | ||
@author: Jimmy Liu | ||
''' | ||
import unittest | ||
from tushare.stock import reference as fd | ||
|
||
from tushare.stock import reference as rf | ||
class Test(unittest.TestCase): | ||
|
||
if __name__ == '__main__': | ||
df = rf.profit_data(top=60) | ||
print df[df.shares>=10] | ||
def set_data(self): | ||
self.code = '600848' | ||
self.start = '2015-01-03' | ||
self.end = '2015-04-07' | ||
self.year = 2014 | ||
self.quarter = 4 | ||
self.top = 60 | ||
self.show_content = True | ||
|
||
def test_profit_data(self): | ||
self.set_data() | ||
print(fd.profit_data(top=self.top)) | ||
|
||
def test_forecast_data(self): | ||
self.set_data() | ||
print(fd.forecast_data(self.year, self.quarter)) | ||
|
||
def test_xsg_data(self): | ||
print(fd.xsg_data()) | ||
|
||
def test_fund_holdings(self): | ||
self.set_data() | ||
print(fd.fund_holdings(self.year, self.quarter)) | ||
|
||
def test_new_stocksa(self): | ||
print(fd.new_stocks()) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ def xls(): | |
def hdf(): | ||
df = ts.get_hist_data('000875') | ||
# df.to_hdf('c:/day/store.h5','table') | ||
print df | ||
|
||
store = HDFStore('c:/day/store.h5') | ||
store['000875'] = df | ||
|
@@ -28,7 +27,7 @@ def json(): | |
df.to_json('c:/day/000875.json',orient='records') | ||
|
||
#或者直接使用 | ||
print df.to_json(orient='records') | ||
print(df.to_json(orient='records')) | ||
|
||
def appends(): | ||
filename = 'c:/day/bigfile.csv' | ||
|
@@ -41,7 +40,6 @@ def appends(): | |
|
||
def db(): | ||
df = ts.get_tick_data('600848',date='2014-12-22') | ||
print df | ||
engine = create_engine('mysql://root:[email protected]/mystock?charset=utf8') | ||
# db = MySQLdb.connect(host='127.0.0.1',user='root',passwd='jimmy1',db="mystock",charset="utf8") | ||
# df.to_sql('TICK_DATA',con=db,flavor='mysql') | ||
|
@@ -53,7 +51,7 @@ def nosql(): | |
import json | ||
conn = pymongo.Connection('127.0.0.1', port=27017) | ||
df = ts.get_tick_data('600848',date='2014-12-22') | ||
print df.to_json(orient='records') | ||
print(df.to_json(orient='records')) | ||
|
||
conn.db.tickdata.insert(json.loads(df.to_json(orient='records'))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
# -*- coding:utf-8 -*- | ||
''' | ||
Created on 2015/3/14 | ||
@author: Jimmy Liu | ||
''' | ||
import unittest | ||
import tushare.stock.trading as fd | ||
|
||
# import tushare.stock.trading as td | ||
import tushare as ts | ||
class Test(unittest.TestCase): | ||
|
||
if __name__ == '__main__': | ||
# print td.get_tick_data('600848', '2015-01-09') | ||
# print td.get_realtime_quotes('600848') | ||
# print td.get_realtime_quotes(['600848','000980','000981']) | ||
# df = td.get_today_all() | ||
# print td.get_realtime_quotes(df['code'].tail(10)) | ||
print ts.get_hist_data('600848',start='2015-02-25') | ||
def set_data(self): | ||
self.code = '600848' | ||
self.start = '2015-01-03' | ||
self.end = '2015-04-07' | ||
self.year = 2014 | ||
self.quarter = 4 | ||
|
||
def test_get_hist_data(self): | ||
self.set_data() | ||
print(fd.get_hist_data(self.code, self.start)) | ||
|
||
def test_get_tick_data(self): | ||
self.set_data() | ||
print(fd.get_tick_data(self.code, self.end)) | ||
|
||
def test_get_today_all(self): | ||
print(fd.get_today_all()) | ||
|
||
def test_get_realtime_quotesa(self): | ||
self.set_data() | ||
print(fd.get_realtime_quotes(self.code)) | ||
|
||
def test_get_h_data(self): | ||
self.set_data() | ||
print(fd.get_h_data(self.code, self.start, self.end)) | ||
|
||
if __name__ == "__main__": | ||
#import sys;sys.argv = ['', 'Test.testName'] | ||
unittest.main() |