I'm tracking portfolio equity curve for different iterations of weight-allocations, and running into 2 issues -
1) I set a global Dictionary called equityGrid with weights Tuple as a key and equity curve TimeSeries as value - this is giving a compilation error - how do i declare this, so i can use it in OnBarPeriod?
SetVariable("equityGrid", new Dictionary<Tuple<int, int>, TimeSeries>());
2) I need to use 3 functions (ref, sharpe, stddev) in OnEndPeriod (to calculate return and sharpe ratio for this equity curve), but not sure how to code it so it gets parsed ..
ret = (curEquity[0] - ref(curEquity, lookback))/ref(curEquity, lookback));
sharp = sharpe(curEquity, lookback);
vol = stddev(curEquity, lookback);
If Data.ParseFormula( ) should be used, I don't know how to pass it the curEquity TimeSeries - Please advise code for this command.
1/ Use KeyValuePair instead of tuple. They are the same. Tuple is not supported in the .Net Framework 2.0
2/ Unfortunately, this isn't possible. You cannot pass the "curEquity" series to the parser. You need to implement the standard deviation function from scratch then the Sharpe.
I'm using TimeSeries objects to store calculated values at each bar in my MM OnEndBar event.
I get a compilation error when i try to assign a value to the latest TimeSeries element - for example this assignment to curEquity[0] doesn't work
curEquity[0] = (i*close[0][0] + j*close[1][0] + (100-i-j)*close[2][0])/100.0;
How do i declare a time series vector in MM so i can assign values to each bar, plot it and use its past values in calculations - for example, also want to do this ..
perf = (curequity[0] - curequity[lookback])/curequity[lookback];
I tried to use Dictionary instead of TimeSeries, so i can store values in a List inside the Dictionary on each bar. Something like -
- Dictionary<string, List<double>> equityGrid = new Dictionary<string, List<double>>();
However, defining it locally in OnEndPeriod event doesn't seem to help as it doesn't retain the values in the list in the next OnEndPeriod bar. So, I tried Global definition as described in the document, but it gives a compilation error -
- SetVariable("equityGrid", new Dictionary<string, List<double>>());
1) Please advise how to define this Global dictionary, so i can store a value (equity value) at each bar in a List inside this dictionary.
2) Pl also address my earlier question reg how to store values in TimeSeries if possible - that would simplify the code dramatically, as i don't need to deal with Lists inside Dictionaries.
I tried declaring in Global event as described below, but it gives a compilation error -
- SetVariable("equityGrid", new Dictionary<string, List<double>>());
Please advise the declaration format that would work..
Do i need to also declare in the OnEndPeriod event?
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.