Home > database >  How to use Python APscheduler do a timing for after-hours stock data timing task?
How to use Python APscheduler do a timing for after-hours stock data timing task?

Time:09-17




How to use Python APscheduler do a timing for after-hours stock data timing task? Look at a lot of examples are written not system,
Can add timing task framework in the following code?
Please everyone a great god passing help

The import pandas as pd
The from WindPy import w
The import pymongo
The from pymongo import MongoClient
The from pymongo. Errors import DuplicateKeyError

The class MDB:
='localhost' def __init__ (self, host, port=27017) :
The self. The client=MongoClient (host, port)
Baron tart ();

Def printpy (self, outdata) :
If outdata ErrorCode!=0:
Print (' the error code: + STR (outdata. ErrorCode) + '\ n');
Return ();
For I in range (0, len (outdata. Data [0])) :
StrTemp='
If len (outdata Times) & gt; 1:
StrTemp=STR (outdata. Times [I]) + "
For k in range (0, len (outdata. Fields)) :
StrTemp=strTemp + STR (outdata. Data [k] [I]) + "
Print (strTemp)

Def get_data (self, w_data) :

Self. W_data=https://bbs.csdn.net/topics/pd.DataFrame (w_data. Data, the index=w_data Fields, the columns=w_data. Times). T.r eset_index ()
# print (self. W_data)

Def insert (self, database, collection) :
Try:
The db=self. Client. Get_database (database)
Coll=db. Get_collection (collection)

For the label, the item in the self. W_data. Iterrows () :
_column=item. To_dict ()
Data_in=coll. Insert (_column)
Return data_in

Except DuplicateKeyError:
Return False

Def the delete (self, database, collection, document) :
Pass

Def updata (self, database, collection, document) :
Pass

Def __del__ (self) :
The self. The client. The close ()

If __name__=="__main__ ':
Mongo=MDB ()
Wsidata=https://bbs.csdn.net/topics/w.wsi (" AU1912. SHF ", "open, high, low, close, volume, amt, CHG, pct_chg, oi", "the 2019-11-01 09:00:00", "the 2019-11-01 09:05:16", "")
Mongo. Get_data (wsidata)
  • Related