Commit e19d25d9 authored by denis's avatar denis

Merge branch 'master' into 'dev'

Master

See merge request !42
parents bc1286df 65887986
Pipeline #128308229 passed with stage
in 1 minute and 20 seconds
.kdev4
ichinscratchy
ichi_reloaded.kdev4
otrasys
OTraSys.kdev4
temp
......@@ -6,4 +6,4 @@ build:
- make
artifacts:
paths:
- ichinscratchy
- otrasys
ichi_reloaded
=============
https://gitlab.com/werwurm/ichi_reloaded.git
This Repository hosts the complete rewrite of ichinscratchy.
It is an Ichimoku-based trading system originally developed in libreoffice/
openoffice basic macro language and rewritten in C from scratch.
The goal is to cross the boundaries of a pure Ichimoku implementation but to
create a framework for designing trading systems. The Ichimoku system will be
the first incarnation of this framework.
# OTraSys- The Open Trading System
## An open source framework to create trading systems
https://gitlab.com/werwurm/OTraSys.git
<img src="docs/pics/logo.png" alt="OTraSys Logo" style="width:100px ; float:left"/>
This Repository hosts the Open Trading System.
It is an open source framework to create trading systems, written in C from
scratch. The goal is to create a framework for designing trading systems.
The Ichimoku system will be the first incarnation of this framework.
In its current state, the software is used to generate all signals and charts
seen on https://spare-time-trading.de (available in English and German)
seen on https://spare-time-trading.de (available in English and German).
--------------------------------------------------------------------------------------
Licence
-------
This program is Free Software: You can use, study share and improve
......@@ -23,20 +25,22 @@ Foundation, either version 3 of the License, or (at your option) any later versi
Folder structure of repository:
-------------------------------
```
| main folder, hosts README.md, makefile, licence and binary after compilation
|--build not syncronised, hosts the object files after compilation
|--config hosts various config files for binary program
|--data not syncronised, hosts data files for binary program
|--charts hosts gnuplot files and csv-files for plotting
|--docs hosts documentation
|--src hosts source files and headers
|--tools hosts several helper scripts (e.g. data retrieval, test procedures)
| main folder, hosts README.md, makefile, licence and binary after compilation
|--build not syncronised, hosts the object files after compilation
|--config hosts various config files for binary program
|--data not syncronised, hosts data files for binary program
|--charts hosts gnuplot files and csv-files for plotting
|--docs hosts documentation for users
|--doxygen_html source code documentation (for developers)
|--pics sample pictures and screenshots for documentation
|--src hosts source files and headers
|--tools hosts several helper scripts (e.g. data retrieval, test procedures)
```
Build instructions:
-------------------
Just issue `make` at the main folder, where the makefile is located.
Compiled files will be generated into *build*-folder, the executable ichinscratchy
Compiled files will be generated into *build*-folder, the executable `otrasys`
will be generated in the main folder. Execute `make clean` to remove all compiled
files and executable.
A `make debug` will generated an executable with most compiler optimizations turned
......@@ -48,21 +52,21 @@ You will need `libmysqlclient-devel` installed. The also needed better string li
Usage:
------
After compiling copy `config/ichinscratchy.conf.EXAMPLE` to `config/ichinscratchy.conf`
After compiling copy `config/otrasys.conf.EXAMPLE` to `config/otrasys.conf`
and tailor to your needs. Most options are set within the config file.
`./ichinscratchy -?` lists the command line options. Note that with `--setup_db` or
<!-- `./otrasys -?` lists the command line options. Note that with `--setup_db` or -->
`-s` you can setup the neccessary database and tables. You will need the mysql root
password to do this (alternatively you can create the database yourself, as specified
in `docs/database_structure.md`).
You can find an in-depth explanation for all command line options and config parameters
in the documentation under `/docs/database_structure.md` or in the project wiki under
https://gitlab.com/werwurm/ichi_reloaded/wikis/config-file-and-command-line-options
https://gitlab.com/werwurm/OTraSys/wikis/config-file-and-command-line-options
Current Build Status:
---------------------
**master branch** [![build status](https://gitlab.com/werwurm/ichi_reloaded/badges/master/pipeline.svg)](https://gitlab.com/werwurm/ichi_reloaded/commits/master)
**release branch** [![build status](https://gitlab.com/werwurm/ichi_reloaded/badges/release/pipeline.svg)](https://gitlab.com/werwurm/ichi_reloaded/commits/release)
**dev branch** [![build status](https://gitlab.com/werwurm/ichi_reloaded/badges/dev/pipeline.svg)](https://gitlab.com/werwurm/ichi_reloaded/commits/dev)
**master branch** [![build status](https://gitlab.com/werwurm/OTraSys/badges/master/pipeline.svg)](https://gitlab.com/werwurm/OTraSys/commits/master)
**release branch** [![build status](https://gitlab.com/werwurm/OTraSys/badges/release/pipeline.svg)](https://gitlab.com/werwurm/OTraSys/commits/release)
**dev branch** [![build status](https://gitlab.com/werwurm/OTraSys/badges/dev/pipeline.svg)](https://gitlab.com/werwurm/OTraSys/commits/dev)
Sample Screenshots:
-------------------
......
This diff is collapsed.
ichinscratchy.conf
otrasys.conf
testsymbols.conf
ichinscratchy.confBACKTEST
symbols.conf
backtest.conf
backtestsymbols.conf
......
#################################################
# Config file for main program ichinscratchy #
# Config file for main program otrasys #
# example file- remove '.EXAMPLE' from filename #
# to use it, fit to your needs #
# #
......@@ -95,16 +95,19 @@ PORTFOLIO_RETURNS_UPDATE = 25 # update mean returns every X periods
# Stop Loss settings
###############################################################################
SL_TYPE = percentage # percentage (percentage stop, default),
# chandelier (Chandelier Stop)
SL_PERCENTAGE_RISK = 0.02 # percent for SL_TYPE= percentage, default 0.02
SL_CHANDELIER_ATR_FACTOR = 3 # SL_TYPE=chandelier: Place SL x-times the ATR
# away (default 3)
SL_CHANDELIER_ATR_PERIOD = 26 # SL_TYPE=chandelier: Period for Averaging the
# True Range (default 26)
SL_ADJUST = trailing # fixed (use initial SL only),
# trailing (adjust SL in trend direction only)
# chandelier, atr (ATR based)
SL_PERCENTAGE_RISK = 0.05 # the SL percentage for SL_TYPE = percentage,
# default 0.02
SL_ATR_FACTOR = 3 # SL_TYPE=chandelier/atr: Place the SL x-times
# the ATR away (default 3)
SL_ATR_PERIOD = 26 # SL_TYPE=chandelier/atr: Period for Averaging
# the True Range (default 26)
SL_ADJUST = trailing # fixed (use initial SL only), trailing (adjust
# SL in trend direction only)
# updown (adjust SL in both directions),
# default: trailing
SL_SAVE_DB = true # save all SL records in mysql database?
# (true/false)
###############################################################################
# Risk management settings
......@@ -122,8 +125,8 @@ RISK_FREE_RATE = 0.02 # rate of returns for 0 risk investment
###############################################################################
CHART_PLOT = true # plot the chart, true/false
CHART_PLOT_WEAK = false # plot weak signals; default false
CHART_PLOT_NEUTRAL = false # plot neutral signals; default false
CHART_PLOT_STRONG = true # plot strong signals; default true
CHART_PLOT_NEUTRAL = false # plot neutral signals; default false
CHART_PLOT_STRONG = true # plot strong signals; default true
CHART_COLORSCHEME = contrast # light/ contrast
CHART_DAYS_TO_PLOT = 120 # default: 120
......
<img src="pics/logo.png" alt="OTraSys Logo" style="width:50px ; float:left"/>
OTraSys- The Open Trading System
An open source framework to create trading systems
Market configuration
====================
This document describes the configuration of markets for the trading system.
General information
......
<img src="pics/logo.png" alt="OTraSys Logo" style="width:50px ; float:left"/>
OTraSys- The Open Trading System
An open source framework to create trading systems
Configuration
=============
This document describes the configuration of the system. There are
basically 2 ways to do so:
* via start parameter
......@@ -12,7 +19,7 @@ described in /docs/config_markets.md
program start parameters
========================
* `-?`, `--help` show help page
* `-c`, `--configfile` select configfile within /config (default is /config/ichinscratchy.conf)
* `-c`, `--configfile` select configfile within /config (default is /config/otrasys.conf)
* `-V`, `--version` shows version number
* `-s`, `--setup_db` setup necessary database (db is cleared
if exists), root password needed! Note that this is exclusive to the
......@@ -33,7 +40,7 @@ program start parameters
Config file parameters
======================
This chapter describes the various parameters if the config file
`ichinscratchy.conf`
`otrasys.conf`
As the config file is separated into different sections, this document
follows this separation.
* [General Settings](#GeneralSettings)
......@@ -502,9 +509,15 @@ Stop Loss settings <a name="Stop_Loss_settings"></a>
**SL_TYPE**
This option determines the type of stop loss the system uses.
Valid options are:
* `percentage`: use a fixed percentage of the buy price to determine SL (default)
* `percentage`: use a fixed percentage of the buy price to determine SL (default)
for an example, see picture in [docs/pics/SL/sl_percent.png](pics/SL/sl_percent.png)
* `chandelier`: use a stop loss based on volatility (Average True Range)
to determine SL
to determine SL, for details see:
see http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:chandelier_exit
; for an example, see picture in [docs/pics/SL/sl_chandelier.png](pics/SL/sl_chandelier.png)
* `atr`: simple ATR based stop; for an example, see picture in
[docs/pics/SL/sl_atr.png](pics/SL/sl_atr.png)
Note that in market conditions with high momentum a new chandelier sl could be over
current price (for long, under current price for short). In this cases the percentage
stop will be used as fallback, so while configuring chandelier stop it is important
......@@ -520,27 +533,34 @@ based on the buy price (default is 0.02).
_Syntax:_
`SL_PERCENTAGE_RISK = 0.02`
**SL_CHANDELIER_ATR_FACTOR**
When using `SL_Type = chandelier` this option specifies the factor that the ATR will be
multiplied with (in other words place the SL x-times the ATR away from current price).
Default is `3`.
**SL_ATR_FACTOR**
When using `SL_Type = chandelier` or `SL_TYPE = atr` this option specifies the factor
that the ATR will be multiplied with (in other words place the SL x-times the ATR away
from current price). Default is `3`.
_Syntax:_
`SL_CHANDELIER_ATR_FACTOR = 3`
`SL_ATR_FACTOR = 3`
**SL_CHANDELIER_ATR_PERIOD**
When using `SL_type = chandelier` this option specifies the _Average_-part of ATR (in other
words the period for averaging the true range). Based on this option the ATR will be calculated
and stored in the db table `indicators_daily`. You can choose your period freely, using the
same period as the mid term period for Ichimoku should give a good starting point.
**SL_ATR_PERIOD**
When using `SL_type = chandelier` or `SL_TYPE = atr` this option specifies the
_Average_-part of ATR (in other words the period for averaging the true range). Based
on this option the ATR will be calculated vand stored in the db table `indicators_daily`.
You can choose your period freely, using the same period as the mid term period for
Ichimoku should give a good starting point.
NOTE: SIGNAL_DAYS_TO_EXECUTE must be at least SL_CHANDELIER_ATR_PERIOD days shorter than
INDI_DAYS_TO_UPDATE, because the first ATR calculation needs SL_CHANDELIER_ATR_PERIOD days.
If earlier ATR values are queried, mysql will return 0 for the ATR so when using chandelier
stop the calculation of the stop might be wrong!
_Syntax:_
`SL_CHANDELIER_ATR_PERIOD = 26`
`SL_ATR_PERIOD = 26`
**SL_ADJUST**
This option specifies how the the stop loss will be adjusted from day to day/ bar to bar.
The default is a trailing stop loss. The other 2 options do not really make sense in live
trading, you can see example pictures for fixed/updown SL.
behaviour in the `docs/pics` folder:
[docs/pics/SL/sl_fixed.png](pics/SL/sl_fixed.png)
[docs/pics/SL/sl_atr_updown.png](pics/SL/sl_atr_updown.png)
Valid options are:
* `fixed`: do not adjust the SL at all, keep the initial SL. This might be useful if you
plan to sell manually and use price targets (currently the software does not support this).
......@@ -553,6 +573,12 @@ Valid options are:
_Syntax:_
`SL_ADJUST = trailing`
**SL_SAVE_DB**
This option specifies if the SL are stored within the mysql database. Valid options are
`true` and `false` (default).
_Syntax:_
`SL_SAVE_DB = false`
-------------------------------------------------------------------------------
Risk Management settings <a name="Risk_management_settings"></a>
......@@ -622,7 +648,7 @@ Example config file
```
#################################################
# Config file for main program ichinscratchy #
# Config file for main program otrasys #
# example file- remove '.EXAMPLE' from filename #
# to use it, fit to your needs #
# #
......@@ -718,16 +744,19 @@ PORTFOLIO_RETURNS_UPDATE = 25 # update mean returns every X periods
# Stop Loss settings
###############################################################################
SL_TYPE = percentage # percentage (percentage stop, default),
# chandelier (Chandelier Stop)
SL_PERCENTAGE_RISK = 0.02 # percent for SL_TYPE= percentage, default 0.02
SL_CHANDELIER_ATR_FACTOR = 3 # SL_TYPE=chandelier: Place SL x-times the ATR
# away (default 3)
SL_CHANDELIER_ATR_PERIOD = 26 # SL_TYPE=chandelier: Period for Averaging the
# True Range (default 26)
SL_ADJUST = trailing # fixed (use initial SL only),
# trailing (adjust SL in trend direction only)
# chandelier, atr (ATR based)
SL_PERCENTAGE_RISK = 0.05 # the SL percentage for SL_TYPE = percentage,
# default 0.02
SL_ATR_FACTOR = 3 # SL_TYPE=chandelier/atr: Place the SL x-times
# the ATR away (default 3)
SL_ATR_PERIOD = 26 # SL_TYPE=chandelier/atr: Period for Averaging
# the True Range (default 26)
SL_ADJUST = trailing # fixed (use initial SL only), trailing (adjust
# SL in trend direction only)
# updown (adjust SL in both directions),
# default: trailing
SL_SAVE_DB = true # save all SL records in mysql database?
# (true/false)
###############################################################################
# Risk management settings
......
<img src="pics/logo.png" alt="OTraSys Logo" style="width:50px ; float:left"/>
OTraSys- The Open Trading System
An open source framework to create trading systems
Database structure
==================
This document describes the database structure, the various tables and
......@@ -10,7 +15,7 @@ commands to you needs).
Name convention
---------------
The database name can be chosen freely and must be specified in
`ichinscratchy.conf`. The selected user needs access to the server and
`otrasys.conf`. The selected user needs access to the server and
all privileges of the database and its tables.
List of tables currently implemented
......@@ -38,6 +43,7 @@ following variables are currently needed by the program (and expected in the tab
* equity (free cash plus current value of positions- if sold right NOW)
* risk_free_equity (free cash plus current value of positions if all their stop losses were hit NOW)
* sum_fees (the sum of all fees paid so far within oderbook)
* all_time_high (the to date highest high of cash + equity ever)
* virgin_flag (initialized with 1 when creating db, valid until first position is bought- after that 0)
The primary key is the column variable_name.
......@@ -52,13 +58,7 @@ CREATE TABLE `account` (
#### Example queries
Get all variables from account table:
```
SELECT variable_name, value
FROM account
WHERE
variable_name='balance'
OR variable_name='equity'
OR variable_name='risk_free_equity'
OR variable_name='virgin_flag';
SELECT * FROM account;
```
-------------------------------------------------------------------------------
......@@ -511,17 +511,19 @@ SELECT
-------------------------------------------------------------------------------
Table `stoploss_daily` <a name="stoploss_daily"></a>
Table `stoploss_record` <a name="stoploss_record"></a>
----------------------------------------------------
#### Description
This tables stores the history of all trade's stop losses. At the moment
it is intended for development only and might be removed in future versions.
Note that all prices are in each market´s currency.
The table holds the following columns:
* symbol (which symbol)
* buydate (when was the date of buying)
* date (todays date as YYYY-MM-DD)
* daynr (todays date as daynr since 1900-01-01 ==> day 1)
* symbol
* buydate (the date this entry was bought, as YYYY-MM-DD)
* selldate (the date this entry was sold, as YYYY-MM-DD)
* sl_type (what sl type?)
* date (which date is this sl?)
* sl (this date's sl price level)
Primary key is {symbol, buydate, sl_type, date} to allow multiple active trades
for one symbol and even switching the type of SL in the lifespan of a single
......@@ -531,17 +533,29 @@ trade.
The table can/should be created using the following SQL command:
```
CREATE TABLE `stoploss_daily` (
`date` date NOT NULL,
`daynr` int NOT NULL,
`symbol` CHAR(10) NOT NULL,
`buydate` date NOT NULL,
`selldate` date,
`sl_type` CHAR(10) NOT NULL,
`date` date NOT NULL,
`sl` decimal(16,6) NOT NULL,
PRIMARY KEY (`symbol`, `buydate`, `sl_type`,`date`, ));
```
#### Example queries
```
tbd
Query database for a specific symbols quote date, but do so only where
there are stop loss records. This comes in handy if you want to plot your
quotes and the corresponding stop losses at that time.
```
SELECT * FROM
(SELECT quotes_daily.date,quotes_daily.symbol,quotes_daily.open,
quotes_daily.high, quotes_daily.low, quotes_daily.close, stoploss_record.sl FROM
quotes_daily
LEFT JOIN
stoploss_record ON (stoploss_record.date = quotes_daily.date AND stoploss_record.symbol='DAIML')
where quotes_daily.symbol="DAIML" GROUP BY quotes_daily.date ORDER BY quotes_daily.date DESC)
SUB ORDER BY date;
```
-------------------------------------------------------------------------------
......@@ -560,6 +574,7 @@ The table holds the following columns:
* equity: everything in the portfolio, rated with latest prices
* risk free equity: everything in portfolio rated with current stop losses
* total: cash + equity
* total_high: the to-date highest high for each day
#### Creation
The table can/should be created using the following SQL command:
......@@ -572,6 +587,7 @@ CREATE TABLE `performance_record` (
`equity` decimal(16,2),
`risk free equity` decimal(16,2),
`total` decimal(16,2),
`total_high` decimal(16,2),
PRIMARY KEY (`date`));
```
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.