English
2. Basic help on using FXDaemon
2.1 Starting
2.1.1 Windows
  • Start in backtesting mode.
  • > fxTrade.exe -s --ini=fxTrade-bktest.ini
    
  • Start the demo account in automated trading mode.
  • > fxTrade.exe -s --ini=fxTrade-demo.ini
    
  • Start the demo account and virtual account in turn in automated trading mode.
  • > start /b fxTrade.exe -s --ini=fxTrade-demo.ini
    ↓↓↓ After the demo account is started, start the virtual account again. ↓↓↓
    > start /b fxTrade.exe -s --ini=fxTrade-virtual.ini
    
  • Set Task Scheduler to start the demo account at 4:00 every Monday.
  • > schtasks /create /tn "FXDaemon-demo" /tr "fxTrade.exe -s --ini=fxTrade-demo.ini" /sc weekly /d mon /st 04:00:00
    
2.1.2 Linux
  • Move to the FXDaemon installation directory and execute the shell script to set the environment variables.
  • $ source setenv.sh
    
  • Start in backtesting mode.
  • $ fxTrade -s --ini=fxTrade-bktest.ini
    
  • Start the demo account in automated trading mode.
  • $ fxTrade -s --ini=fxTrade-demo.ini
    
  • Start the demo account and virtual account in turn in automated trading mode.
  • $ nohup fxTrade -s --ini=fxTrade-demo.ini 2>&1 &
    ↓↓↓ After the demo account is started, start the virtual account again. ↓↓↓
    $ nohup fxTrade -s --ini=fxTrade-virtual.ini 2>&1 &
    
  • Edit crontab to start the demo account at 4:00 every Monday.
  • > vi /etc/crontab
    > 0 4 * * 1 [user] source [install-path]/setenv.sh && fxTrade -s --ini=fxTrade-demo.ini
    
  • Edit crontab to execute "fxTrade.sh" every 10 minutes to monitor the running of demo account and virtual account.
  • The monitoring script provides the following features. Please modify it according to your needs.
    1. Start demo account and virtual account at 4:00 and 4:10 every Monday.
    2. Restart when an abnormal termination occurs.
    3. Forcefully terminate the process and restart it when the process is hangup.
    4. Send message to the specified email address when restarting.
    (User need to set the destination address for the "mail_to" variable, as well as some settings related to the sendmail.)
    > vi /etc/crontab
    > */10 * * * * [user] [install-path]/fxTrade.sh
    
2.2 Quitting
2.2.1 Windows, Linux

Perform either of the following two operations.

  • Press the q key (only when starting in the foreground)
  • Exit automatically after specified time by setting ini file
2.2.2 Linux only
$ ps -ef | grep fxTrade
$ kill -3 [pid] ← Process ID obtained with ps
2.3 Command line switches
  • [--ini=FILE]
  • Specify ini file. If not specified, read in "fxTrade.ini" by default.
  • [--license=FILE]
  • Specify license file. If not specified, read in "fxTrade.lic" by default.
  • -s, --start [--ini=FILE] [--license=FILE]
  • According to the settings of the ini file, the system in the backtesting mode or automated trading mode is started. Automated trading mode of the second trading account cannot be started if the license expires.
  • -r, --save-hisdata-add [--ini=FILE]
  • According to the start and end times set in the ini file, historical data is obtained from the broker trading server and written to the data file in append mode.
  • -R, --save-hisdata-new [--ini=FILE] --start-date=DATE --end-date=DATE
  • The historical data is obtained from the broker trading server and written to the data file in new mode.
  • -h, --print-hisdata [--ini=FILE] --symbol=SYMBOL --period=PERIOD --start-date=DATE --end-date=DATE
  • The historical data is obtained from the broker trading server and output to standard output.
  • -m, --print-mktdata [--ini=FILE] --symbol=SYMBOL
  • The market data is obtained from the broker trading server and output to standard output.
  • -a, --print-account [--ini=FILE]
  • The account information is obtained from the broker trading server and output to standard output.
  • -j, --run-js [--ini=FILE] [PARAM1, PARAM2, ...]
  • Run the js file set in the ini file. [param1,...] is passed to the js file as an input parameter. The built-in functions related to the trading interface cannot be used.
  • -n, --issue-serial-no
  • Issue a serial number.
  • -e, --check-expiration-date [--license=FILE]
  • Confirm the expiration date of the license.
2.4 Back Testing
  • The generated data is inserted into the tables `Order`, `Trade`, and `TsContext`.
  • When running the backtesting again, you can either modify [ticketno] to prevent the unique constraint error of
  • duplicate keys, or execute SQL to delete all previously generated data.
    $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/delete.sql;"
    
2.5 Position summary
  • Summary by year
  • $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/year.sql;"
    
  • Summary by year > month
  • $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/month.sql;"
    
  • Summary by year > week
  • $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/week.sql;"
    
  • Summary by symbol
  • $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/symbol.sql;"
    
  • Summary by symbol > method
  • $ mysql -ufxtrade -pfxtrade scm_fxtrade -e"set @account_id:='bt001'; source sql/method.sql;"