|
Jaime Mauro
2018-01-08 15:32:07
|
|
Good Day,
Can you suggest a way to design a strategy, that could dynamically hedge based on signals the strategy generates?
For example, I want to buy stocks if they went up by a certain percentage today. I either want to buy the close of the trigger day(pct performance threshhold is met today therefore I buy today OR
I may decide instead to buy TOMORROW's open). However, whatever capital is generated for these BUYS----which will vary each day----must be matched with an equal amount of SHORT
capital in symbol SPY, at same time as BUY occurs.
Suggestions?
Thank you.
JM
|
|
|
|
QuantShare
2018-01-09 04:53:14
0
|
|
Hi,
You need to use a money management script for this. Here is an example that you can download, check and update. Note that this requires some basic C# knowledge.
Hedge a portfolio strategy
(by QuantShare,
uploaded several months ago)
No notes
|
|
|
|
|
Jaime Mauro
2018-01-09 10:16:56
0
|
|
Thank you kindly for the script! I will examine, but am no C# expert. Is there a quick and dirty way to get it to rebalance on a DAILY basis??
|
|
|
|
QuantShare
2018-01-10 08:31:03
0
|
|
Are you referring to the hedge?
|
|
|
|
Jaime Mauro
2018-01-10 09:17:47
0
|
|
Yes....referring to the hedge. If I have a strategy that buys tomorrow's open for example and sells tomorrow's close, the capital invested for those trades(assume all long), is matched by some percent of that capital in the hedge, call it SPY. Next open I have new signals and new trades for the day. I'd like the SPY hedge to be rebalanced based on the amount of capital I have in for the NEW day. Will that work with this script? Documentation indicates it may only do that rebalancing on a weekly or monthly basis.
Thank you for your consideration.
|
|
|
|
QuantShare
2018-01-11 03:37:27
0
|
|
You will need to edit the money management script. That one will rebalance on monthly basis.
If you want to rebalance daily for example, you can replace the code before #functions" line in the "OnEndPeriod" event and put this instead:
// Adjust hedge position
double longshort = (double)Variables.GetVariable("Long (1) or Short (0)");
if(longshort == 1)
{
AdjustPosition(false, Orders, Functions);
}
else
{
AdjustPosition(true, Orders, Functions);
}
|
|
|
|
Jaime Mauro
2018-01-11 10:51:09
0
|
|
Very interesting, but wouldn't I need to adjust all of the MONTH variables to DAY or something as well?? I just leave all those variables under section // Track changes in month as MONTH??
Thanks.
|
|
|
|
Jaime Mauro
2018-01-11 11:06:46
0
|
|
Also, when I ran my first test using this money management script as written, it NEVER rebalances, monthly or otherwise. I have a long strategy and set to symbol SPY and 100% of equity, then toggled the long/short switch first LONG, then SHORT and did separate backtests. Script looks like it initiates the hedge at the beginning of whatever date range I have and keeps it on for the full duration of that date range.
|
|
|
|
QuantShare
2018-01-12 03:18:41
0
|
|
Yes, the script does not work exactly the way you want it to work.
You need to create your own script or you can hire one of our programmers to implement this script for you. You can send an email to support and we will send you a quote.
|
|
|
|