VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 24
声望: 1

在用户文件夹里面的vt_setting.json修改了database.database的值,但是不管用.

{
"font.family": "微软雅黑",
"font.size": 12,
"log.active": true,
"log.level": 50,
"log.console": true,
"log.file": true,
"email.server": "",
"email.port": 465,
"email.username": "",
"email.password": "",
"email.sender": "",
"email.receiver": "",
"datafeed.name": "",
"datafeed.username": "",
"datafeed.password": "",
"database.timezone": "Asia/Shanghai",
"database.name": "sqlite",
"database.database": "D:/database.db",
"database.host": "",
"database.port": 0,
"database.user": "",
"database.password": ""
}

Member
avatar
加入于:
帖子: 387
声望: 20

改成:

D:\\database.db

试试呢,注意改完要重启VeighNa Trader

Member
avatar
加入于:
帖子: 24
声望: 1

MTF wrote:

改成:

D:\\database.db

试试呢,注意改完要重启VeighNa Trader
不管用,还是会用.vntrader目录下的数据库...

Member
avatar
加入于:
帖子: 24
声望: 1

找到了~

# sqlite的位置是不能通过设置来修改的
# 设定的sqlite数据库位置在
#  "....miniconda\envs\vn\Lib\site-packages\vnpy_sqlite\sqlite_database.py"

# 初始设定位置,.vntrader文件夹下的database.db
path = str(get_file_path("database.db"))
# 修改后设定位置
path = 'D:\\database.db'
db = PeeweeSqliteDatabase(path)
Member
avatar
加入于:
帖子: 27
声望: 0

1、sqlite_database.py
path = str(get_file_path("database.db"))
2、utility.py->get_file_path
return TEMP_DIR.joinpath(filename)
TRADER_DIR, TEMP_DIR = _get_trader_dir(".vntrader")
3、in _get_trader_dir(),
cwd = Path.cwd()
temp_path = cwd.joinpath(temp_name)

# If .vntrader folder exists in current working directory,
# then use it as trader running path.
if temp_path.exists():
    return cwd, temp_path



# Otherwise use home path of system.
home_path = Path.home()
temp_path = home_path.joinpath(temp_name)

# Create .vntrader folder under home path if not exist.
if not temp_path.exists():
    temp_path.mkdir()

return home_path, temp_path

4、from pathlib import Path
Path.home #返回当前用户的根目录
5、结论:如果根目录下存在.vntrader就在这个目录下放置database.db; 如果不存在,就在当前用户的根目录下新建.vntrader/database.db。如果想改路径,可以改上述代码,就可以达到目的

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】