forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Express Generator → collection filename to include net profit

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 4

1 (edited by lisaforex 2023-04-29 14:31:02)

Topic: collection filename to include net profit

Hi,

I am trying to achieve the following in Express Generator:

- generate strategies for 2 years (max 200 collection)
- run the top 200 strategies for the following month, and pick the top 10 (simulating DEMO testing)
- run the top 10 for the next month (simulating REAL trading)

I've got everything I want working well. My final json file contains the 10 strategies with simulated "real" trading.

I can see the profits for each strategy in the json file uner "profit".

I would like to see a summary of all the profits in the collection in the filename.

Example:

output = ./collections/Coll_[SERVER]_[SYMBOL]_[PERIOD]_[YEAR]-[MONTH]-[DAY]_str_[PROFIT].json

I had a quick look though collection.js

    let collectionPath = path
        .replaceAll('[SERVER]', cleanName(dataId.source) )
        .replaceAll('[SYMBOL]', cleanName(dataId.symbol) )
        .replaceAll('[PERIOD]', periodToText(dataId.period) )
        .replaceAll('[YEAR]'  , date.getUTCFullYear().toString() )
        .replaceAll('[MONTH]' , ('0' + (date.getUTCMonth() + 1).toString()).slice(-2) )
        .replaceAll('[DAY]'   , ('0' + date.getUTCDate().toString()).slice(-2) )
        .replaceAll('[HOUR]'  , date.getUTCHours().toString() )
        .replaceAll('[MINUTE]', date.getUTCMinutes().toString() )
        .replaceAll('[COUNT]' , count.toString() )
        .replaceAll('[PROFIT]', ???? )

I'm after something that will add profit to the filename, but my JS knowledge isn't that great.

I could code up something in python to extract the data from the json file, but I was hoping there would be an easier way if anyone knows?

Re: collection filename to include net profit

Hello Lisa,

> I would like to see a summary of all the profits in the collection in the filename.

This is a good idea. I'll implement it in the next Express Generator release (later this week).

EDIT

If you want to hack it yourself, you have to change two files:

1: C:\express-generator\bin\gen.js

Change line 285 with these two lines:

// Old
const collPath = makeCollectionPath(settings.output, dataEndText, dataId, collectionSize, settings.outputReplace)

// New
const profit   = collection.reduce((acc, rec) => acc + rec.stat.profit, 0)
const collPath = makeCollectionPath(settings.output, dataEndText, dataId, collectionSize, profit, settings.outputReplace)

2: C:\express-generator\bin\lib\collection.js

Change the function signature on line 149 as follows:

// Old
function makeCollectionPath(path, timeUpdated, dataId, count, outputReplace)

// New
function makeCollectionPath(path, timeUpdated, dataId, count, profit, outputReplace)

Append the [PROFIT] parameter as follows:

.replaceAll('[PROFIT]', profit.toFixed(0) )

If everything is alright, you can use it exactly as you requested it:

> node bin/gen --symbol EURUSD --period M30 --output [SYMBOL]-[PERIOD]-[COUNT]-[PROFIT]

Produces:

https://image-holder.forexsb.com/store/xgen-export-profit-in-coll-name-thumb.png

Re: collection filename to include net profit

woo! I'll wait for the official release instead of hacking away at the code. Thanks!

Re: collection filename to include net profit

Thanks! Looks like the latest release includes this update : https://forexsb.com/forum/post/74929/#p74929!

Posts: 4

Pages 1

You must login or register to post a reply

Forex Software → Express Generator → collection filename to include net profit

Similar topics in this forum