Click here to Login





                                                   How to backup an entire QuantShare account

  1

0
SystemTrade
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.

Why?

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
(MAKE SURE THAT YOU ENTER THE CORRECT DESTINATION ACCOUNT IN THE SCRIPT, OTHERWISE DATA MIGHT BE OVERWRITTEN!)
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");



QuantShare
2014-01-02 23:34:22

  0

Excellent. Thank you for the script.



Seeker
2014-02-06 04:53:00

  0

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

  0

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


QuantShare
2014-02-07 23:03:27

  0

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




Seeker
2014-02-09 05:33:49

  0

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.


SystemTrade
2014-02-11 15:29:06

  0

@ 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");



Seeker
2014-02-12 10:44:07

  0

SystemTra.de,
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

  0

Quite Handy



Seeker
2017-07-08 06:29:06

  0

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



QuantShare
2017-07-10 04:52:07

  0

Try restarting your computer.


No more messages
0




Reply:

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"










QuantShare

Trading Items
How far are the close prices from the support line
Quandl.com Universal Downloader
Nepal Market - Daily Stock Quotes
Basic Portfolio Measures
Set Global Variable

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 run QuantShare offline
How to improve the performance of QuantShare databases?
How to use QuantShare with Metastock data

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 to Create an Automated Trading System in QuantShare
How Does QuantShare Work?









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
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.