QuantConnect / pythonnet

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
http://pythonnet.github.io
MIT License
28 stars 27 forks source link

Performance improvements ClrObject - Dispose PyObj #22

Closed Martin-Molinero closed 5 years ago

Martin-Molinero commented 5 years ago

What does this implement/fix? Explain your changes.

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