Commit Graph

232 Commits

Author SHA1 Message Date
Michael Handschuh eeae2e291e BUG #3021: Validate email addresses in NotificationEmail
* Adds Validate class in util with accompanying regular expressions
* Provides tests for NotificationEmail and Validate.EmailAddress
* Provides default values for NotificationEmail Subject and Message
  These default values resolve the underlying issue of #3021 w/out
  needing to modify external sources (such as impl of IMessagingHandler)
2019-07-08 02:52:04 -04:00
Gerardo Salazar 3c04d922c2 Address reviews 2019-06-17 16:45:53 -07:00
Martin Molinero b9c0fb6fbf Fix plugin-directory config override 2019-06-12 19:23:45 -03:00
Jared 2f46e708a1 Merge pull request #3184 from Martin-Molinero/refactor-3183-remove-backtestingtransactionhandler-thread
Removing BacktestingTransactionHandler thread
2019-05-17 07:22:24 -07:00
Martin Molinero 7f12cbb901 Addressing reviews 2019-05-15 18:56:08 -03:00
Martin Molinero f976ffa099 Removing BacktestingTransactionHandler thread
- For backtesting the algorithm thread will sequentially process pending
order requests
   - Adding new non blocking `BusyCollection`
- Updating `UpdateOrderRegressionAlgorithm` that suffered of a race
condition: it supposed `OnOrderEvent` would be called after the call to
`Transactions.AddOrder()` was finished
2019-05-10 16:15:24 -03:00
Martin Molinero 7d507ca310 Review: Adding WorkerThread.Join and try catch 2019-05-09 13:40:57 -03:00
Martin Molinero 4382aa1886 Add algorithm thread
- Adding `WorkerThread` class, wrapper for a worker thread that will
execute given `Actions`.
    - Algorithm related code (`Construction`, `Initialization`,
    `Execution` will be executed by the same `WorkerThread` instance,
    this is required for `Python` debugging.
2019-05-09 11:23:28 -03:00
Martin Molinero 3d52343799 Optimize stored result json
- `Alpha Assets` chart will only store last data point
- Adding new `JsonRoundingConverter` that will round to 4 (number of
digits currently used for comparing alpha statistics) fractional
digits.
   - Will be used for `Insights` and `ChartPoint`
2019-04-29 19:17:00 -03:00
Stefano Raggi f7e06510d4 Fix missing front month contract in energy futures backtesting
Energy futures (CL, HO, RB, NG) expire in the month before the contract month.

To handle these properly, the following changes have been implemented:
- the AlgoSeekFuturesReader has been updated to create the future symbol with the correct expiry date
- the zip entry names in futures data files now contain the full expiry date (in addition to the contract month)
- the sample data files have been updated to use the new zip entry names
- new unit tests have been added and existing ones updated
2019-04-29 09:40:59 +02:00
Martin Molinero c39638668c Overall performance improvements
- `FactorFile` will keep an ordered reversed list with the dates.
Calling `Reverse()` on the `SortedList` is expensive.
- `MapFiles` will keep first and last date, so we don't need to call
`First()` and `Last()` multiple times.
- `Liquidate` will go through all the algorithms securities only if
necessary
- `TradeBar` parsing will not call `new T` for pure `TradeBar` which is
expensive
- Removing `Lazy` hash code and security type for the
`SecurityIdentifier`, replacing for direct initialization. Accessing the
`Lazy` value adds an overhead.
- Replacing `Enum` to string for hardcoded switch statement. `Enum.ToString` is expensive.
- `DataManager` will be lazy for counting the subscriptions for
determining if its above the limit
- Adding `AlgorithmSecurityValuesProvider.GetAllValues()`, removes the
need to fetch all the security keys twice.
- During universe selection, will not try to re add already added symbol
2019-04-22 10:47:27 -03:00
Martin Molinero e60eb28a3c Load assemblies from Plugin Directory 2019-04-15 11:12:37 -03:00
Martin Molinero 9865fe63e0 Improve initialization speed
- `Composer` will load `QuantConnect` assemblies and keep the `Types`
which is much faster than using previous wway of getting types that uses
reflexion.
- Adding static `MapFileProvider` improving calls to
`QuantConnect.commo.Symbol.Create` or `Addxxx` which created a new
instance every time
- `Engine.StackExceptionInterpreter` will be lazy initialized, since it
takes some time because it goes through all assemblies
- Moving `MarketHoursDataBase` initialization earlier and in a `Task`
since it takes some time.
2019-04-12 21:27:56 -03:00
Martin Molinero fa122fa809 Add missing PyObject.Dispose calls
- Adding _some_ of the missing PyObject.Dispose calls. In the cases
where C# is calling the Python side.
   - Note that Python calls to C# code is correctly handling the
   disposure of resources.
2019-04-10 15:03:10 -03:00
Martin Molinero ce3f7ecd41 Replace FileSystem workers Thread for Tasks
- Deleting `ParallelRunnerController` and `ParallelRunnerWorker`.
Replacing them for `Tasks`. The consumer, `EnqueueableEnumerator` will
directly spin up a new producer Task when he is running low on items.
2019-03-04 15:12:46 -03:00
AlexCatarino ef59fa7ba2 Updates pythonnet package.
In the new package:
- C# decimal conversion will use C# double and python float due to the big performance impact of converting C# decimal to python decimal;
2019-01-18 23:18:35 +00:00
Jared d367dbd025 Revert; unit test coverage.
Annoying spin off affects. Won't update now but flag for later standardization.
2019-01-14 19:44:49 -08:00
Jared 5e8d43df1a Sanity check for consistency with new method
Missing toLower
2019-01-14 16:03:27 -08:00
Gerardo Salazar c9d5764a4b Fix issue #2826 in which we were unable to write to write Futures or Options data to disk 2019-01-14 11:24:26 -08:00
Martin Molinero 103bf638b5 Adding Pandas MultiIndex cache
- Adding a cache for the `Pandas.MultiIndex`, giving a significant
performance improvement.
- Adding new `ListComparer` class. Adding unit tests.
2019-01-11 14:00:32 -03:00
Martin Molinero e4fc00efbf Composer will scan directory once
- `Composer` will scan the specified directory for binaries only once.
This gives a performance improvement:
- Regression tests execution times:
    - `master`: 11:11
    - `PR`: 9:56, 9:46
- Reverting the assert logic of a unit test

> We now have regression tests < 1 second as low as 0.5s!
2018-12-14 12:52:45 -03:00
Stefano Raggi 57d50c69c4 Fix XML documentation compiler warnings
- Fixed all warnings except for missing XML comments (CS1591)
2018-11-09 11:44:03 +01:00
Martin Molinero 8518739435 Adding checks to avoid exceptions
- Fixing exception at ParallelRunnerController due to trying to double
dispose of workers and setting already disposed `_waitHandler`
- Fixing exception at ParallelRunnerWorker, disposing of handle after
thread. Will now try joining thread before aborting if cancellation was
requested.
2018-10-18 14:00:05 -03:00
Martin Molinero 027df936b9 Adressing review - Use DisposeSafetly
Use DisposeSafetly instead of Dispose.
Adding new check for WaitHandle to verify its not already closed, before
setting and disposing.
2018-10-01 15:09:58 -03:00
Martin Molinero 8d2eb36627 Dispose queues after consumers
Removing sleep and disposing queues after consumers,
I believe this should also solve original issue while saving time.

Will first Join with 1 second timeout and Abort if it failed.
Adding try catch for robustness.
2018-09-28 20:16:54 -03:00
Martin Molinero 767ee77fb1 Fix exception being thrown when deserializing backtest result and fix Color serialization 2018-09-09 19:55:23 -03:00
Michael Handschuh 1c07805be3 Fixes potential memory leak in StreamReaderEnumerable
This implements a finalizer to perform disposal.
Also adds ability to mark other objects for disposal when this instance
is disposed. This is useful for disposing, for example, a ZipFile that
was used to create the StreamReader instance.
2018-08-23 12:55:25 -04:00
Martin Molinero 5f3fc59c72 Fix insight sum pie chart 2018-08-22 10:44:41 -03:00
Michael Handschuh a6640c0886 Adds API support for /splits and /dividends endpoints 2018-08-15 13:45:12 -04:00
Michael Handschuh 57affafdc2 Implement 'live' factor files
Adds reference price to dividend/split
Adds GetSplitsAndDividends to FactorFile
Adds Apply methods to FactorFile/FactorFileRow
Updates factor files to include reference prices
2018-08-14 17:58:44 -04:00
Martin Molinero b253668b1d Adding new API endpoint prices 2018-08-04 10:57:41 -03:00
Art Wild d5996fb7c8 MV & BL portfolio optimization implementation
Closes #1998. Closes #2219.
2018-07-24 16:53:11 +01:00
Michael Handschuh 00d473b74b Add util method for lifting IEnumerator<T> to IEnumerable<T> 2018-07-19 13:49:15 -04:00
Michael Handschuh 43a7d0c3e8 Rename HasDiffs to AreDifferent
No need to be so terse :)
2018-05-30 15:55:34 -04:00
Michael Handschuh f7db6d2442 Add LinqExtensions.HasDiffs method
Implementation is simplified form of that used to detect diffs
in universe selection (selection updated to use simplified form
as well)
2018-05-30 15:54:06 -04:00
Michael Handschuh 533bbaff5f Add ToList extension that accepts a selector
Convenience method for performing a select and then to list.
2018-05-07 15:52:29 -04:00
Juan José D'Ambrosio 4ace8cb255 Lean Visualizer C# toolbox project and Python Wrapper working 2018-04-27 11:49:52 -03:00
AlexCatarino cdb98b5de3 Configurable Composer dll look-up directory
When creating a collection of directories from where dynamic-link library can be loaded from, a user-defined path is used if the reserved key `composer-dll-directory` exists. Otherwise, the current executing directory is used.
This feature is necessary for applications, e.g.: Jupyter kernels, that use Lean/QuantConnect assemblies, since they may be called from a directory with dlls that don't need to be loaded by the `Composer`.
2018-04-23 17:51:19 +01:00
AlexCatarino bfe8a272ed Fixes PythonExceptionStackParser
`PythonExceptionStackParser` was wrongly replacing all `in` string for `at` where it should only replace the first occurence.
2018-04-13 11:29:38 +01:00
AlexCatarino 7bab95fa0b Adds methods to create universe selection Func from python methods 2018-04-06 19:41:34 +01:00
AlexCatarino 0bbb5def47 Fixes PythonUtil.PythonExceptionStackParser 2018-03-14 14:37:27 +00:00
Michael Handschuh 922eca06dc Add support or reference result types in TypeChangeJsonConverter
Existing implementation was written under the assumption that the result type
was a value type and was being read using JToken.Value<TResul>() which cases
exceptions if TResult is a non-string class type. The fix was to check the type
and use JToken.ToObject<TResult>() when the result type is not a value type.
2018-03-10 15:58:01 -05:00
Michael Handschuh 6b239674e2 Renames Alpha -> Insight
The term 'alpha' is used to describe the entire algorithm. Therefore, 'alpha'
produces insights. From this we have things like IAlphaModel, which is the model
defining how insights are produced. We have IAlphaHandler, which defines how the
insights from a single 'alpha' (the algorithm) are managed, analyzed, and stored.
Types closer to the individual prediction level, such as InsightDirection, or
InsightScore relate directly to exactly 1 insight. The distinction between the
two became more clear as we developed the insights API, and from that effort it
was decided to harmonize alpha/insight terminology across the various QC systems.
2018-03-09 16:12:56 -05:00
AlexCatarino 682b312c0f Moves GetStringBetweenChars to Extensions from PythonUtil
Since this method is not exclusive of python algorithms, it is being moved to Extension methods.
2018-03-07 23:24:35 +00:00
AlexCatarino b672580693 Implements KeyErrorPythonExceptionInterpreter 2018-03-06 11:05:39 +00:00
AlexCatarino 718c1d61c8 Implements DllNotFoundPythonExceptionInterpreter
This exception interpreter interprets a DllNotFoundException that is thrown when pythonnet cannot fing the python dynamic-link library in the system.
2018-03-05 22:55:11 +00:00
AlexCatarino 165f7a6f41 Throws argument exception to multiple attemps to add a type to ObjectActivator 2018-03-01 20:07:32 +00:00
AlexCatarino 0f57c2fd43 Fixes Custom Data for Python
In order to access the custom data classes, the module containing them was added to the ObjectActivator. This was unnecessary if it wasn't a custom data algorithm.
Also, this operation would not be taken into account if the custom data class were defined after the algorithm was created: this is the case for QuantBook.
We refactor how custom data is handled: a new class was added to provide a instance creation factory that creates an instance of each python custom type.
2018-03-01 19:28:30 +00:00
Stefano Raggi 8f115795c5 Fix FineFundamental universe selection resource leak
The FineFundamentalSubscriptionEnumeratorFactory used in combination with SingleEntryDataCacheProvider and DefaultDataProvider was never disposing of the underlying file stream, leaving files open.
2018-02-08 16:04:04 +01:00
AlexCatarino 6bbdbcb8fe Fixes LeanData.cs hard-coded Market.USA
It prevents support for new markets.
2018-01-19 18:09:52 +00:00