READ-ONLY

The forum is now a read-only archive.

For bug reports & platform questions → [email protected]

Our community lives on Discord and YouTube — come join us!

Monte Carlo Verify function

5 replies

huangwh88

Customer, bbp_participant, community, sq-ultimate, 107 replies.

Visit profile

5 years ago #270606

In the documentation here https://strategyquant.com/doc/quantanalyzer/predict-verify-strategy-performance-using-monte-carlo-simulation/, it is mentioned that the verify function is supposed to compare the strategy’s live performance to the range predicted using MC.

But is it possible to import actual live results and compare them to the MC predictions? Right now it seems like it’s splitting the data into IS and OOS portions and comparing the OOS results against MC predictions obtained using IS results.

 

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

5 years ago #270622

Hi,

yes, you can use the MC prediction and apply it on your live trading results. Simply load the results and set the data “Verify – date” to date from which you want to start the prediction simulation. On the example attached results from 1.1.2021 to 24.5.2021 are loaded. The prediction is set to start from 1.3.2021 so we can compare whether we are within MC simulation boundaries with our trading results

Attachments:
You must be logged in to view attached files.

0

Massimo Scapini

Subscriber, bbp_participant, customer, community, sq-ultimate, 59 replies.

Visit profile

3 years ago #280024

Yes,

but in this way I guess that live data before before 1 Mar 2021 are used to simulate data afterwards, which is not what one may want…

I would rather prefer to load  two different sets: 1st the simulated data for the past, 2nd the live data (as in the “Compare Data” section) and then use the 1st data set to simulate the 2nd one.

Can this be workarounded loading past simulated data and live data in a single file ? If yes, which format could be used ?

Moreover, how can I change the number of trades used for the “Predict” function ?

0

Massimo Scapini

Subscriber, bbp_participant, customer, community, sq-ultimate, 59 replies.

Visit profile

3 years ago #280025

I probably found the way (maybe it was just what you suggested but simply I did not understand it !):

1. Load the simulated data

2. Load the live data

3. Create a Portfolio merging 1 & 2

4. Run the MC using the start date of 2 as a reference

5. Done !

0

Massimo Scapini

Subscriber, bbp_participant, customer, community, sq-ultimate, 59 replies.

Visit profile

3 years ago #280041

In principle it works…

… but unfortunately with MT4 the display of results is quite misleading because all the transactions contained in the MT4 report are counted as trades, at least in the graph (I do not know if in the simulation too).

See attachment

 

In order to fix this, you have to clean the MT4 report manually before loading it in QA. Quite annoying

Attachments:
You must be logged in to view attached files.

0

trademaster

Subscriber, bbp_participant, 2 replies.

Visit profile

4 months ago #293111

I overcome this Problem by programming a Filter to Set the Date until there the MC should use the Data. You simply Tip in you Date in yyyymmdd Format and use the Same Date in the verify function.

————————–

package com.strategyquant.extend.MonteCarloMethods;

 

import com.strategyquant.lib.results.SQOrder;

import com.strategyquant.lib.results.SQOrderList;

import com.strategyquant.lib.snippets.MonteCarloSim.MonteCarloMethod;

import java.util.Calendar;

 

public class DateFilter extends MonteCarloMethod {

 

public DateFilter() {

setName(“FilterByDate”);

// Datum im Format YYYYMMDD (z.B. 20231231 für 31.12.2023)

addIntParameter(“_STOP_DATE_”, “Nur Trades bis Datum (YYYYMMDD)”, 20231231, 19000101, 21001231, 1);

setFormatedName(“Filter: Trades bis _STOP_DATE_”);

}

 

@Override

public void compute(SQOrderList originalOrders) throws Exception {

int stopDate = getIntParameterValue(“_STOP_DATE_”);

SQOrderList filteredOrders = new SQOrderList();

 

for(int i = 0; i < originalOrders.size(); i++) {

SQOrder order = originalOrders.get(i);

 

// Umrechnung der CloseTime (Long/Timestamp) in YYYYMMDD

Calendar cal = Calendar.getInstance();

cal.setTimeInMillis(order.CloseTime);

int orderDate = (cal.get(Calendar.YEAR) * 10000)

+ ((cal.get(Calendar.MONTH) + 1) * 100)

+ cal.get(Calendar.DAY_OF_MONTH);

 

// Nur Trades hinzufügen, die am oder vor dem Stichtag liegen

if(orderDate <= stopDate) {

filteredOrders.add(order.clone());

}

}

 

// Die Originalliste wird mit der gefilterten Liste überschrieben

originalOrders.clear();

for(int j = 0; j < filteredOrders.size(); j++) {

originalOrders.add(filteredOrders.get(j).clone());

}

 

// Optional: Falls die Reihenfolge für nachfolgende MC-Methoden egal ist

// java.util.

Collections.shuffle(originalOrders);

}

}

0

Viewing 5 replies - 1 through 5 (of 5 total)