Click here to Login

                                                   How to backup an entire QuantShare account


2014-01-01 19:44:46

A happy, healthful and prosperous New Year to everyone and all the best for 2014!
This is the time when I backup my operative QuantShare account.


Because I want to have an account with "frozen" history that will not be impacted by future changes of index constituents, corporate actions etc.

Why not just copy the database folder?

Of course, symbols and their quotes as well as a lot of other information is stored in the database folder "\QuantShareFolder\Database\AccountName\"
But there is also some data outside this database folder:
in "\QuantShareFolder\Database\" we have files like "AccountName*.*" that contain information on symbol categories and others.
in "\QuantShareFolder\" we have a file "AccountName.xml" that contains information on the layout of the docking panel.

How to backup

Create your Destination Account ("Accounts > Add Account"), the account name you enter will be your destination account.
QuantShare will automatically select this new account.

Change back to your source account
(Accounts > Change Account, select source account, "Open")

Go to "Tools > Script Editor" copy the script below, change the line "string DestinationAccountName = "_Backup_" to your individual Destination account name that you have used for account creation
and execute the script.

Go to the destination account now (Accounts > Change Account, select destination account, "Open")
and you will see your quotes, symbols, categories, docking panels

// -------------- C# backup an entire account ------------------
using System.IO;
string DestinationAccountName = "_Backup_"; // edit according to your needs
bool AllowFileOverwrite = true;
string SourceAccountName = App.Main.GetAccountName();
string SourceUserDatabasePath = App.Main.GetUserDatabasePath();
string QSDatabasesPath = SourceUserDatabasePath.Substring(0, SourceUserDatabasePath.LastIndexOf(SourceAccountName));
string DestinationUserDatabasePath = QSDatabasesPath + DestinationAccountName;

// copy xml file
string QSPath = QSDatabasesPath.Substring(0, QSDatabasesPath.LastIndexOf("Database"));
File.Copy(QSPath + SourceAccountName + ".xml", QSPath + DestinationAccountName + ".xml", AllowFileOverwrite);
Global.Trace1("xml file copied");

// copy settings files
string[] SourceAccountSettingFiles = Directory.GetFiles(QSDatabasesPath, SourceAccountName + "*.*");
string[] DestinationAccountSettingFiles = new string[SourceAccountSettingFiles.Length];
for (int i = 0; i < SourceAccountSettingFiles.Length; i++)
DestinationAccountSettingFiles[i] = Path.GetDirectoryName(SourceAccountSettingFiles[i]) + "\\" + DestinationAccountName + SourceAccountSettingFiles[i].Substring(SourceAccountSettingFiles[i].LastIndexOf(SourceAccountName) + SourceAccountName.Length);
File.Copy(SourceAccountSettingFiles[i], DestinationAccountSettingFiles[i], AllowFileOverwrite);
Global.Trace1(SourceAccountSettingFiles.Length.ToString() + " settings files copied");

// copy Database files and folders
string[] SourceDatabaseFiles = Directory.GetFiles(SourceUserDatabasePath, "*.*", SearchOption.AllDirectories);
foreach (string SourceFile in SourceDatabaseFiles)
string DestinationFile = QSDatabasesPath + DestinationAccountName + SourceFile.Substring(SourceUserDatabasePath.Length);
if (!Directory.Exists(Path.GetDirectoryName(DestinationFile))) Directory.CreateDirectory(Path.GetDirectoryName(DestinationFile));
File.Copy(SourceFile, DestinationFile, AllowFileOverwrite);
Global.Trace1(SourceDatabaseFiles.Length.ToString() + " database files copied");

2014-01-02 23:34:22


Excellent. Thank you for the script.

2014-02-06 04:53:00


Very useful. Also, a script to delete all traces of an existing account will be useful. The delete option under 'change account' does not delete everything which was created for that account.

Stock Hunter
2014-02-07 20:59:53


Instead of going all these backup code( especially dont have that much software coding knowledge) Why not consider any backup option in QS? then guys like me it is easy and useful..I hope it will consider future update

2014-02-07 23:03:27


To backup all your accounts, you can just backup QuantShare directory.
To restore it later, simply install QuantShare on that directory.

2014-02-09 05:33:49


Possibly, while using the 'delete account' option in QS, add the capability to delete every trace of the account. Currently, it still leaves many files.

2014-02-11 15:29:06


@ Seeker:

the script below will delete an account completely. Please make sure to always backup your data and be careful with the variable "DeletionAccountName", you may delete mportant data if a wrong account name is entered

// -------------- C# completely delete an account ------------------
using System.IO;
string DeletionAccountName = "_test_"; // edit according to your needs
string SourceAccountName = App.Main.GetAccountName();
string SourceUserDatabasePath = App.Main.GetUserDatabasePath();
string QSDatabasesPath = SourceUserDatabasePath.Substring(0, SourceUserDatabasePath.LastIndexOf(SourceAccountName));
string DeletionUserDatabasePath = QSDatabasesPath + DeletionAccountName;

// delete xml file
string QSPath = QSDatabasesPath.Substring(0, QSDatabasesPath.LastIndexOf("Database"));
File.Delete(QSPath + DeletionAccountName + ".xml");
Global.Trace1("xml file deleted");

// delete settings files
string[] DeletionAccountSettingFiles = Directory.GetFiles(QSDatabasesPath, DeletionAccountName + "*.*");
for (int i = 0; i < DeletionAccountSettingFiles.Length; i++) File.Delete(DeletionAccountSettingFiles[i]);
Global.Trace1(DeletionAccountSettingFiles.Length.ToString() + " settings files deleted");

// delete Database folders
Directory.Delete(DeletionUserDatabasePath, true);
Global.Trace1("database folder deleted");

2014-02-12 10:44:07

Thank you so much for the generous efforts. It will be of great use in cleaning the program folder of redundant items.

Jim Harrison
2014-03-01 08:25:44


Quite Handy

2017-07-08 06:29:06


Of late, when i run this script, the following error appears:
Script:Copy the account as a backup
The process cannot access the file 'C:\Program Files\CTrading\QuantShare\Database\' because it is being used by another process.

2017-07-10 04:52:07


Try restarting your computer.

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
How far are the close prices from the support line
Nepal Market - Daily Stock Quotes Universal Downloader
History of dividend payment for stocks in the US stock market
EODData Daily Import

How-to Lessons
How to copy the data/settings of an account to another account
How to backup your databases (EOD, Intraday, Tick and Custom) and...
How to download Portfolio123 data into QuantShare
How to run QuantShare offline
How to improve the performance of QuantShare databases?

Related Forum Threads
Learning to program QuantShare - how to begin
Backup and move entire QS to new computer
How to Backup my whole SQ
How to rename an account
How to change the quantshare login in to other PC?

Blog Posts
How to use QuantShare screener to trade penny stocks
How to use QuantShare Indicators in the Grid Tool
How to use the new Market Regimes Feature in QuantShare Trading S...
How Does QuantShare Work?
How to Run QuantShare without UAC Prompts?

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2021
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.