8000 Performance improvements ClrObject - Dispose PyObj by Martin-Molinero · Pull Request #22 · QuantConnect/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Performance improvements ClrObject - Dispose PyObj #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Martin-Molinero
Copy link
Member
@Martin-Molinero Martin-Molinero commented Jan 18, 2019

What does this implement/fix? Explain your changes.

  • Increasing minor version to 14
  • Adding UnsafeDispose() for PyObject which does not require
    acquiring/releasing the lock, for performance
  • Adding check before calling SetArgsAndCause for the ClrObject, the
    call only makes sense when we are an exception and causes an overhead.
    3 seconds out of 43s.

Master Samplig:
imagen

Algorithm:

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
import numpy as np

from datetime import timedelta

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2015,1,1)
        self.SetEndDate(2018,1,1)
        self.SetCash(100000)

        self.symbols = [Symbol.Create(x, SecurityType.Equity, Market.USA)
                        for x in ["SPY", "GOOG", "AAPL", "FB", "AMZN"]]

        self.AddEquity("SPY", Resolution.Minute)
        self.UniverseSettings.Resolution = Resolution.Minute
        self.AddUniverse(self.CoarseSelectionFunction)

    def OnData(self, data):
        pass

    def CoarseSelectionFunction(self, coarse):
        return self.symbols

- Increasing minor version to 14
- Adding `UnsafeDispose()` for `PyObject` which does not require
acquiring/releasing the lock
- Adding check before calling `SetArgsAndCause` for the `ClrObject`, the
call only makes sense when we are an exception and causes an overhead
@jaredbroad jaredbroad merged commit 877e510 into QuantConnect:master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0