@@ -104,7 +104,7 @@ def main():
104
104
sb = StockBox ()
105
105
# sb.looper(id)
106
106
id = '300333'
107
- #sb.realtime(id)
107
+ # sb.realtime(id)
108
108
sb .base_function ("300333" )
109
109
# pandas_test=Pandas_test()
110
110
# pandas_test.test_function()
@@ -196,15 +196,101 @@ def fund(self):
196
196
197
197
198
198
def main ():
199
+ # 获取历史数据 近3年的数据
200
+ history = ts .get_hist_data (id )
201
+
202
+ print u"历史3年的数据"
203
+
204
+ print history .head (10 )
205
+
206
+ history_all = ts .get_h_data (id , '20015101' , '20160101' )
207
+
208
+ print u'所有的历史数据'
209
+ print history_all
210
+
211
+
212
+
213
+ # print type(stockInfo)
214
+ # print stockInfo.head()
215
+ # print stockInfo.dtypes
216
+ # df = ts.get_stock_basics()
217
+ #data = df.ix[id]['timeToMarket']
218
+ #print data
219
+ #ts.get_today_all()
220
+
221
+
222
+ def get_info (self , id ):
223
+ # 获取一些股票的基本信息
224
+ df = ts .get_stock_basics ()
225
+ print df .ix ['300333' ]['timeToMarket' ]
226
+
227
+
228
+ def realtime (self , id ):
229
+ # all_stock=ts.get_today_all()
230
+ # print all_stock
231
+ df = ts .get_realtime_quotes (id )
232
+ # print df[['time','name','price','bid','ask','volume']]
233
+ # print df.head()
234
+
235
+ price_change = ts .get_today_ticks (id )
236
+ print price_change [['time' , 'change' , 'type' , 'volume' ]]
237
+ big_share = ts .get_sina_dd (id , date = '2016-04-01' )
238
+ print big_share [['time' , 'code' , 'price' , 'preprice' , 'volume' , 'type' ]]
239
+
240
+
241
+ def looper (self , id ):
242
+ while (1 ):
243
+ self .realtime (id )
244
+ time .sleep (30 )
245
+
246
+
247
+ def getNews (self ):
248
+ token = '60517739976b768e07823056c6f9cb0fee33ed55a1709b3eaa14a76c6a1b7a56'
249
+ ts .set_token (token )
250
+ print ts .get_token ()
251
+ mkt = ts .Market ()
252
+ df = mkt .TickRTSnapshot (securityID = '000001.XSHE' )
253
+ print df
254
+
255
+
256
+ def longhuban (self , date ):
257
+ print ts .top_list (date )
258
+ print ts .cap_tops ()
259
+
260
+
261
+ def get_stock_chengfeng (self ):
262
+ df = ts .get_sz50s ()
263
+ # print df
264
+ terminal_stock = ts .get_terminated ()
265
+ print terminal_stock
266
+
267
+
268
+ def fund (self ):
269
+ fd = ts .Fund ()
270
+ df = fd .FundDiv (ticker = '184688' , adjustedType = 'D' , beginDate = '20000101' ,
271
+ field = 'secShortName,effectDate,publishDate,dividendAfTax,dividendBfTax' )
272
+ print df
273
+ dd = ts .fund_holdings (2015 , 4 )
274
+ print dd [['name' , 'nums' , 'clast' , 'amount' ]]
275
+
276
+
277
+ '''
278
+ def main():
279
+
199
280
token = '60517739976b768e07823056c6f9cb0fee33ed55a1709b3eaa14a76c6a1b7a56'
200
281
id = '300333'
201
282
# id=sys.argv[1]
202
283
203
284
sb = StockBox()
285
+
204
286
# sb.base_function(id)
205
287
sb.get_info(id)
206
288
207
289
290
+ #sb.base_function(id)
291
+ sb.get_info(id)
292
+ '''
293
+
208
294
# sb.looper(id)
209
295
# sb.realtime(id)
210
296
# stockBox.base_function("300333")
@@ -216,6 +302,7 @@ def main():
216
302
# sb.get_stock_chengfeng()
217
303
218
304
305
+
219
306
class Pandas_test :
220
307
def test_function (self ):
221
308
dates = pd .date_range ("20160501" , periods = 10 )
0 commit comments