Commit 7e506b3d authored by denis's avatar denis

added a new private variable to class portfolio_element: sl_list_idx, which...

added a new private variable to class portfolio_element: sl_list_idx, which stores the position of this certain portfolio entry within a sl_record_list.
wrote a setter/getter method to access this and adapted all init/clone methods that deal with use portfolio_element objects
parent 0b8195e7
......@@ -48,7 +48,7 @@ static void class_portfolio_destroyImpl(class_portfolio *self);
static class_portfolio* class_portfolio_clonePortfolioImpl(const class_portfolio* original);
static void class_portfolio_printTableImpl(const class_portfolio* self);
static void class_portfolio_addElementImpl(class_portfolio* self, const void* the_element);
static void class_portfolio_addNewElementImpl(class_portfolio* self, const class_market* the_market, const signal_type longorshort, const float quantity, const unsigned int quotenr, const unsigned int indicatorpos, const char* signalstring, const class_accounts* the_account, const int marketListPosition);
static void class_portfolio_addNewElementImpl(class_portfolio* self, const class_market* the_market, const signal_type longorshort, const float quantity, const unsigned int quotenr, const unsigned int indicatorpos, const char* signalstring, const class_accounts* the_account, const int marketListPosition, const int sl_list_idx);
static void class_portfolio_removeElementImpl(class_portfolio* self, unsigned int elementToRemove);
static unsigned int class_portfolio_getNrElementsImpl(const class_portfolio* self);
static unsigned int class_portfolio_getElementIndexImpl(const class_portfolio* self, bstring* symbol, bstring* buydate, bstring* signalname);
......@@ -295,7 +295,7 @@ static void class_portfolio_addElementImpl(class_portfolio* self, const void* th
////////////////////////////////////////////////////////////////////////////
static void class_portfolio_addNewElementImpl(class_portfolio* self, const class_market* the_market, const signal_type longorshort,
const float quantity, const unsigned int quotenr, const unsigned int indicatorpos,
const char* signalstring, const class_accounts* the_account, const int marketListPosition)
const char* signalstring, const class_accounts* the_account, const int marketListPosition, const int sl_list_idx)
{
// increase nr of elements in portfolio object
self->portfolio_private->nr_elements = self->portfolio_private->nr_elements + 1;
......@@ -307,7 +307,7 @@ static void class_portfolio_addNewElementImpl(class_portfolio* self, const class
// create temporary portfolio element
class_portfolio_element_stocks* tmp_element_stocks = NULL;
tmp_element_stocks = class_portfolio_element_stocks_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition);
tmp_element_stocks = class_portfolio_element_stocks_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition, sl_list_idx);
// calculate right values for the new element
tmp_element_stocks->update(tmp_element_stocks, 0.0, true, 0, the_market, quotenr, the_account->getCash(the_account));
......@@ -326,7 +326,7 @@ static void class_portfolio_addNewElementImpl(class_portfolio* self, const class
// create temporary portfolio element
class_portfolio_element_cfdfut* tmp_element_cfdfut = NULL;
tmp_element_cfdfut = class_portfolio_element_cfdfut_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition);
tmp_element_cfdfut = class_portfolio_element_cfdfut_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition, sl_list_idx);
// calculate right values for the new element
tmp_element_cfdfut->update(tmp_element_cfdfut, 0.0, true, 0, the_market, quotenr, the_account->getCash(the_account));
......@@ -346,7 +346,7 @@ static void class_portfolio_addNewElementImpl(class_portfolio* self, const class
// create temporary portfolio element
class_portfolio_element_cfdcur* tmp_element_cfdcur = NULL;
tmp_element_cfdcur = class_portfolio_element_cfdcur_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition);
tmp_element_cfdcur = class_portfolio_element_cfdcur_init(the_market, longorshort, quantity, quotenr, indicatorpos, signalstring, the_account, marketListPosition, sl_list_idx);
// calculate right values for the new element
tmp_element_cfdcur->update(tmp_element_cfdcur, 0.0, true, 0, the_market, quotenr, the_account->getCash(the_account));
......
......@@ -48,7 +48,7 @@ typedef void (*destroyPortfolioFunc)(struct _class_portfolio*);
typedef struct _class_portfolio*(*clonePortfolioFunc)(const struct _class_portfolio*);
typedef void (*printPortfolioTableFunc)(const struct _class_portfolio*);
typedef void (*addPortfolioElementFunc)(struct _class_portfolio*, const void*);
typedef void (*addNewPortfolioElementFunc)(struct _class_portfolio*, const struct _class_market*, const enum _longshort, const float, const unsigned int, const unsigned int, const char*, const struct _class_accounts*, const int);
typedef void (*addNewPortfolioElementFunc)(struct _class_portfolio*, const struct _class_market*, const enum _longshort, const float, const unsigned int, const unsigned int, const char*, const struct _class_accounts*, const int, const int);
typedef void (*removePortfolioElementFunc)(struct _class_portfolio*, unsigned int);
typedef unsigned int (*getNrPortfolioElementsFunc)(const struct _class_portfolio*);
typedef unsigned int (*getElementIndexFunc)(const struct _class_portfolio*, bstring*, bstring*, bstring*);
......
......@@ -46,6 +46,8 @@ static void class_portfolio_element_printPortfolioElementTableImpl(const void* s
static void class_portfolio_element_update_byMarketImpl(void *self, float new_sl, bool new_isl_flag, unsigned int new_trading_days, const class_market* the_market, unsigned int quotenr, float account_cash);
static int class_portfolio_element_getMarketListPositionImpl(const void* self);
static void class_portfolio_element_setMarketListPositionImpl(void* self, const int pos);
static int class_portfolio_element_getSL_list_idxImpl(const void* self);
static void class_portfolio_element_setSL_list_idxImpl(void* self, const int idx);
///////////////////////////////////////////////////////////////////////////////
/**
......@@ -61,6 +63,7 @@ static void class_portfolio_element_setMarketListPositionImpl(void* self, const
///////////////////////////////////////////////////////////////////////////////
struct _portfolio_element_private{
int posMarketList; /**< position of particular market in market_list */
int sl_list_idx; /**< index of this element within a stoploss_list */
};
typedef struct _portfolio_element_private portfolio_element_private;
......@@ -89,7 +92,7 @@ class_portfolio_element* class_portfolio_element_init(const class_market* the_ma
const signal_type longorshort, const float quant,
const unsigned int quotenr, const unsigned int indicatorpos,
const char* signalstring, const class_accounts* the_account,
const int marketListPosition)
const int marketListPosition, const int sl_list_idx)
{
class_portfolio_element *self = NULL;
......@@ -162,6 +165,7 @@ class_portfolio_element* class_portfolio_element_init(const class_market* the_ma
// init private variables
self->portfolio_element_private->posMarketList = marketListPosition;
self->portfolio_element_private->sl_list_idx = sl_list_idx;
// set methods
class_portfolio_element_setMethods(self);
......@@ -192,6 +196,9 @@ static void class_portfolio_element_setMethods(class_portfolio_element* self)
self->update = class_portfolio_element_update_byMarketImpl;
self->getMarketListPosition = class_portfolio_element_getMarketListPositionImpl;
self->setMarketListPosition = class_portfolio_element_setMarketListPositionImpl;
self->getSL_list_idx = class_portfolio_element_getSL_list_idxImpl;
self->setSL_list_idx = class_portfolio_element_setSL_list_idxImpl;
}
///////////////////////////////////////////////////////////////////////////////
......@@ -251,7 +258,8 @@ static class_portfolio_element* class_portfolio_element_clonePortfolioElementImp
tmp_original->Buyquote_market->nr_digits, bdata(*tmp_original->Buyquote_market->datevec), *tmp_original->Buyquote_market->daynrvec,
*tmp_original->Buyquote_account->quotevec, tmp_original->Buyquote_account->nr_digits, bdata(*tmp_original->Buyquote_account->datevec),
*tmp_original->Buyquote_account->daynrvec, *tmp_original->Buyquote_signal->quotevec, tmp_original->Buyquote_signal->nr_digits,
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname), tmp_original->getMarketListPosition(tmp_original));
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname),
tmp_original->getMarketListPosition(tmp_original), tmp_original->portfolio_element_private->sl_list_idx);
// now copy data from original to clone
bdestroy(*clone->currQuote_account->datevec); // free bstrings before assigning new
......@@ -298,7 +306,7 @@ static class_portfolio_element* class_portfolio_element_clonePortfolioElementImp
class_portfolio_element* class_portfolio_element_init_manually(char* symbol, char* markettype, char* market_currency, signal_type longorshort,
float quant, float market_quote, unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date, unsigned int aq_daynr,
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition)
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition, const int sl_list_idx)
{
class_portfolio_element *self = NULL;
......@@ -361,6 +369,7 @@ class_portfolio_element* class_portfolio_element_init_manually(char* symbol, cha
// init private variables
self->portfolio_element_private->posMarketList = marketListPosition;
self->portfolio_element_private->sl_list_idx = sl_list_idx;
// set methods
class_portfolio_element_setMethods(self);
......@@ -567,4 +576,46 @@ static void class_portfolio_element_setMarketListPositionImpl(void* self, const
tmp_self->portfolio_element_private->posMarketList = pos;
}
///////////////////////////////////////////////////////////////////////////////
/**
* @brief returns the position of a portfolio_element`s sl_record within a
* sl_record_list
*
* This function returns the position of a portfolio_element`s sl_record within
* a sl_record_list
*
* @param self pointer to portfolio_element struct
* @return index as int
*/
///////////////////////////////////////////////////////////////////////////////
static int class_portfolio_element_getSL_list_idxImpl(const void* self)
{
// first upcast void pointer of argument to right type
class_portfolio_element* tmp_self = NULL;
tmp_self = (class_portfolio_element*) self;
return tmp_self->portfolio_element_private->sl_list_idx;
}
///////////////////////////////////////////////////////////////////////////////
/**
* @brief sets the position of a portfolio_element`s sl_record within a
* sl_record_list
*
* This function sets the position of a portfolio_element`s sl_record within
* a sl_record_list
*
* @param self pointer to portfolio_element struct
* @param index as int
*/
///////////////////////////////////////////////////////////////////////////////
static void class_portfolio_element_setSL_list_idxImpl(void* self, const int idx)
{
// first upcast void pointer of argument to right type
class_portfolio_element* tmp_self = NULL;
tmp_self = (class_portfolio_element*) self;
tmp_self->portfolio_element_private->sl_list_idx = idx;
}
// eof
......@@ -49,6 +49,8 @@ typedef void (*printPortfolioElementTableFunc)(const void*);
typedef void (*updatePortfolioElementbyMarketFunc)(void*, float, bool, unsigned int, const struct _class_market*, unsigned int, float);
typedef int (*getMarketListPositionFunc)(const void*);
typedef void (*setMarketListPositionFunc)(void*, const int);
typedef int (*getSL_list_idxFunc)(const void*);
typedef void (*setSL_list_idxFunc)(void*, const int);
///////////////////////////////////////////////////////////////////////////////
/**
......@@ -95,6 +97,8 @@ struct _class_portfolio_element
updatePortfolioElementbyMarketFunc update; /**< update portfolio element "automatically" by market information */
getMarketListPositionFunc getMarketListPosition; /**< returns the position of element´s market within a market list */
setMarketListPositionFunc setMarketListPosition; /**< sets the position of element´s market within a market list */
getSL_list_idxFunc getSL_list_idx; /**< get the position of this element within a sl_record_list */
setSL_list_idxFunc setSL_list_idx; /**< set the position of this element within a sl_record_list */
//private part
struct _portfolio_element_private *portfolio_element_private; /**< opaque pointer to private data and functions */
......@@ -103,11 +107,11 @@ struct _class_portfolio_element
// "constructor" for portfolio_element "objects"
class_portfolio_element* class_portfolio_element_init(const class_market* the_market,const signal_type longorshort,
const float quant, const unsigned int quotenr, const unsigned int indicatorpos,
const char* signalstring, const class_accounts* the_account, const int marketListPosition);
const char* signalstring, const class_accounts* the_account, const int marketListPosition, const int sl_list_idx);
class_portfolio_element* class_portfolio_element_init_manually(char* symbol, char* markettype, char* market_currency,
signal_type longorshort, float quant, float market_quote, unsigned int mq_digits, char* mq_date,
unsigned int mq_daynr, float account_quote, unsigned int aq_digits, char* aq_date,
unsigned int aq_daynr, float signal_quote, unsigned int sq_digits, char* sq_date,
unsigned int sq_daynr, char* signalstring, const int marketListPosition);
unsigned int sq_daynr, char* signalstring, const int marketListPosition, const int sl_list_idx);
#endif // CLASS_PORTFOLIO_ELEMENT_H
// eof
......@@ -74,7 +74,8 @@ class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init(const class_
const unsigned int indicatorpos,
const char* signalstring,
const class_accounts* the_account,
const int marketListPosition)
const int marketListPosition,
const int sl_list_idx)
{
class_portfolio_element_cfdcur *self = NULL;
......@@ -82,7 +83,7 @@ class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init(const class_
// everything from its parent, portfolio_element
self = (class_portfolio_element_cfdcur*) class_portfolio_element_init(
the_market, longorshort, quant, quotenr,
indicatorpos, signalstring, the_account, marketListPosition);
indicatorpos, signalstring, the_account, marketListPosition, sl_list_idx);
// set class specific methods
class_portfolio_element_cfdcur_setMethods(self);
......@@ -111,7 +112,8 @@ class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init_manually(
unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date,
unsigned int aq_daynr, float signal_quote, unsigned int sq_digits,
char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition)
char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx)
{
class_portfolio_element_cfdcur *self = NULL;
......@@ -121,7 +123,7 @@ class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init_manually(
// everything from its parent, portfolio_element
tmp_element = class_portfolio_element_init_manually(symbol, markettype, market_currency, longorshort,
quant, market_quote, mq_digits, mq_date, mq_daynr, account_quote, aq_digits, aq_date, aq_daynr,
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition);
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition, sl_list_idx);
// now clone the freshly created element and cast it to correct type
self = (class_portfolio_element_cfdcur*) tmp_element->clone(tmp_element);
......@@ -178,7 +180,8 @@ static class_portfolio_element* class_portfolio_element_cfdcur_cloneImpl(const v
tmp_original->Buyquote_market->nr_digits, bdata(*tmp_original->Buyquote_market->datevec), *tmp_original->Buyquote_market->daynrvec,
*tmp_original->Buyquote_account->quotevec, tmp_original->Buyquote_account->nr_digits, bdata(*tmp_original->Buyquote_account->datevec),
*tmp_original->Buyquote_account->daynrvec, *tmp_original->Buyquote_signal->quotevec, tmp_original->Buyquote_signal->nr_digits,
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname), tmp_original->getMarketListPosition(tmp_original));
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname),
tmp_original->getMarketListPosition(tmp_original), tmp_original->getSL_list_idx(tmp_original));
// now copy data from tmp_original to clone
bdestroy(*clone->currQuote_account->datevec); // free bstrings before assigning new
......
......@@ -65,10 +65,11 @@ struct _class_portfolio_element_cfdcur
// "constructor" for portfolio_element "objects"
class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init(const class_market* the_market,const signal_type longorshort,
const float quant, const unsigned int quotenr, const unsigned int indicatorpos, const char* signalstring,
const class_accounts* the_account, const int marketListPosition);
const class_accounts* the_account, const int marketListPosition, const int sl_list_idx);
class_portfolio_element_cfdcur* class_portfolio_element_cfdcur_init_manually(char* symbol, char* markettype, char* market_currency,
signal_type longorshort, float quant, float market_quote, unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date, unsigned int aq_daynr,
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition);
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx);
#endif // CLASS_PORTFOLIO_ELEMENT_CFDFUT_H
// eof
......@@ -74,7 +74,8 @@ class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init(const class_
const unsigned int indicatorpos,
const char* signalstring,
const class_accounts* the_account,
const int marketListPosition)
const int marketListPosition,
const int sl_list_idx)
{
class_portfolio_element_cfdfut *self = NULL;
......@@ -82,7 +83,7 @@ class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init(const class_
// everything from its parent, portfolio_element
self = (class_portfolio_element_cfdfut*) class_portfolio_element_init(
the_market, longorshort, quant, quotenr,
indicatorpos, signalstring, the_account, marketListPosition);
indicatorpos, signalstring, the_account, marketListPosition, sl_list_idx);
// set class specific methods
class_portfolio_element_cfdfut_setMethods(self);
......@@ -111,7 +112,8 @@ class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init_manually(
unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date,
unsigned int aq_daynr, float signal_quote, unsigned int sq_digits,
char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition)
char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx)
{
class_portfolio_element_cfdfut *self = NULL;
......@@ -121,7 +123,7 @@ class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init_manually(
// everything from its parent, portfolio_element
tmp_element = class_portfolio_element_init_manually(symbol, markettype, market_currency, longorshort,
quant, market_quote, mq_digits, mq_date, mq_daynr, account_quote, aq_digits, aq_date, aq_daynr,
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition);
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition, sl_list_idx);
// now clone the freshly created element and cast it to correct type
self = (class_portfolio_element_cfdfut*) tmp_element->clone(tmp_element);
......@@ -178,7 +180,8 @@ static class_portfolio_element* class_portfolio_element_cfdfut_cloneImpl(const v
tmp_original->Buyquote_market->nr_digits, bdata(*tmp_original->Buyquote_market->datevec), *tmp_original->Buyquote_market->daynrvec,
*tmp_original->Buyquote_account->quotevec, tmp_original->Buyquote_account->nr_digits, bdata(*tmp_original->Buyquote_account->datevec),
*tmp_original->Buyquote_account->daynrvec, *tmp_original->Buyquote_signal->quotevec, tmp_original->Buyquote_signal->nr_digits,
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname), tmp_original->getMarketListPosition(tmp_original));
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname),
tmp_original->getMarketListPosition(tmp_original), tmp_original->getSL_list_idx(tmp_original));
// now copy data from tmp_original to clone
bdestroy(*clone->currQuote_account->datevec); // free bstrings before assigning new
......
......@@ -65,10 +65,11 @@ struct _class_portfolio_element_cfdfut
// "constructor" for portfolio_element "objects"
class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init(const class_market* the_market,const signal_type longorshort,
const float quant, const unsigned int quotenr, const unsigned int indicatorpos, const char* signalstring,
const class_accounts* the_account, const int marketListPosition);
const class_accounts* the_account, const int marketListPosition, const int sl_list_idx);
class_portfolio_element_cfdfut* class_portfolio_element_cfdfut_init_manually(char* symbol, char* markettype, char* market_currency,
signal_type longorshort, float quant, float market_quote, unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date, unsigned int aq_daynr,
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition);
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx);
#endif // CLASS_PORTFOLIO_ELEMENT_CFDFUT_H
// eof
......@@ -75,7 +75,8 @@ class_portfolio_element_stocks* class_portfolio_element_stocks_init(const class_
const unsigned int indicatorpos,
const char* signalstring,
const class_accounts* the_account,
const int marketListPosition)
const int marketListPosition,
const int sl_list_idx)
{
class_portfolio_element_stocks *self = NULL;
......@@ -83,7 +84,8 @@ class_portfolio_element_stocks* class_portfolio_element_stocks_init(const class_
// everything from its parent, portfolio_element
self = (class_portfolio_element_stocks*) class_portfolio_element_init(
the_market, longorshort, quant, quotenr,
indicatorpos, signalstring, the_account, marketListPosition);
indicatorpos, signalstring, the_account,
marketListPosition, sl_list_idx);
// set class specific methods
class_portfolio_element_stocks_setMethods(self);
......@@ -112,7 +114,8 @@ class_portfolio_element_stocks* class_portfolio_element_stocks_init_manually(
unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date,
unsigned int aq_daynr, float signal_quote, unsigned int sq_digits,
char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition)
char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx)
{
class_portfolio_element_stocks *self = NULL;
......@@ -122,7 +125,7 @@ class_portfolio_element_stocks* class_portfolio_element_stocks_init_manually(
// everything from its parent, portfolio_element
tmp_element = class_portfolio_element_init_manually(symbol, markettype, market_currency, longorshort,
quant, market_quote, mq_digits, mq_date, mq_daynr, account_quote, aq_digits, aq_date, aq_daynr,
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition);
signal_quote, sq_digits, sq_date, sq_daynr, signalstring, marketListPosition, sl_list_idx);
// now clone the freshly created element and cast it to correct type
self = (class_portfolio_element_stocks*) tmp_element->clone(tmp_element);
......@@ -179,7 +182,8 @@ static class_portfolio_element* class_portfolio_element_stocks_cloneImpl(const v
tmp_original->Buyquote_market->nr_digits, bdata(*tmp_original->Buyquote_market->datevec), *tmp_original->Buyquote_market->daynrvec,
*tmp_original->Buyquote_account->quotevec, tmp_original->Buyquote_account->nr_digits, bdata(*tmp_original->Buyquote_account->datevec),
*tmp_original->Buyquote_account->daynrvec, *tmp_original->Buyquote_signal->quotevec, tmp_original->Buyquote_signal->nr_digits,
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname), tmp_original->getMarketListPosition(tmp_original));
bdata(*tmp_original->Buyquote_signal->datevec), *tmp_original->Buyquote_signal->daynrvec, bdata(*tmp_original->signalname),
tmp_original->getMarketListPosition(tmp_original), tmp_original->getSL_list_idx(tmp_original));
// now copy data from tmp_original to clone
bdestroy(*clone->currQuote_account->datevec); // free bstrings before assigning new
......
......@@ -65,10 +65,11 @@ struct _class_portfolio_element_stocks
// "constructor" for portfolio_element "objects"
class_portfolio_element_stocks* class_portfolio_element_stocks_init(const class_market* the_market,const signal_type longorshort,
const float quant, const unsigned int quotenr, const unsigned int indicatorpos, const char* signalstring,
const class_accounts* the_account, const int marketListPosition);
const class_accounts* the_account, const int marketListPosition, const int sl_list_idx);
class_portfolio_element_stocks* class_portfolio_element_stocks_init_manually(char* symbol, char* markettype, char* market_currency,
signal_type longorshort, float quant, float market_quote, unsigned int mq_digits, char* mq_date, unsigned int mq_daynr,
float account_quote, unsigned int aq_digits, char* aq_date, unsigned int aq_daynr,
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring, const int marketListPosition);
float signal_quote, unsigned int sq_digits, char* sq_date, unsigned int sq_daynr, char* signalstring,
const int marketListPosition, const int sl_list_idx);
#endif // CLASS_PORTFOLIO_ELEMENT_STOCKS_H
// eof
......@@ -1200,19 +1200,19 @@ int mysql_get_portfolio(class_portfolio *the_portfolio)
quantity, buyquote_market, buyquote_market_digits, row[4], buydaynr_market,
buyquote_account, buyquote_account_digits, row[7], buydaynr_account,
buyquote_signal, buyquote_signal_digits, row[10], buydaynr_signal,
row[19], -1); // note that last parameter is a dummy one which has to be properly set within a function that has an idea of market_lists
row[19], -1, -1); // note that last parameters are dummy ones which have to be properly set within a function that has an idea of market_lists and stop losses
else if(biseqcstr(tmp1, "CFDCUR"))
tmp_element = (class_portfolio_element*) class_portfolio_element_cfdcur_init_manually(row[0], row[1], row[2], element_type,
quantity, buyquote_market, buyquote_market_digits, row[4], buydaynr_market,
buyquote_account, buyquote_account_digits, row[7], buydaynr_account,
buyquote_signal, buyquote_signal_digits, row[10], buydaynr_signal,
row[19], -1);
row[19], -1, -1);
else if(biseqcstr(tmp1, "CFDFUT"))
tmp_element = (class_portfolio_element*) class_portfolio_element_cfdfut_init_manually(row[0], row[1], row[2], element_type,
quantity, buyquote_market, buyquote_market_digits, row[4], buydaynr_market,
buyquote_account, buyquote_account_digits, row[7], buydaynr_account,
buyquote_signal, buyquote_signal_digits, row[10], buydaynr_signal,
row[19], -1);
row[19], -1, -1);
else
{
log_err("found unknown market type %s for market %s in database... Aborting!", row[1], row[0]);
......
......@@ -595,13 +595,15 @@ int execution_manager(class_accounts *the_account, class_market_list *market_lis
}
else
quantity = theMarketWeight;
the_portfolio->addNewElement(the_portfolio,
market_list->markets[marketPos],
daily_signals->Sig[current_signal]->type, quantity,
market_daynr_idx, market_closePos,
bdata(*daily_signals->Sig[current_signal]->name),
the_account, marketPos);
the_account, marketPos, -1); // TODO: change -1
// get idx of last created portfolio_element
unsigned int element_idx = the_portfolio->getNrElements(the_portfolio) - 1;
......
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