Commit 0b8195e7 authored by denis's avatar denis

further work on infrastructure to track/save all stop losses ever considered

parent 571ad185
Pipeline #123750531 passed with stage
in 1 minute and 25 seconds
This diff is collapsed.
/* class_stoploss_list.h
* declarations for class_stoploss_list.c, interface for
* "stoploss_list" class
* This file is part of ichinscratchy
* Copyright (C) 2016-2020 Denis Zetzmann [email protected]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* The Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file class_stoploss_list.h
* @brief Header file for class_stoploss_list.c
*
* This file contains the declarations for class_stoploss_list.c
* @author Denis Zetzmann
*/
#ifndef CLASS_STOPLOSS_LIST_H
#define CLASS_STOPLOSS_LIST_H
......@@ -7,22 +33,24 @@
#include "datatypes.h"
#include "class_stoploss_record.h"
struct _class_signal_list;
struct _class_stoploss_list;
typedef void (*destroyStopLossListFunc)(struct _class_stoploss_list*);
typedef struct _class_stoploss_list* (*cloneStopLossListFunc)(const struct _class_stoploss_list*);
typedef void (*printStopLossListTableFunc)(const struct _class_stoploss_list*);
typedef void (*addNewSLFunc)(struct _class_stoploss_list*, char* datestring, unsigned int daynr, float price, float indicator_quote, char* symbol, signal_type type, strength_type strength, unsigned int nrOfDigits, char* signal_name, char* signal_description, char* amp_info, char* tablename);
typedef void (*addSLFunc)(struct _class_signal_list*,struct _class_signal*);
typedef void (*addNewSLFunc)(struct _class_stoploss_list*, char* quote_symbol, unsigned int nr_records, unsigned int nrOfDigits, char* buydate, char* stoploss_type);
typedef void (*addSLFunc)(struct _class_stoploss_list*, const struct _class_sl_record*);
typedef void (*saveAllSLFunc)(const struct _class_stoploss_list*);
typedef void (*removeSLFunc)(struct _class_signal_list*, unsigned int elementToRemove);
typedef void (*saveAllSLFunc)(const struct _class_signal_list*);
struct _class_stoploss_list
{
// public part
// DATA
bstring* name; /**< list of this list of signals */
class_stoploss_record** SL; /**< vector to members of signal class */
class_sl_record** SL; /**< vector to members of signal class */
unsigned int nr_records; /**< nr of signals contained in object */
// Methods
......
......@@ -42,6 +42,7 @@
#include "date.h"
#include "class_signals.h"
#include "class_signal_list.h"
#include "class_stoploss_list.h"
#include "stoploss.h"
#include "datatypes.h"
#include "ichimoku.h"
......@@ -300,7 +301,6 @@ int execution_manager(class_accounts *the_account, class_market_list *market_lis
performance_equity = class_indicators_init("performance", enddaynr - startdaynr + 1, parms.ACCOUNT_CURRENCY_DIGITS, "equity", "equity in portfolio", "performance_record");
performance_rf_equity = class_indicators_init("performance", enddaynr - startdaynr + 1, parms.ACCOUNT_CURRENCY_DIGITS, "risk_free_equity", "equity @ stop loss", "performance_record");
performance_total_high = class_indicators_init("performance", enddaynr - startdaynr + 1, parms.ACCOUNT_CURRENCY_DIGITS, "total_high", "total high watermark", "performance_record");
// sl_records = N
performance_total->db_saveflag = true;
performance_cash->db_saveflag = true;
......
......@@ -62,6 +62,7 @@
#include "class_order.h"
#include "class_orderbook.h"
#include "class_stoploss_record.h"
#include "class_stoploss_list.h"
const int MAJOR_VERSION_NR=0;
const int RELEASE_NR = 4;
......@@ -399,25 +400,32 @@ int main (int argc, char **argv)
fflush(stdout);
printf("\n\n=============================\ntest stuff :)\n=============================\n");
class_sl_record* the_sl = NULL;
the_sl = class_sl_record_init("XAD", 1, 2, "2020-03-03", "percentage");
// (char* quote_symbol, unsigned int nr_records, unsigned int nrOfDigits, bstring* buydate, bstring* stoploss_type);
// class_quotes* testquote = class_quotes_init("test", 2, 2, "haha", "ulftable");
//
the_sl->QuoteObj->datevec[0] = bfromcstr("2020-03-02"); the_sl->QuoteObj->daynrvec[0] = 40666; the_sl->QuoteObj->quotevec[0] = 666.1;
the_sl->QuoteObj->appendQuoteRecords(the_sl->QuoteObj, 2);
the_sl->QuoteObj->datevec[1] = bfromcstr("2020-03-03"); the_sl->QuoteObj->daynrvec[1] = 40667; the_sl->QuoteObj->quotevec[1] = 999.1;
the_sl->QuoteObj->datevec[2] = bfromcstr("2020-03-04"); the_sl->QuoteObj->daynrvec[2] = 40668; the_sl->QuoteObj->quotevec[2] = 123.1;
// testquote->datevec[3] = bfromcstr("2020-03-05"); testquote->daynrvec[3] = 40669; testquote->quotevec[3] = 321.0;
//
// testquote->printTable(testquote);
// class_sl_record* the_sl = NULL;
// the_sl = class_sl_record_init("XAD", 1, 2, "2020-03-03", "percentage");
//
// // (char* quote_symbol, unsigned int nr_records, unsigned int nrOfDigits, bstring* buydate, bstring* stoploss_type);
// // class_quotes* testquote = class_quotes_init("test", 2, 2, "haha", "ulftable");
// //
// the_sl->QuoteObj->datevec[0] = bfromcstr("2020-03-02"); the_sl->QuoteObj->daynrvec[0] = 40666; the_sl->QuoteObj->quotevec[0] = 666.1;
// the_sl->QuoteObj->appendQuoteRecords(the_sl->QuoteObj, 2);
// the_sl->QuoteObj->datevec[1] = bfromcstr("2020-03-03"); the_sl->QuoteObj->daynrvec[1] = 40667; the_sl->QuoteObj->quotevec[1] = 999.1;
// the_sl->QuoteObj->datevec[2] = bfromcstr("2020-03-04"); the_sl->QuoteObj->daynrvec[2] = 40668; the_sl->QuoteObj->quotevec[2] = 123.1;
// // testquote->datevec[3] = bfromcstr("2020-03-05"); testquote->daynrvec[3] = 40669; testquote->quotevec[3] = 321.0;
// //
// // testquote->printTable(testquote);
// //
// // testquote->destroy(testquote);
// // (char* quote_symbol, unsigned int nr, unsigned int nrOfDigits, char* quotetype, char *tablename);
//
// class_stoploss_list* sl_list = class_stoploss_list_init("new sl list");
// sl_list->addSL(sl_list, the_sl);
// sl_list->printTable(sl_list);
// sl_list->saveToDB(sl_list);
// // the_sl->saveToDB(the_sl);
// the_sl->destroy(the_sl);
//
// testquote->destroy(testquote);
// (char* quote_symbol, unsigned int nr, unsigned int nrOfDigits, char* quotetype, char *tablename);
the_sl->printTable(the_sl);
the_sl->saveToDB(the_sl);
the_sl->destroy(the_sl);
// sl_list->destroy(sl_list);
// printf("\n");
// =================================== end of test stuff (: ================
// ===================================================================================
fflush(stdout);
......
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