Commit 65887986 authored by denis's avatar denis

Merge branch 'release' into 'master'

Release

See merge request !41
parents af6efb8c 538f49c0
Pipeline #128307548 passed with stage
in 1 minute and 15 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,41 +25,65 @@ 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
of, and including debugging symbols. Please use that if you want to report bugs (as
only debug builds are able to track down the location of the bug).
You will need `libmysqlclient-devel` installed. The also needed better string library
(please visit http://bstring.sourceforge.net/) is included and part of src/
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:
-------------------
While the system itself is terminal only, there won't be too impressive screenshots.
However, the small samples below give you a hint, what to expect. For more information
please see the docs.
Please note: all screenshots show random examples taken during development, not final
optimized trading systems that are out in the wild making big money. The large versions
of those screenshots are in `docs/pics/`
### Sample terminal output:
<img src="docs/pics/terminal_output.png" alt="sample terminal output" style="width:1000px"/>
### Sample performance using the script under `tools/`
<img src="docs/pics/performance.png" alt="sample performance graph" style="width:800px"/>
### Sample chart
<img src="docs/pics/DAX_contrast.png" alt="sample Ichimoku Chart" style="width:800px"/>
### Sample report
<img src="docs/pics/report.png" alt="sample terminal report" style="width:800px"/>
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 #
# #
......@@ -13,6 +13,8 @@
CONFIG_SYMBOLFILE = symbols.conf # file that holds symbols
ACCOUNT_CURRENCY = EUR # atm EUR/USD/JPY
ACCOUNT_CURRENCY_DIGITS = 2 # nr of significant digits
TRANSACTION_COSTS_FIX = 15 # fixed amount fee in account currency
TRANSACTION_COSTS_PERCENTAGE = 0.0025 # fee as percentage of position´s value
###############################################################################
# Database related settings
......@@ -93,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
......@@ -120,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
......
This diff is collapsed.
<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
......@@ -23,7 +28,8 @@ List of tables currently implemented
* [portfolio](#portfolio): all currently active trades
* [orderbook_daily](#orderbook_daily): record of all executed trades
* [stoploss_daily](#stoploss_daily): record of all stop losses
* [currency_translation](#currency_translation): translation of all symbol currencies to account currency
* [currency_translation](#currency_translation): translation of all symbol currencies to account currency
* [performance_record](#performance_record): tracks the performance of the system through time
-------------------------------------------------------------------------------
Table `account` <a name="account"></a>
......@@ -36,6 +42,8 @@ following variables are currently needed by the program (and expected in the tab
* balance (current free cash in account)
* 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.
......@@ -50,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;
```
-------------------------------------------------------------------------------
......@@ -452,6 +454,7 @@ This table stores all transaction that were ever taken. The metadata is used for
* P_L_total: if sell: profit/loss of total position (in account currency)
* P_L_piece: if sell: profit/loss per unit (in account currency)
* P_L_percent: if sell: profit/loss in percent (in account currency)
* fee: the transaction cost (e.g. fees) for this order
#### Creation
......@@ -475,6 +478,7 @@ CREATE TABLE `orderbook_daily` (
`P_L_total` decimal(10,2),
`P_L_piece` decimal(10,2),
`P_L_percent` decimal(10,2),
`fee` decimal(6,6),
PRIMARY KEY (`date`,`signaldate`,`symbol`, `price`, `type`,`buy_sell`, `signalname`));
```
......@@ -507,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
......@@ -527,14 +533,64 @@ 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
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;
```
-------------------------------------------------------------------------------
Table `performance_record` <a name="performance_record"></a>
----------------------------------------------------
#### Description
This table holds the performance of the trading system over time. For that it
includes a datestamp, and stores the account information for every traded day.
The table holds the following columns:
* date
* symbol: This field exists for the sole purpose we can use the class indicators
and its methods for different performance measures
* daynr
* cash: available free cash at above date
* 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:
```
CREATE TABLE `performance_record` (
`date` date NOT NULL,
`symbol` CHAR(11),
`daynr` int,
`cash` decimal(16,2),
`equity` decimal(16,2),
`risk free equity` decimal(16,2),
`total` decimal(16,2),
`total_high` decimal(16,2),
PRIMARY KEY (`date`));
```
#### Example queries
```
tbd
......
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.
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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.