Giter Site home page Giter Site logo

Comments (5)

jaymon0703 avatar jaymon0703 commented on June 30, 2024

Hi @QuantDevHacks. So whats happening here, is reshape2::recast calls dcast() which calls cast(), both of which have fun.aggregate=NULL for the default argument value. When there is any duplicate in the data being melted and cast in one step, the cast function uses fun.aggregate <- length. If you used values of the free.params which did not overlap the function would correctly sum the statistic of interest.

My thinking at this point is to add a fun.aggregate=sum argument to our call to reshape2::recast. It works, so i will push the change shortly, and bump the version one minor increment.

image

EDIT - on second thoughts...fun.aggregate=sum might not make sense for a statistic such as "Profit.To.Max.Draw", so passing it to the tradeGraphs() function definition might be necessary...since in some cases sum() makes sense, and in others perhaps mean() or median() makes more sense...

from quantstrat.

jaymon0703 avatar jaymon0703 commented on June 30, 2024

Ok tested my change locally...this is the output...

image

Would you mind testing @QuantDevHacks?

The code to install the version with the last commit is install_github("braverock/quantstrat", ref = "1e8dbbf").

The code i ran for the call to the newly defined tradeGraphs function is below...

tradeGraphs(stats = results$tradeStats, 
            free.params = c("macd.sig","macd.fast"),
            statistics = c("Profit.To.Max.Draw"),
            fun.aggregate=mean) 

from quantstrat.

jaymon0703 avatar jaymon0703 commented on June 30, 2024

Apologies...i am too quick to type today...i think the optimal solution here is to not use recast() as we do not want any aggregating...this will require a bit more work...

from quantstrat.

jaymon0703 avatar jaymon0703 commented on June 30, 2024

In the spirit of typing too fast, i think we do need to aggregate where there are duplicate column combinations...for example there are multiple observations in which macd.fast and macd.sig are equivalent...so how would we like to present that information...presumably mean or median makes sense.

from quantstrat.

jaymon0703 avatar jaymon0703 commented on June 30, 2024

Ok @QuantDevHacks i have updated the default to use the mean as the aggregation function. This is necessary for scenarios in which the param search covers more than 2 params. I think the mean makes sense. Appreciate your thoughts, and testing the latest commit? You can use install_github("braverock/quantstrat", ref = "f73c3c7").

Using your original example, please note you can benefit from parallel computation for the param search if you add the below 2 lines:

library(doParallel)
registerDoParallel()

And because we set the default to mean there is no need to specify it in the call to tradeGraphs():

tradeGraphs(stats = results$tradeStats, 
            free.params = c("macd.sig","macd.fast"),
            statistics = c("Profit.To.Max.Draw"))

Appreciate your feedback.

EDIT: With your permission i may add your example as a demo...

from quantstrat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.