- ago
I follow Sample Strategies - Pairs Trading

Originally there were 100+ stocks

five groups of stocks
run backtest this speed normal?

Code :

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript1 {    public class PairTrading_sample : UserStrategyBase    {       string[,] Pair = new string[5, 2] { {"SA1", "SB1" }, { "SA2", "SB2" }, { "SA3", "SB3" }, { "SA4", "SB4" }, { "SA5", "SB5" } };       string A_stock = "", B_stock = "";       BarHistory A_stockBarHistory, B_stockBarHistory;       int MAPeriod = 20;       TimeSeries close1, close2, ActualRatio, ActualRatioSMA, Delta, DeltaSMA, DeltaDifference, DeltaNorm;       public override void Initialize(BarHistory bars)       {          StartIndex = MAPeriod;          for (int i = 0; i <= 4; i++)          {             if (Pair[i, 0] == bars.Symbol)             {                B_stock = Pair[i, 1];                break;             }          }          A_stockBarHistory = GetHistory(bars, bars.Symbol);          B_stockBarHistory = GetHistory(bars, B_stock);          close1 = A_stockBarHistory.Close;          close2 = B_stockBarHistory.Close;          ActualRatio = close1 / close2;          ActualRatioSMA = SMA.Series(ActualRatio, MAPeriod);          Delta = ActualRatio - ActualRatioSMA;          DeltaSMA = SMA.Series(Delta, MAPeriod);          DeltaDifference = Delta - DeltaSMA;          DeltaNorm = DeltaDifference / StdDev.Series(Delta, MAPeriod);          PlotTimeSeries(DeltaNorm, "DeltaNorm", A_stockBarHistory.Symbol, Color.Navy);          PlotBarHistory(B_stockBarHistory, B_stockBarHistory.Symbol, Color.Green, false);       }       public override void PreExecute(DateTime dt, List<BarHistory> participants)       {       }       public override void Execute(BarHistory bars, int idx)       {       }    } }
0
1,445
Solved
15 Replies

Reply

Bookmark

Sort
- ago
#1
How do you determine "slow" exactly?
What historical data providers are selected in the Data Manager?
What are the Strategy settings?
0
- ago
#2
1 - Original Pair Trading QQQ / SPY ( 1 group) run backtest spend few seconds.
i change {"SA1", "SB1" }, { "SA2", "SB2" }, { "SA3", "SB3" }, { "SA4", "SB4" }, { "SA5", "SB5" } ( 5 groups) run backtest need to spend 3 ~ 5 minutes

The time gap is huge.

2 - DataSets from ASCII (txt file)
Image :


3 - Strategy Settings

Data Scale : Daily / Weekly (Weekly slow too)
Data Range : Most Recent N Years
Number of Years : 5Y or 10Y (5Y speed slow too)

Image :
0
- ago
#3
QUOTE:
2 - DataSets from ASCII (txt file)

What historical data providers are selected in the Data Manager > "Historical Providers" tab?
0
- ago
#4
Import txt file, so seleted Data Provider Linked -> ASCII
0
- ago
#5

0
- ago
#6
I'm asking whether you have other historical data providers selected in the Data Manager > "Historical Providers" tab.

And also the same important question regarding the "Event providers" tab. Which providers have you selected in these two tabs?

My point is, the more checkmarks the more requests for data Wealth-Lab makes to each provider, historical or fundamental. Despite the low number of symbols you may be experiencing a network timeout, for example.
0
- ago
#7
0
- ago
#8
Try unchecking WD, QD and Y.

And Event providers??
0
- ago
#9
QUOTE:

Try unchecking WD, QD and Y.

And Event providers??


Ok, unchcking WD / QD / Y

Event provviders Image :


0
- ago
#10
I'd recommend you uncheck everything here as well for the purpose of experiment. Does it have any effect on the performance?
0
Best Answer
- ago
#11
QUOTE:

I'd recommend you uncheck everything here as well for the purpose of experiment. Does it have any effect on the performance?


Ok!
0
- ago
#12
QUOTE:
... the more checkmarks the more requests for data Wealth-Lab makes to each provider, historical or fundamental. Despite the low number of symbols you may be experiencing a network timeout, for example.
Aren't these raw data values cached such that there would be a one-time delay (acceptable), but future runs would be much faster?
0
- ago
#13
@superticker
Yes but none of topic starter's symbols can be found by any data provider like WD or Yahoo so there's no cache.
1
Cone8
 ( 6.17% )
- ago
#14
... but Wealth-Lab will check for data with the linked DataSet Provider first, in this case, ASCII.

Nonetheless (although not definitively confirmed here) the problem often is the delay getting "missing" data from the Event Providers. This keeps coming up and I think we need a smart option... like, "Only update Event Providers for Scheduled Updates."
0
- ago
#15
QUOTE:
... but Wealth-Lab will check for data with the linked DataSet Provider first, in this case, ASCII.

Right but I'm talking about the delay imposed by requesting Events for unsupported symbols, not their historical data.
1

Reply

Bookmark

Sort