Commit c384cd12 authored by denis's avatar denis

fixed 2 regressions regarding the SIGNAL_REGIME_FILTER, first it was not...

fixed 2 regressions regarding the SIGNAL_REGIME_FILTER, first it was not evaluated at all after rewrite of v.0.4, second especially TNI calculation was buggy
parent 1e232bf3
Pipeline #135195218 passed with stage
in 1 minute and 18 seconds
-------------------------------------------------------------------------------
# OTraSys v0.5.1, released on ????
The Open Trading System v0.5
An open source framework to create trading systems
# changes from v0.5.0
-------------------
## Description
## New features ##
* database changes:
Please note that the changes mentioned below break compatibility with prior program versions!
- changed string length for `symbol` in all tables to 40 (was: 10)
## Bugfixes ##
* SIGNAL_REGIME_FILTER in general did not work as the flag was not evaluated due to a regression
* SIGNAL_REGIME_FILTER=TNI in special now working again, the calculation was broken since code
refactoring during v0.4.0 development (separate problem from above bugfix)
-------------------------------------------------------------------------------
# OTraSys v0.5.0, released on March, 20th 2020
The Open Trading System v0.5
......@@ -61,7 +79,6 @@ The database record for all stoplosses was redone and is working again.
Please note that the changes mentioned below break compatibility with prior program versions!
- added field `fee` to `orderbook_daily` and `sum_fees', `all_time_high` to `account`
- added new table `performance_record` that tracks account information for each day
- renamed table `stoploss_daily` to `stoploss_record`, now using the fields as defined
in the documentation (see [table stoploss_record](docs/database_structure.md#stoploss_record))
......
......@@ -443,6 +443,49 @@ int execution_manager(class_accounts *the_account, class_market_list *market_lis
skip_reason = bfromcstr("due to SIGNAL_EXECUTION_PYRAMID = none");
skip_signal = true;
}
int market_daynr_idx = -1;
const int market_closePos = market_list->markets[marketPos]->IndPos.close;
const int market_openPos = market_list->markets[marketPos]->IndPos.open;
if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "real_date"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->nr_elements - 1;
check(market_daynr_idx >=0, "no quote index nr. %i in quote %s in market %s!",
error_market_daynr_idx, market_daynr_idx,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
else if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "signal_date"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_closePos]->QuoteObj->findDaynrIndexlB(market_list->markets[marketPos]->Ind[market_closePos]->QuoteObj, *daily_signals->Sig[current_signal]->SIG_DAYNR);
check(market_daynr_idx >=0, "no quote for daynr %i found within %s in market %s!",
error_market_daynr_idx, *daily_signals->Sig[current_signal]->SIG_DAYNR,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
else if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "signal_next"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->findDaynrIndex(market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj, *daily_signals->Sig[current_signal]->SIG_DAYNR) + 1;
check(market_daynr_idx >=0, "no quote for daynr %i found within %s in market %s!",
error_market_daynr_idx, *daily_signals->Sig[current_signal]->SIG_DAYNR,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
// check if current market regime allows execution of signals
if(!biseqcstr(parms.SIGNAL_REGIME_FILTER, "none"))
{
float regime_filter_today = 0;
const int regPos = market_list->markets[marketPos]->getIndicatorPos(market_list->markets[marketPos], "regime_filter");
regime_filter_today = market_list->markets[marketPos]->Ind[regPos]->QuoteObj->quotevec[market_daynr_idx];
if(regime_filter_today)
{
skip_reason = bfromcstr("due to filtered by SIGNAL_REGIME_FILTER");
skip_signal = true;
}
}
// find out which weekday the signal occured
bstring weekday = NULL;
......@@ -477,35 +520,6 @@ int execution_manager(class_accounts *the_account, class_market_list *market_lis
bdestroy(skip_reason);
continue;
}
int market_daynr_idx = -1;
const int market_closePos = market_list->markets[marketPos]->IndPos.close;
const int market_openPos = market_list->markets[marketPos]->IndPos.open;
if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "real_date"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->nr_elements - 1;
check(market_daynr_idx >=0, "no quote index nr. %i in quote %s in market %s!",
error_market_daynr_idx, market_daynr_idx,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
else if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "signal_date"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_closePos]->QuoteObj->findDaynrIndexlB(market_list->markets[marketPos]->Ind[market_closePos]->QuoteObj, *daily_signals->Sig[current_signal]->SIG_DAYNR);
check(market_daynr_idx >=0, "no quote for daynr %i found within %s in market %s!",
error_market_daynr_idx, *daily_signals->Sig[current_signal]->SIG_DAYNR,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
else if(biseqcstr(parms.SIGNAL_EXECUTION_DATE, "signal_next"))
{
market_daynr_idx = market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->findDaynrIndex(market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj, *daily_signals->Sig[current_signal]->SIG_DAYNR) + 1;
check(market_daynr_idx >=0, "no quote for daynr %i found within %s in market %s!",
error_market_daynr_idx, *daily_signals->Sig[current_signal]->SIG_DAYNR,
bdata(*market_list->markets[marketPos]->Ind[market_openPos]->QuoteObj->quotetype),
bdata(*market_list->markets[marketPos]->symbol));
}
float theMarketWeight = 0;
theMarketWeight = market_list->getMarketWeight(market_list, marketPos);
......
......@@ -319,15 +319,15 @@ int ichimoku_tni(class_indicators *tenkan, class_indicators *kijun, class_indica
float *trend_normality=NULL;
trend_normality = init_1d_array_float(tenkan->NR_ELEMENTS);
for(i=0; i<tenkan->NR_ELEMENTS; i++)
{
if((senkouA->QUOTEVEC[i] - senkouB->QUOTEVEC[i]) != 0) //make sure we avoid division by 0
trend_normality[i] = (tenkan->QUOTEVEC[i] - kijun->QUOTEVEC[i]) / (senkouA->QUOTEVEC[i] - senkouB->QUOTEVEC[i]);
else
trend_normality[i] = 1.1; // has to be only >1, will be a filtered trade anyhow
// determine tni as a "switch" (see comments in function description)
// determine tni as a "switch" (see comments in function description)
if((trend_normality[i] < 0) || (trend_normality[i] > 1))
tni->QUOTEVEC[i] = 1;
else
......@@ -385,21 +385,6 @@ int ichimoku_update_indicators(class_market* the_market)
const int senkouAPos = the_market->getIndicatorPos(the_market, "senkou_A");
const int senkouBPos = the_market->getIndicatorPos(the_market, "senkou_B");
// create trend normality indicator if market regime filter is configured
// note that there is no special "TNI" field/table as TNI is only
// one option for market regime filter, so it will be stored as "regime
// filter" in the table indicators_daily
if(biseqcstr(parms.SIGNAL_REGIME_FILTER, "TNI"))
{
the_market->addNewIndicator(the_market, "regime_filter", parms.INDI_DAYS_TO_UPDATE, "Trend Normality Indicator", "indicators_daily");
const int regPos = the_market->getIndicatorPos(the_market, "regime_filter");
the_market->copyIndicatorQuotes(the_market, "close", "regime_filter");
ichimoku_tni(the_market->Ind[tenkanPos], the_market->Ind[kijunPos],
the_market->Ind[senkouAPos], the_market->Ind[senkouBPos],
the_market->Ind[regPos]);
the_market->Ind[regPos]->db_saveflag = true;
}
the_market->copyIndicatorQuotes(the_market, "close", "HH_short");
the_market->copyIndicatorQuotes(the_market, "close", "HH_mid");
the_market->copyIndicatorQuotes(the_market, "close", "HH_long");
......@@ -425,6 +410,21 @@ int ichimoku_update_indicators(class_market* the_market)
ichimoku_senkou_A(parms.ICHI_PERIOD_MID, the_market->Ind[tenkanPos], the_market->Ind[kijunPos], the_market->Ind[senkouAPos]);
ichimoku_senkou_B(parms.ICHI_PERIOD_MID, the_market->Ind[hhlongPos], the_market->Ind[lllongPos],the_market->Ind[senkouBPos]);
// create trend normality indicator if market regime filter is configured
// note that there is no special "TNI" field/table as TNI is only
// one option for market regime filter, so it will be stored as "regime
// filter" in the table indicators_daily
if(biseqcstr(parms.SIGNAL_REGIME_FILTER, "TNI"))
{
the_market->addNewIndicator(the_market, "regime_filter", parms.INDI_DAYS_TO_UPDATE, "Trend Normality Indicator", "indicators_daily");
const int regPos = the_market->getIndicatorPos(the_market, "regime_filter");
the_market->copyIndicatorQuotes(the_market, "close", "regime_filter");
ichimoku_tni(the_market->Ind[tenkanPos], the_market->Ind[kijunPos],
the_market->Ind[senkouAPos], the_market->Ind[senkouBPos],
the_market->Ind[regPos]);
the_market->Ind[regPos]->db_saveflag = true;
}
// set flag so indicators will be written to db if market->saveAllIndicatorsDB(market) is called
the_market->Ind[hhshortPos]->db_saveflag = true;
the_market->Ind[hhmidPos]->db_saveflag = true;
......
......@@ -68,8 +68,8 @@
const int MAJOR_VERSION_NR=0;
const int RELEASE_NR = 5;
const int SUB_RELEASE_NR = 0;
const char SUBRELEASE_SUFFIX[]="";
const int SUB_RELEASE_NR = 1;
const char SUBRELEASE_SUFFIX[]="dev";
/**< Flag set by ‘--verbose’ */
bool verbose_flag=false;
......
......@@ -6,7 +6,7 @@ sh sql2csv.sh -c otrasys -i performance -o performance
rm performance.sql
echo "set key font \",20\"" > performance.plot
echo "set title \"Ichinscratchy Performance Chart\" textcolor \"blue\" offset char -60,0 font \",20\"" >> performance.plot
echo "set title \"OTraSys v0.5.1 Performance Chart\" textcolor \"blue\" offset char -60,0 font \",20\"" >> performance.plot
echo "set terminal pngcairo size 1600,1200 nocrop enhanced font \"arial,12\"" >> performance.plot
echo "set output \"performance.png\"" >> performance.plot
echo "" >> performance.plot
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment