Quant Vernon
Feb 7, 2021

--

Configuring collection name for MongoDB in VnPy

The default database solution for VnPy is MongoDB

Configure the MongoDB settings in vt_settings.json , the file is located under C:\Users\<YourUser>\.vntrader\

“database.driver”: “mongodb”,
“database.database”: “vnpytest”,
“database.host”: “localhost”,
“database.port”: 27017,
“database.user”: “root”,
“database.password”: “”,
“database.authentication_source”: “admin”,

Change the file vnpy/trader/database/database.py to include the collection name input

Change the vnpy/trader/database/database_mongdo.py to have collection_name as input

Change the load_bar_data() and load_tick_data() functions too in vnpy/trader/database/database_mongdo.py

And it’s done!

The BarData is now saved to the collection , easily loaded from the collection

--

--