Compare commits

...

107 Commits

Author SHA1 Message Date
Colton Sellers
a2850fb20c Address Non-Compiled Files (#5225)
* Include MortgageRateVolatilityAlpha and fixes

* Include PlaceHolder PythonAlgorithm.cs

* Delete BinanceUtil

* Remove unused Regression Algorithms

* Minor tweaks

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-27 09:56:03 -03:00
Colton Sellers
c86fceac97 Fix regression typo (#5224) 2021-01-26 15:31:57 -03:00
Stefano Raggi
9997df45af IB Brokerage updates (#5222)
* Upgrade IBAutomater to v1.0.40

* Fix FinancialAdvisor account id check

- The Ixxxxxx account code is the Master Account for Fully Disclosed Brokers and this account is not tradable. Proprietary accounts for Brokers/Dealers used for proprietary trading have the Uxxxxxx account code.

* Update IBAutomater to v1.0.42

* Update IBAutomater to v1.0.43

* Log server version in ConnectAck handler
2021-01-26 09:52:05 -08:00
Jared
1ef92b3eca Update Crisis.cs 2021-01-25 10:47:15 -08:00
Adalyat Nazirov
c6d29c8be5 add FIX Protocol UTC timestamp format (#5212) 2021-01-25 11:24:54 -03:00
Derek Melchin
97deb4bbc6 Fix typo (#5216) 2021-01-25 10:24:15 -03:00
Gerardo Salazar
6ab40c102b Only report daily point-in-time portfolios instead of every trade (#5214)
* Only report daily point-in-time portfolios instead of every trade

* Allow for cash holdings to be visible in point-in-time portfolio output
2021-01-22 17:00:09 -08:00
Gerardo Salazar
41417593aa Writes point-in-time portfolios to disk (#5213)
* Writes point-in-time portfolios to disk

* Adds optional argument to Report constructor in ReportGenerator
2021-01-22 15:17:19 -08:00
Martin-Molinero
3ccf428498 Adjust delisting liquidation time (#5203)
* Adjust delisting liquidation time

- Adjust delisting liquidation time to 15 min before market closes.
  Adding unit tests. Updating existing.
- Handle `Statistics.CompoundingAnnualPerformance` invalid calculation
  to avoid exception.
- AlgorithmManager will not handle delisting events in live trading
- Fix bug where due to a split driven liquidation matching delisting
  date a position in the option would remain open. Reproduced by
  `BasicTemplateOptionsFrameworkAlgorithm`

* Address review

- Address review add documentation on delisting offset span
2021-01-22 14:41:29 -03:00
Colton Sellers
5d8a62c2e1 Symbol Alias Fix (#5205)
* Fix Symbol Alias

- Fix Symbol Alias being wrong in some cases for futures and options

* Add test cases

* Address review

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-22 13:00:14 -03:00
Martin-Molinero
5df29f16dd Fix thread safety of Mapfile exchange provider (#5208) 2021-01-21 19:02:50 -08:00
Martin-Molinero
56a0d52212 Allow limiting streaming security Types per job packet (#5206) 2021-01-21 21:23:32 -03:00
Juan José D'Ambrosio
765f2cab3b Add primary exchage to map files (#5194)
* Add main exchange to map file

minimum minimorum test

* Add MainExchange to MapFilRow IEquatable implementation
Also write CSV line correctly

* Normalize exchanges

Also add small test form MapFileRow

* Exchange name normalization

- Exchange name normalization.
- Tick will protobuf `ExchangeCode` which will set existing `Exchange`

* Include single character exchange code

* Encode exchange as byte, Include exchange name as Enum

* Update MapFileRow.cs to accept a byte instead a string for primary exchange

* Fix issues in encoding exchanges map

* Fix broken MapFile tests

* Rename Main Exchange property in MapFileRow

* Use BATS instead of BATSZ

* Add primary exchange from map file

* Move MapFilePrimaryExchangeProvider to its own file

* Implement Char for primary exchange in map files

* Fix broken tests after implementing char exchange into map file

* Add a new constructor for MapFileRow

it  accepts a PrimaryExxchange object as parameter

* Fix broken test 

WIP

* Address review 

WIP

* Handles unexpected encoded exchanges

* Keep addressing review

* Address review

* Fix broken tests

Make PrimaryExchange as default even if the IPrimaryExchangeProvider is not instantiated

* Revert breaking change.

* Add a check that resolved map file actually have content

The issue that leads to this change was caused by a map file resolved to APC in the CoarseFundamentalTop3Algorithm. 
The resolver returns a not-null MapFile, but it is empty.
To my best understand, the MapFile Resolver should return only existing map files in the map_files folder. But the LocalMapFileProvider returned a map file with a permtick that doesn't exist in the file system as CSV.

* Set PrimaryExchange.UNKNOWN as default

* Address review couple minor bugs

- Use SID market instead of USA
- Default ticke exchange is UNKNOWN

* Update map files with latest format and latest info

This include:
 - VXX, it was delisted, then VXXB appears and later it chnages from VXXB -> VXX
 - AAA delisting and a new listing with ticker AAA
 - FOXA ticker changue to TFCFA and later it was delisted

* Update test after updating latest map files

* Fix bug with factor files after updating map files

* Fix bug with factor files after updating map files

and revert statistics in regression tests

* Update OrderHash in regression test

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-21 18:46:12 -03:00
Martin-Molinero
f175ac6c6b Fix universe selection symbol cache removal (#5193)
- Only remove symbol from cache during universe selection if there is no
  other universe using it. Adding regression test reproducing issue
2021-01-21 15:48:33 -03:00
Gerardo Salazar
79c544d3a2 Reduces output log size and warnings emitted when building with mono's msbuild (#5200) 2021-01-21 11:09:16 -03:00
Aaron Janeiro Stone
5dcbed535d 5052 - Adds missing constructor routing (#5201)
* Adds missing constructor routing

* Minor tweak remove unrequired lines and format

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-21 10:49:27 -03:00
Gerardo Salazar
35393b66a3 Updates report generator template.crisis.html (#5202) 2021-01-20 18:01:44 -08:00
Karthik Kailash
ce42c888ce Add 2001-12-24 to US equities early closes in market-hours-database.json (#5184) 2021-01-19 13:21:00 -08:00
Colton Sellers
f2fd10d9d2 Build Configuration Hotfix (#5186)
* Reflect properties prior to migration onto projects

* Do not prefer 32bit

* Reinstate SelectedOptimization var
2021-01-19 09:38:16 -03:00
Colton Sellers
94d766ff89 Refactor Default Benchmark (#5158)
* Have BrokerageModel determine default benchmark

* Add DefaultBenchmark to Python wrapper

* Handle Null benchmark case

* Add NullBenchmarkRegressionAlgorithm

* Refactor solution to have BrokerageModel return IBenchmark; also refactor QCAlgorithm benchmark handling

* Always create a new security for benchmark

* Drop security overload, Always create a new security for benchmark

* Check our securities for a symbol matching the ticker before creating a new one

* No Python version of this regression

* Address review

* Create shared SecurityBenchmark creator function

* Add Python regression and needed FuncBenchmark constructor
2021-01-19 08:40:41 -03:00
Martin-Molinero
592d037085 Fix delisted liquidation orders being cancelled (#5169)
* Fix delisted liquidation orders being cancelled

- Place delisted liquidation orders 10 min before market closes of 10
  min before the end of the delisting warning date. Adding regression
  test and unit tests. Updating existing tests.

* Fix failing python option unit tests

* Fix bug where positions would be open delisting liquidation

* Fix universe selection and delisting

- Delisting will happen ASAP for all types. Giving priority to close
  positions on derivates first
- Fix bug in universe selection where OptionChain would remove
  underlying even if holding a position in derivate.
- Updating regression tests statistics

* Add unit test, fix unit test expected stats
2021-01-18 22:02:40 -03:00
Gerardo Salazar
17ab10531a Fixes ETB/shortable regression algorithms that were previously failing (#5174)
* Fixes ETB/shortable regression algorithms that were previously failing

* Addresses review and fixes bug

  * Fixes bug where orders would be denied regardless of direction
    whenever they exceeded the absolute value of the shortable quantity

  * Updates regression algorithm + statistics + simplifies test

  * Fixes python regression algorithm

* Addresses review: removes comments and unneeded imports
2021-01-18 21:19:42 -03:00
Juan José D'Ambrosio
9d576a4121 Update regression tests statistics (#5187)
Those statistic were affected for the new early market close entries in MHBD.
2021-01-18 21:06:26 -03:00
Aaron Janeiro Stone
7aefe07274 4553 - Refactor RenkoConsolidator (#5052)
* Separated Update calls and other non-common RenkoConsolidator.cs artifacts.

* Added type safe init for wicked

* Refactor; moved wicked-specific fields to WickedRenkoConsolidator.cs

* Addresses requested changes (and compacts constructors)

* Separated Update calls and other non-common RenkoConsolidator.cs artifacts.

* Added type safe init for wicked

* Refactor; moved wicked-specific fields to WickedRenkoConsolidator.cs

* Addresses requested changes (and compacts constructors)

* Removes base class for brevity

* Delete BaseRenkoConsolidator.cs

* Fixes naming for classic Renko consolidator

* Addresses review concerns

* Fixes missing null checks and missing typesafe constructor

* Adds warning

* WickedRenkoConsolidator -> RenkoConsolidator calls

* Separated Update calls and other non-common RenkoConsolidator.cs artifacts.

* Added type safe init for wicked

* Refactor; moved wicked-specific fields to WickedRenkoConsolidator.cs

* Addresses requested changes (and compacts constructors)

* Removes base class for brevity

* Fixes naming for classic Renko consolidator

* Separated Update calls and other non-common RenkoConsolidator.cs artifacts.

* Added type safe init for wicked

* Refactor; moved wicked-specific fields to WickedRenkoConsolidator.cs

* Addresses requested changes (and compacts constructors)

* Delete BaseRenkoConsolidator.cs

* Addresses review concerns

* Fixes missing null checks and missing typesafe constructor

* Adds warning

* WickedRenkoConsolidator -> RenkoConsolidator calls

* Addresses review

* unneeded tag removed

* Minor tweaks address reviews

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-18 15:54:15 -03:00
Karthik Kailash
6de9a146a9 Issue 5149: Added missing early closes for 1999-2008 (#5163)
* Added missing early closes for 1999-2008

See GitHub issue for details

* Fix expected Treynor ratio for backtest in test suite

This backtest runs from 2008-10-10 to 2010-10-10 so it is affected by the early close date now recorded on 2008-12-24.
2021-01-15 11:22:44 -03:00
Gerardo Salazar
4d4ad92fa7 Easy To Borrow Hotfix (#5167) 2021-01-14 15:07:54 -08:00
Jared
345fe7357e Update readme.md 2021-01-14 13:58:26 -08:00
Gerardo Salazar
3e7af17e02 Implements Easy To Borrow Reality Modeling (WIP) (#5159)
* Creates IShortableProvider interface + interface impls

  * This is the foundational work for the addition of the shortable stocks
    feature for backtesting and live trading. Note that the QCAlgorithm
    API and the backend transaction handling will be implemented
    separately.

* temp; work on preorder checks

* improve checks

* tmep

* Enforces ETB checks at BrokerageTransactionHandler

  * Adds ETB Shortable Provider to QCAlgorithm and IAlgorithm
  * Removes ETB check from PreOrderChecksImpl
  * Removes outdated test, new test to come soon for relevant class

* Work in progress commit, pushing for review.

  * Adds new regression algorithm (WIP)
  * Enhances ShortableProviderOrdersRejectedRegressionAlgorithm
  * Adds new methods to QCAlgorithm
  * Move IShortableProvider to have BrokerageModel own it
  * Comments updates
  * Adds new properties to Equity Security for shortable

  * Fixes bug where retrieving open order quantities would aggregate the
    submitted order quantity rather than the remaining order quantity for
    open orders.

  * Fixes bug where quantity of zero would result in a
    false positive in QCAlgorithm.Shortable(...)

  * Code refactoring and comments updates

Co-authored-by: Jared <jaredbroad@gmail.com>
2021-01-14 13:33:44 -08:00
Colton Sellers
a2a874e333 CSProj Update (#5145)
* Migrate to newer CSProj format; build succesful

Rebase onto master

* Maintain binaries directory

* Reinstate FSharp default condition

* Remove reference to packages.config

* Test project fixes

* Remove nuget.config and "Solution Items"

* Remove repetitive assembly info

* Reinstate default compiles and cleanup redundant settings

* Reinstate any specific settings that defaults are unclear for

* Reinstate Framework.nuspec

* Make test internal classes public for composer use; undo assembly change

Rebase onto master part 2

* Address review; restore some settings

* Restore RootNamespace and AssemblyName attributes

* Use NugetPackageRoot instead of NugetPackageFolders

* Reinstate "RestorePackages" setting

* Transfer compilied Python files to launcher and tests bin

* Remove conflicting settings

* Fix WebSocketSharpFork references

* Fix FSharp Core reference

* Upgrade TestPlatform.ObjectModel to 16.8.3, and redirect V11 binding

* Add Mono.Cecil package

* Address review
2021-01-14 12:55:09 -08:00
Juan José D'Ambrosio
96592b3387 Update RTY price multiplier (#5166) 2021-01-14 16:45:24 -03:00
Colton Sellers
7e3741d983 Allow Custom Security Properties and MarketHours (#5100)
* Add interface to allow custom security entries for MHDB and SPD

* Simplify adding custom Properties and MarketHours via AddData overload

* Refactor

* Remove AddData and GetDatabaseSymbolKey overloads

* Add unit tests

* Remove AddData overload, for real.

* Nit changes

* Set CustomDataBitcoinAlgorithm back to original

* Add Python and C# Regression

* nit typo

* nit typo actual

* Reset symbol property to default

* Reflect last change to py regression

* Revert "Remove AddData overload, for real."

This reverts commit dc877495c0.

* Implement AddData solution fully

* Function nit fix

* Address review

* nit - remove param comment

* Address review
2021-01-14 11:34:02 -03:00
Martin-Molinero
e6d16882f7 Remove raw Sleeps for Sleeps+Event (#5153)
- Remove raw Thread.Sleep for Event driven wait/sleeps. Improves startup
  performance significantly
2021-01-12 19:12:07 -03:00
Gerardo Salazar
d5aa9e65f3 Adds FuturesOptionsUnderlyingMapper and FuturesListing (#5142)
* Adds FuturesOptionsUnderlyingMapper

  This adds a mapper for Futures options that have a different
  contract month between the FOP and the underlying future, as is
  observed in the contracts ZB, ZC, ZS, ZT, ZW, HG, SI, GC.
  An example of this is GC (e.g. OGH21 -> GCJ21). Other contracts follow
  different rules, which have been included as part of this commit.

  * Adds unit tests for FuturesOptionsUnderlyingMapper

  * Adds unit and regresssion tests for underlying Futures mapping for FOPs

* Addresses review and adds FuturesListings

  * Removes dependency on IFuturesChainProvider in
    FuturesOptionsUnderlyingMapper

  * Fixes bugs related to FuturesOptionsUnderlyingMapper and incorrect
    results

  * Modifies misc. code to handle new results correctly from FOPs
    underlying mapper

  * Makes FOPs underlying mapper static, and makes other methods private

  * Adds new tests for FuturesListings

* Addresses review: code cleanup

* Address review: Makes arrays to List in FuturesListing private methods
2021-01-12 06:12:00 -08:00
Mathieu Paquette
ec1c4b7142 update IQFeed.CSharpApiClient (#5148)
* update IQFeed.CSharpApiClient

fixes #5147

* Update IQFeed client csproj referece

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-11 18:11:16 -03:00
Adalyat Nazirov
9a0d943f1d Fill forward data points until delisted date (#4973)
* fill forward data points until expiry date

* wip: test non Delisting

* handle Aux not-Delisting dp; keep order while ff'ing

* simplify test checks

* wip

* fix liquidation expected date

* change statistics

* check EndTime, because it's used for time synchronization

* clean up code; remove duplicated test
2021-01-11 16:45:09 -03:00
Ari Cooperman
771244aaa0 Add order related mappings to resolve type & status IDs in pure python (#5075)
* Add order related mappings to resolve tye & status IDs in pure python

* Update order.py

Co-authored-by: Martin-Molinero <martin@quantconnect.com>
2021-01-11 15:45:51 -03:00
Alexandre Catarino
659a57884c Improves Error Message for Api.Download (#5038)
* Improves Error Message for Api.Download

Catches the exceptios, logs it and returns null.

* Replace Logging for Re-Throwing the Exception
2021-01-11 15:40:46 -03:00
Martin-Molinero
3f2a558f91 Remove pythonNet from stacktrace (#5146)
* Avoid pythonNet  stackTrace in algorithm status

* Handle algorithm initialization exception
2021-01-11 10:28:32 -03:00
Martin-Molinero
9bb7c77fb7 Fix UniverseSelectionAddAndRemove race condition (#5144)
* Fix UniverseSelectionAddAndRemove race condition

- Fix unit test UniverseSelectionAddAndRemove thread race condition

* Avoid boolean flag thread race condition

* Exclude test from travis build
2021-01-08 19:18:58 -03:00
Derek Melchin
c8eb9e0099 Fix MACD WarmUpPeriod and Updating (#5110)
* Fix MACD WarmUpPeriod and Updating

* Add System to use Math library

* Fix WarmUpPeriod math and add tests

* Fix SchaffTrendCycle Indicator WarmUpPeriod

* Ensure fastPeriod < slowPeriod

* Minor tweaks

- Remove unrequired Math.Max operation
- Remove unrequired changes in solution file

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-08 16:58:53 -03:00
Jovad Uribe
b85a32a391 Bug #5030 Generation of CFD data not working (#5112)
* Update RandomDataGeneratorProgram.cs

Replaced AddMonths(6) with a Datetime value half way between settings.Start and settings.End.

* Update RandomDataGeneratorProgram.cs

* Update to bug-5030-CFDdatanotoworking

* Added midpoint unit test

* Minor test assert improvement

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-08 11:38:36 -03:00
Martin-Molinero
31d101253c LeanDataReader future/option data (#5117)
* LeanDataReader future option data

- The LeanDataReader will be able to read an entire zip of future and
  option data, currently it's just returning the first entry in the zip
  file. Adding unit tests

* Fix added unit test data path
2021-01-08 11:13:05 -03:00
Aaron Janeiro Stone
7531046f14 Feature 4999 -- Adds RVI (#5041)
* adds RVI

* RVI refactor and tests
TODO: fix ComparesWithExternalDataRviSignal

* Fixed to allow all tests to pass.

* Addresses requested changes

* Addresses requested changes

* Addresses reviewer recommendations
2021-01-08 11:11:00 -03:00
Martin-Molinero
6b99266669 Update IBAutomator increased init timeout (#5139)
- Updating IBAutomator to 1.0.40 which has an increased initialization
  timeout
2021-01-07 19:13:07 -03:00
Adalyat Nazirov
8d48996948 fix covesion to string: decimal are represented using comma decimal separator for non-US English cultures, but expected dot (#5138) 2021-01-07 17:35:51 -03:00
Martin-Molinero
7f381cb135 Universe dispose and removal (#5134)
* Universe dispose and removal

- Fix bug where in some cases the disposed universe would not get removed
from UniverseManager not allowing new universes to get added correctly,
using the same symbol. Adding regression test
- Fix bug where in some cases selected symbols would not get removed
  when the parent universe would get disposed of.
- Minor normalization on UniverseSelection call

* Address review

- Add status plots for the added regression test

* Adding regression algorithm reproducing issue 3914
2021-01-07 12:03:17 -03:00
Riley Shea
2b7372783a Fix column headings in Data/equity/readme.md (#5125)
* Swapped incorrect column heading postions
2021-01-07 11:01:51 -03:00
Adalyat Nazirov
54fce3f666 FillForward enumerator does not loop infinitely if fillforward resolution is different from data resolution (#5118)
* change filename template. add fillforward resolution suffix

* replicate GH issue 5116 on master

it's easy to reproduce on FXCM market by using data resolution different from fillforward resolution.
in this cases daily vs hour/minute were added

* change priorities of Time & EndTime values.

it's necessary to calculate EndTime  properly, and then we can align Time to it.
potential end time should be also calculated using ptoper TZ. Because of we store open hours without TZ movement TZ in market-hours it's necessary to reapply TZ

fix tests

* Miss 2AM bar on Sunday of DST; FF 2AM bar on Sunday ST

* use UTC TimeZone as baseline during comparison
2021-01-06 20:18:08 -03:00
Colton Sellers
12db2261dc Allow Saving of Octet Stream in API (#5130)
* Allow downloading of octet stream

* Refactor solution

* Match lowercase ContentType
2021-01-06 19:46:09 -03:00
Alexandre Catarino
c6d4888e70 Refactors Market Fill of Equity Fill Model (#5114)
* Refactors Market Fill Model

Create `GetBidPrice` and `GetAskPrice` methods to request the most suitable price to fill market orders.

Fix unit tests to show that new implementation prevents using non-market data to fill the order.

* Addresses Peer Review …

Modifies EquityTickQuoteAdjustedModeRegressionAlgorithm to reflect changes in the market fill method. The previous implementation only looks for the last tick when it should look for the last tick of quote type, so current implementation is an improvement.
2021-01-06 12:35:33 -03:00
Martin-Molinero
33b58b0dbc Fixes for IB malformed symbols (#5127)
* Fixes for IB malformed symbols

- Add handling for IB future malformed symbols. Adding unit test
- Fix IB option malformed symbols which had more whitespaces than
  expected. Adding unit test

* Address review
2021-01-06 11:59:22 -03:00
Martin-Molinero
56cb9fbec5 IB will wait for connection response (#5124)
- IB.Connect() will wait for connection response before starting reader
2021-01-05 19:44:04 -03:00
Jared
194e6f6b58 Update benchmark algorithm to include disabling (#5115)
* Update benchmark algorithm to include disabling

* Update C# benchmark example algo

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2021-01-04 18:11:18 -03:00
Martin-Molinero
612c4f8b66 Fix BTC future price multiplier (#5113) 2021-01-04 15:44:38 -03:00
Martin-Molinero
d3b9f8bc7a Protobuf OpenInterest (#5107)
- Add OpenInterest protobuf support. Adding unit test
- Use composer for future and option chain provider
2021-01-04 10:40:35 -03:00
Gerardo Salazar
c4a1c245a7 Adds data parsing for malformed option contracts for InteractiveBrokers (#5101)
* Adds data parsing for malformed option contracts in IBBrokerage

  * Some contracts come in malformed from IB when downloading our
    account holdings. We attempt to detect whenever this happens with
    our options Symbols and try to recover the contract.

* Addresses review and fixes bug

  * Uses contract currency for the new contract created from the
    malformed contract.

  * Bug fix: Sets ibSymbol to new Symbol of the contract once the
    malformed contract has been parsed.

  * Adds support for Futures and FOPs

  * Refactoring code and cleanup

* Addresses review: code cleanup and refactoring

* Addresses review: remove redundant logging of contract in log statement
2020-12-30 16:28:33 -08:00
Martin-Molinero
050dadc21f Increase low resolution cache size (#5105)
- Increasing low resolution cache size so it can hold QC500
2020-12-30 20:59:36 -03:00
Colton Sellers
7b0ea0982e Update ExpectedStatistics (#5094) 2020-12-29 12:04:36 -03:00
Adalyat Nazirov
f8cf923d7b upload SHY quote bars (#5097) 2020-12-29 11:58:13 -03:00
Colton Sellers
14b44bbe17 Reduce Travis Logs v2 (#5049)
* Silence DotNet in building stubs

* Reapply silence to stub publishing

* Have QuantBook store and restore initial LogHandler

* Add assembly action to maintain LogHandler

* Allow AlgorithmRunner to use ConsoleLogHandler

* Use MaintainLogHandlerAttribute to provide current test logger

* Refactor LogHandler creation
2020-12-28 21:10:21 -03:00
Colton Sellers
2ed221b623 Linux PyCharm Docker Debugger Fix (#5092)
* Map host.docker.internal to host ip

* Typo fix

* Only add host in Linux environment
2020-12-28 21:08:34 -03:00
Gerardo Salazar
3f1c33e1c5 Fixes DockerfileLeanFoundation build and adds/updates new packages (#5036)
* Fixes DockerfileLeanFoundation build

  * Updates DockerfileLeanFoundation packages and adds new packages
  * apt-get performance improvements

* Moves packages to CDN and install packages from CDN

  * Updates all CDN downloads to HTTPS

* Removes interactive `rm` command arg in DockerfileLeanFoundation cleanup
2020-12-28 18:22:15 -03:00
Adalyat Nazirov
017b464e21 Map legacy symbols using map file (#5017)
* map IB brokerage symbol

* map Alpaca symbols

* improve empty symbol checking
2020-12-28 17:54:00 -03:00
Gerardo Salazar
4dec21ccc0 Fixes failing option chain provider test for futures options (#5088)
* The test didn't take into account that the contract expiring on
    December would mean that there would temporarily be no Dec. FOP
    contract. We fix this by looking for the Mar. contract instead
    if the december contract has expired.
2020-12-28 16:28:41 -03:00
Martin-Molinero
529d0a3634 Fix low resolution cache (#5080)
* Replace cache size for MB

* Remove setting capacity

* Custom cache implementation

* Reduce locks in custom cache

* Add cache performance unit test
2020-12-28 16:27:11 -03:00
Martin-Molinero
9c89e8d403 Fix backtest result packet deserializing (#5084)
* added test covering minValue / maxValue issue with JsonRoundingConverter

* change namespaces

* JsonRoundingConverter fix decimal.Min and MaxValues (cannot deserialize)

* remove dependency on 3rd party library

* c# 6 compatible code (remove pattern matching)

* Fixes BacktestResultPacket deserializing

- Serializing decimals as strings to avoid precision loss, since json
  convert will use floating point precision. Updating unit tests.
- Fix logging unit test failing to delete file being used.

Co-authored-by: Mark Virchenko <mark.virchenko@calienteam.com>
2020-12-28 16:26:40 -03:00
Adalyat Nazirov
1988ad1ae5 Bug 4925 daylight out of order bar (#4941)
* test

* wip

* Revert "Fix duplicated history entries when contains daylight saving time change (#4700)"

Use proper rounding down

* regression test

* remove unused parameters

* more tests

* fix name and comment

* improve regression test

* more tests: oanda market hours

* re-apply Exchange TZ to bar EndTime

* fix expected results

* we can't substract minute because it can harm algorithm on minute resolution; so we could use tick?

* rename prop: conflict with QCAlgorithm.StartDate

* do not log messages to pass travis ci log limit

* assign loghandler in AlgorithmSetupHandler

* reference to PR for more description

* due to https://github.com/QuantConnect/Lean/pull/5039 we don't need to override it manually
2020-12-28 16:24:33 -03:00
Martin-Molinero
3658fb1405 Update config.json (#5086) 2020-12-28 13:06:07 -03:00
Colton Sellers
0ac79487d7 IB Brokerage Restore Subscriptions Fix (#5078)
* Return true after all symbols have been processed

* Continue on Canonical Future Symbols
2020-12-23 20:56:07 -03:00
Gerardo Salazar
38120a3217 Converts QuantConnect.Common.csproj file to .NET Sdk format (#5071) 2020-12-23 13:15:29 -03:00
Martin-Molinero
01a13a095a Remove cloud-api-url config setting (#5073) 2020-12-22 22:51:00 -03:00
Colton Sellers
704a5cb00e Pycharm Docker Debugging Fix (#5069)
* Move PyCharm Debugger to port 6000 and expose it

* Change PyCharm default configurations to port 6000
2020-12-22 15:22:46 -03:00
Martin-Molinero
490ad08c89 Optimization handling of failed backtest init (#5068)
- Optimizer will increment failed count and notify the strategy of
  failed backtest initialization
2020-12-21 19:27:27 -03:00
Martin-Molinero
a60cd95611 Optimizer will clean lean before last update (#5063)
- LeanOptimizer will clean up any lean instance before calling the last
  udpate, so that runtime stats are correct.
2020-12-21 15:17:44 -03:00
Colton Sellers
eed8e9c763 Improve IBBrokerage Symbol Mapping Error Message (#5051)
* Improve IBBrokerage Error Message

* Add exception message to catch statement

* Address review

* Address review edits
2020-12-21 13:04:05 -03:00
Marco Grassi
365f53dfc7 Fix the missed rename of OptimizationStatus.Ended to Completed (#5060) 2020-12-19 19:06:09 -03:00
Martin-Molinero
48a86c2626 Rename OptimizationStatus from Ended to Completed (#5059) 2020-12-18 16:53:29 -08:00
Martin-Molinero
2de9c21b6d Optimization tweaks (#5056)
* Add progress for runtimeStats

- Add optimization progress runtimestats
- Add ServerStatistics for the last backtesting package

* Add StaticOptimizationParameter

- Add StaticOptimizationParameter. Updating unit tests
2020-12-18 16:01:44 -08:00
Martin-Molinero
649aafc952 Adding Api.ReadBacktest optional getCharts (#5054)
* Adding Api.ReadBacktest optional getCharts

- Optionally allow users not to fetch backtest charts when reading a
  backtest, it can be slow

* Fix null reference for deleted/cancelled backtests

* Get Leaky bucket config settings once
2020-12-18 14:17:40 -03:00
Gerardo Salazar
25fa4c6fb6 Adds holidays to ES futures (#5045)
* Adds holidays to ES futures

* Adds CME equity product market hours and holidays (ES, NQ, YM)
2020-12-17 21:12:20 -03:00
Martin-Molinero
d1b35f7974 Optimization status update (#5050) 2020-12-17 17:09:01 -03:00
Colton Sellers
4006ba01e4 Reduce Travis Log (#5039)
* Reduce Travis setup verbosity

* Introduce ConsoleErrorLogHandler

* Change Console.WriteLine to Log statements

* Quiet wget

* Route build stubs stdout to null

* Fix Quantbook history test

* Silence stub packages directly

* Use parameterized log-handler for testing

* Rename AssemblyInitialize Setup

* Fix AlgorithmRunner file logging

* Drop all overriden LogHandlers in tests

* Change to OneTimeSetup to maintain LogHandlers

* Permit any ILogHandler to be defined in params

* Fix for AlgorithmRunner Handlers V2
2020-12-17 12:59:13 -03:00
Martin-Molinero
6d824b40a6 Add handling for custom host name (#5043)
* Add handling for custom host name

* Credit cost as decimal
2020-12-16 21:54:00 -03:00
Colton Sellers
8e410fcaf1 Update old Hourly/Daily data for ApiDataProvider (#5034)
* Update old Hourly/Daily data for ApiDataProvider

* Add unit test for IsOutOfDate

* Address review

* Fix reference to static function in test
2020-12-16 19:04:06 -03:00
Adalyat Nazirov
d136428556 ignore *.DotSettings files (#5035)
This layer is designated for common settings that enforce your team preferences for the current solution.
Since we don't have specific resharper settings we want to share within the team we ignore this file
2020-12-16 12:38:01 -03:00
Gerardo Salazar
40d81965be Adds debug logging for MapSymbol(...) method in IB Brokerage (#5040) 2020-12-15 17:44:00 -08:00
Aaron Janeiro Stone
c650eb6c1c Adds DeM indicator (#5002)
* Adds DeM indicator

* Added reference to param movingaverage type

* Fixed variable declarations

* Added nameless initialize

* Missing DeM "type" args added

* Missing DeM "type" args added

* refactor

* Undid _previousInput → protected

* Demarker symbol: DeM →DEM

* Symbol change: DeM → DEM

* Updated symbols

TestDivByZero originally had dem as cmf.

* Symbol: DeM →DEM

Co-authored-by: Alexandre Catarino <AlexCatarino@users.noreply.github.com>
2020-12-15 08:29:55 -03:00
Charles Naccio
aa2f9f927a Fixed QuantBook import path for CSharp example (#5028)
Now requires a relative path for loading QuantBook.csx
2020-12-14 21:22:22 -03:00
Charles Naccio
c698a65a84 Replaced obsolete Gitter badge with Slack (#5031) 2020-12-14 12:55:35 -03:00
Charles Naccio
181283a4cd Noted Polygon downloaded in Readme (#5025) 2020-12-11 16:55:58 -08:00
Martin-Molinero
b247724a34 Improve Optimizer runtime statistics (#5024)
- Adding optimization Id to backtests packets
- SeriesSampler will allow truncating the samples
- Removing OptimizationEstimate, simplifying getting estimate and
  runtime stats separatly
2020-12-11 16:39:13 -08:00
Gerardo Salazar
dde3576161 Fixes intraday delistings not occurring before contract expiry for Futures and FOPs (#5007)
* Fixes intraday delistings not occurring for Futures and FOPs

  * Previously, we would wait until the next market open to
    liquidate futures and futures options contracts. Since these
    contracts can not be traded at the next market open and require
    intraday delisting, changes were made to liquidate at the first
    available place where we know the market is open. This means
    we now liquidate futures and FOPs intraday as a market order.

  * Maintains backwards compatability with equities and equity options
    delisting behavior

* Addresses review: adds additional protections for ProcessDelistedSymbols

  * We choose to adjust the delisting date to the next market open only
    if the market is not open at the current time, otherwise the time
    would have been adjusted to the market open of the next trading day

* Addresses review: reverts changes and fixes error message in regression algo
2020-12-11 20:46:56 -03:00
Gerardo Salazar
e8734a0797 Adds/Fixes Futures Options History Research Support (#5013)
* Adds Futures Options History Research Support

* Address review: make canonical future throw when calling GetOptionHistory

* Improve error message, recommending users to user FutureChainProvider
2020-12-11 20:46:41 -03:00
Aaron Janeiro Stone
7f5d69bbec Adds the Awesome Oscillator (#5005)
* Adds the awesome oscillator.

* added missing type hint for AO

* cleaned initializations

* refactor in call for AO(fast,slow,type)

* added missing type parameter for AO

* Changes AO sub-indicators to public.

Co-authored-by: Alexandre Catarino <AlexCatarino@users.noreply.github.com>
2020-12-11 20:46:07 -03:00
Colton Sellers
f6be7a41a5 Bug python runtime issue with local report generation (#5014)
* Fixed Python runtime issue that was occurring when trying to generate reports locally on OSX/mono, but assume the issue impacts all configurations.

* Move Python.Runtime config to common

* Remove duplicate files

* Update readme

* Typo

* Change destination in build directory

Co-authored-by: Charles Naccio <cnaccio@gmail.com>
2020-12-11 20:45:26 -03:00
Stefano Raggi
7f30c0cd00 Downgrade IB error codes from Warning to Information (#5015) 2020-12-11 18:53:25 -03:00
Colton Sellers
6694fe01f8 Api Chart Hotfix (#5023)
* Api Chart Hotfix

* Use IsNullOrEmpty
2020-12-11 18:43:18 -03:00
Aaron Janeiro Stone
32ab4fdea1 Adds ChaikinMoneyFlow indicator (#4986)
* Added CMF indicator

CMF is a volume-weighted average of accumulation and distribution over a period.

* Added initializer for CMF

Registration for ChaikinMoneyFlow implemented.

* Added CMF tests.

* Added CMF tests.

* spy_cmf.txt changed to external indicator data.

* Implement suggestions of @AlexCatarino

* added sum terms as subindicators.

* added sum terms as subindicators.

* Removal of vestigial rolling window

* Minor nit changes

Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
2020-12-11 18:04:17 -03:00
Colton Sellers
fc81f606e4 Reserve Names for Pandas Mapper (#4978)
* Fix for #4886 and unit test

* Fix test function

* Address review

* Clarify comments
2020-12-11 16:39:13 -03:00
Stefano Raggi
ec74abd4d0 Fix Bitfinex brokerage currency mapping (#5011) 2020-12-11 16:12:57 -03:00
Colton Sellers
bd3ead3480 ApiDataProvider Zip Download Fixes (#5020)
* Stop non zip responses from being saved as a zip

* Capture and log message

* Log as Error
2020-12-11 16:01:57 -03:00
Colton Sellers
45849962a3 Readme expansion and additional VS build tasks (#5018) 2020-12-11 14:49:29 -03:00
Gerardo Salazar
8279cf7eac Improve exception message for indicators using Update(DateTime, decimal) (#5019) 2020-12-11 14:36:42 -03:00
Colton Sellers
4c4a699cb0 Stop Emitting Insights on Delisted Securities (#4997)
* Verify insights are valid before emitting

* nit

* Address review

* Address review and unit tests

* nit - remove extra lines

* Address review

* Initialize insight fields
2020-12-10 11:44:37 -03:00
Colton Sellers
31a2c31c0a Api Update November 2020 (#4981)
* WIP Backtest adjustments

* Workaround awaiting changes

* Adjustments to API Changes

* Nit fix

* Custom Newtonsoft Deserializer for AlphaRuntimeStatistics

* Workaround Travis build error

* Drop AlphaRuntimeStatistics converter; use Decimal converter

* Use StringDecimalJsonConverter

* Undo set properties

* Add more members to de-serializer class
2020-12-09 16:51:58 -03:00
Jared
877a123276 Update readme.md 2020-12-08 12:26:21 -08:00
Gerardo Salazar
4134b05bfd Fixes options order crash in ReportGenerator/PortfolioLooper (#4992) 2020-12-07 12:39:53 -03:00
424 changed files with 17915 additions and 9337 deletions

1
.gitignore vendored
View File

@@ -144,6 +144,7 @@ $tf/
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings
*.DotSettings.user
# JustCode is a .NET coding addin-in

4
.idea/workspace.xml generated
View File

@@ -3,7 +3,7 @@
<component name="RunManager" selected="Python Debug Server.Debug in Container">
<configuration name="Debug Local" type="PyRemoteDebugConfigurationType" factoryName="Python Remote Debug">
<module name="LEAN" />
<option name="PORT" value="5678" />
<option name="PORT" value="6000" />
<option name="HOST" value="localhost" />
<PathMappingSettings>
<option name="pathMappings">
@@ -16,7 +16,7 @@
</configuration>
<configuration name="Debug in Container" type="PyRemoteDebugConfigurationType" factoryName="Python Remote Debug">
<module name="LEAN" />
<option name="PORT" value="5678" />
<option name="PORT" value="6000" />
<option name="HOST" value="localhost" />
<PathMappingSettings>
<option name="pathMappings">

View File

@@ -5,7 +5,7 @@ mono:
solution: QuantConnect.Lean.sln
before_install:
- export PATH="$HOME/miniconda3/bin:$PATH"
- wget https://cdn.quantconnect.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh
- wget -q https://cdn.quantconnect.com/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh
- bash Miniconda3-4.5.12-Linux-x86_64.sh -b
- rm -rf Miniconda3-4.5.12-Linux-x86_64.sh
- sudo ln -s $HOME/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6m.so
@@ -17,10 +17,10 @@ before_install:
- conda install -y scipy=1.4.1
- conda install -y wrapt=1.12.1
install:
- nuget restore QuantConnect.Lean.sln
- nuget restore QuantConnect.Lean.sln -v quiet
- nuget install NUnit.Runners -Version 3.11.1 -OutputDirectory testrunner
script:
- msbuild /p:Configuration=Release /p:VbcToolExe=vbnc.exe QuantConnect.Lean.sln
- mono ./testrunner/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe ./Tests/bin/Release/QuantConnect.Tests.dll --where "cat != TravisExclude" --labels=Off
- msbuild /p:Configuration=Release /p:VbcToolExe=vbnc.exe /v:quiet /p:WarningLevel=1 QuantConnect.Lean.sln
- mono ./testrunner/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe ./Tests/bin/Release/QuantConnect.Tests.dll --where "cat != TravisExclude" --labels=Off --params:log-handler=ConsoleErrorLogHandler
- chmod +x ci_build_stubs.sh
- sudo -E ./ci_build_stubs.sh -d -t -g -p

15
.vscode/readme.md vendored
View File

@@ -13,7 +13,7 @@ Before anything we need to ensure a few things have been done:
1. Get [Visual Studio Code](https://code.visualstudio.com/download)
* Get the Extension [Mono Debug](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) for C# Debugging
* Get the Extension [Mono Debug **15.8**](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) for C# Debugging
* Get the Extension [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for Python Debugging
2. Get [Docker](https://docs.docker.com/get-docker/):
@@ -35,7 +35,8 @@ Before anything we need to ensure a few things have been done:
* Download the repo or clone it using: _git clone[ https://github.com/QuantConnect/Lean](https://github.com/QuantConnect/Lean)_
* Open the folder using VS Code
**NOTES**:
- Mono Extension Version 16 and greater fails to debug the docker container remotely, please install **Version 15.8**. To install an older version from within VS Code go to the extensions tab, search "Mono Debug", and select "Install Another Version...".
<br />
<h1>Develop Algorithms Locally, Run in Container</h1>
@@ -112,6 +113,12 @@ In VS Code click on the debug/run icon on the left toolbar, at the top you shoul
As defaults these are all great! Feel free to change them as needed for your setup.
**NOTE:** VSCode may try and throw errors when launching this way regarding build on `QuantConnect.csx` and `Config.json` these errors can be ignored by selecting "*Debug Anyway*". To stop this error message in the future select "*Remember my choice in user settings*".
If using C# algorithms ensure that msbuild can build them successfully.
<br />
<h3>Option 2</h3>
@@ -194,4 +201,6 @@ _Figure 2: Python Debugger Messages_
<h1>Common Issues</h1>
Here we will cover some common issues with setting this up. This section will expand as we get user feedback!
* Error messages about build in VSCode points to comments in JSON. Either select **ignore** or follow steps described [here](https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json) to remove the errors entirely.
* Any error messages about building in VSCode that point to comments in JSON. Either select **ignore** or follow steps described [here](https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json) to remove the errors entirely.
* `Errors exist after running preLaunchTask 'run-docker'`This VSCode error appears to warn you of CSharp errors when trying to use `Debug in Container` select "Debug Anyway" as the errors are false flags for JSON comments as well as `QuantConnect.csx` not finding references. Neither of these will impact your debugging.
* `The container name "/LeanEngine" is already in use by container "****"` This Docker error implies that another instance of lean is already running under the container name /LeanEngine. If this error appears either use Docker Desktop to delete the container or use `docker kill LeanEngine` from the command line.

28
.vscode/tasks.json vendored
View File

@@ -20,6 +20,34 @@
},
"problemMatcher": "$msCompile"
},
{
"label": "rebuild",
"type": "shell",
"command": "msbuild",
"args": [
"/p:Configuration=Debug",
"/p:DebugType=portable",
"/t:rebuild",
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"type": "shell",
"command": "msbuild",
"args": [
"/t:clean",
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "force build linux",
"type": "shell",

View File

@@ -131,13 +131,13 @@ namespace QuantConnect.Algorithm.CSharp
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.92"},
{"Alpha", "-0.023"},
{"Beta", "0.005"},
{"Alpha", "-0.021"},
{"Beta", "-0.01"},
{"Annual Standard Deviation", "0.006"},
{"Annual Variance", "0"},
{"Information Ratio", "-3.424"},
{"Tracking Error", "0.057"},
{"Treynor Ratio", "-4.775"},
{"Information Ratio", "-3.374"},
{"Tracking Error", "0.058"},
{"Treynor Ratio", "2.133"},
{"Total Fees", "$2.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
@@ -158,7 +158,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1185639451"}
{"OrderListHash", "-262924291"}
};
}
}

View File

@@ -0,0 +1,236 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Brokerages;
using QuantConnect.Data;
using QuantConnect.Data.Shortable;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Tests filtering in coarse selection by shortable quantity
/// </summary>
public class AllShortableSymbolsCoarseSelectionRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private static readonly DateTime _20140325 = new DateTime(2014, 3, 25);
private static readonly DateTime _20140326 = new DateTime(2014, 3, 26);
private static readonly DateTime _20140327 = new DateTime(2014, 3, 27);
private static readonly DateTime _20140328 = new DateTime(2014, 3, 28);
private static readonly DateTime _20140329 = new DateTime(2014, 3, 29);
private static readonly Symbol _aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
private static readonly Symbol _bac = QuantConnect.Symbol.Create("BAC", SecurityType.Equity, Market.USA);
private static readonly Symbol _gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
private static readonly Symbol _goog = QuantConnect.Symbol.Create("GOOG", SecurityType.Equity, Market.USA);
private static readonly Symbol _qqq = QuantConnect.Symbol.Create("QQQ", SecurityType.Equity, Market.USA);
private static readonly Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
private DateTime _lastTradeDate;
private static readonly Dictionary<DateTime, bool> _coarseSelected = new Dictionary<DateTime, bool>
{
{ _20140325, false },
{ _20140326, false },
{ _20140327, false },
{ _20140328, false },
};
private static readonly Dictionary<DateTime, Symbol[]> _expectedSymbols = new Dictionary<DateTime, Symbol[]>
{
{ _20140325, new[]
{
_bac,
_qqq,
_spy
}
},
{ _20140326, new[]
{
_spy
}
},
{ _20140327, new[]
{
_aapl,
_bac,
_gme,
_qqq,
_spy,
}
},
{ _20140328, new[]
{
_goog
}
},
{ _20140329, new Symbol[0] }
};
public override void Initialize()
{
SetStartDate(2014, 3, 25);
SetEndDate(2014, 3, 29);
SetCash(10000000);
AddUniverse(CoarseSelection);
UniverseSettings.Resolution = Resolution.Daily;
SetBrokerageModel(new AllShortableSymbolsRegressionAlgorithmBrokerageModel());
}
public override void OnData(Slice data)
{
if (Time.Date == _lastTradeDate)
{
return;
}
foreach (var symbol in ActiveSecurities.Keys)
{
if (!Portfolio.ContainsKey(symbol) || !Portfolio[symbol].Invested)
{
if (!Shortable(symbol))
{
throw new Exception($"Expected {symbol} to be shortable on {Time:yyyy-MM-dd}");
}
// Buy at least once into all Symbols. Since daily data will always use
// MOO orders, it makes the testing of liquidating buying into Symbols difficult.
MarketOrder(symbol, -(decimal)ShortableQuantity(symbol));
_lastTradeDate = Time.Date;
}
}
}
private IEnumerable<Symbol> CoarseSelection(IEnumerable<CoarseFundamental> coarse)
{
var shortableSymbols = AllShortableSymbols();
var selectedSymbols = coarse
.Select(x => x.Symbol)
.Where(s => shortableSymbols.ContainsKey(s) && shortableSymbols[s] >= 500)
.OrderBy(s => s)
.ToList();
var expectedMissing = 0;
if (Time.Date == _20140327)
{
var gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
if (!shortableSymbols.ContainsKey(gme))
{
throw new Exception("Expected unmapped GME in shortable symbols list on 2014-03-27");
}
if (!coarse.Select(x => x.Symbol.Value).Contains("GME"))
{
throw new Exception("Expected mapped GME in coarse symbols on 2014-03-27");
}
expectedMissing = 1;
}
var missing = _expectedSymbols[Time.Date].Except(selectedSymbols).ToList();
if (missing.Count != expectedMissing)
{
throw new Exception($"Expected Symbols selected on {Time.Date:yyyy-MM-dd} to match expected Symbols, but the following Symbols were missing: {string.Join(", ", missing.Select(s => s.ToString()))}");
}
_coarseSelected[Time.Date] = true;
return selectedSymbols;
}
public override void OnEndOfAlgorithm()
{
if (!_coarseSelected.Values.All(x => x))
{
throw new AggregateException($"Expected coarse selection on all dates, but didn't run on: {string.Join(", ", _coarseSelected.Where(kvp => !kvp.Value).Select(kvp => kvp.Key.ToStringInvariant("yyyy-MM-dd")))}");
}
}
private class AllShortableSymbolsRegressionAlgorithmBrokerageModel : DefaultBrokerageModel
{
public AllShortableSymbolsRegressionAlgorithmBrokerageModel() : base()
{
ShortableProvider = new RegressionTestShortableProvider();
}
}
private class RegressionTestShortableProvider : LocalDiskShortableProvider
{
public RegressionTestShortableProvider() : base(SecurityType.Equity, "testbrokerage", Market.USA)
{
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "5"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "36.294%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0.340%"},
{"Sharpe Ratio", "21.2"},
{"Probabilistic Sharpe Ratio", "99.990%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.274"},
{"Beta", "0.138"},
{"Annual Standard Deviation", "0.011"},
{"Annual Variance", "0"},
{"Information Ratio", "7.202"},
{"Tracking Error", "0.068"},
{"Treynor Ratio", "1.722"},
{"Total Fees", "$307.50"},
{"Fitness Score", "0.173"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
{"Portfolio Turnover", "0.173"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "97613274"}
};
}
}

View File

@@ -19,28 +19,27 @@ using QuantConnect.Indicators;
using QuantConnect.Orders.Fees;
using QuantConnect.Data.Custom;
using System.Collections.Generic;
using QuantConnect.Algorithm.Framework;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Execution;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Risk;
using QuantConnect.Algorithm.Framework.Selection;
namespace QuantConnect.Algorithm.CSharp
namespace QuantConnect.Algorithm.CSharp.Alphas
{
/// <summary>
/// This Alpha Model uses Wells Fargo 30-year Fixed Rate Mortgage data from Quandl to
/// generate Insights about the movement of Real Estate ETFs. Mortgage rates can provide information
/// regarding the general price trend of real estate, and ETFs provide good continuous-time instruments
/// to measure the impact against. Volatility in mortgage rates tends to put downward pressure on real
/// estate prices, whereas stable mortgage rates, regardless of true rate, lead to stable or higher real
/// estate prices. This Alpha model seeks to take advantage of this correlation by emitting insights
/// based on volatility and rate deviation from its historic mean.
/// This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open
///<summary>
/// This Alpha Model uses Wells Fargo 30-year Fixed Rate Mortgage data from Quandl to
/// generate Insights about the movement of Real Estate ETFs. Mortgage rates can provide information
/// regarding the general price trend of real estate, and ETFs provide good continuous-time instruments
/// to measure the impact against. Volatility in mortgage rates tends to put downward pressure on real
/// estate prices, whereas stable mortgage rates, regardless of true rate, lead to stable or higher real
/// estate prices. This Alpha model seeks to take advantage of this correlation by emitting insights
/// based on volatility and rate deviation from its historic mean.
///
/// This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open
/// sourced so the community and client funds can see an example of an alpha.
/// <summary>
public class MortgageRateVolatilityAlgorithm : QCAlgorithmFramework
///</summary>
public class MortgageRateVolatilityAlgorithm : QCAlgorithm
{
public override void Initialize()
{
@@ -51,8 +50,8 @@ namespace QuantConnect.Algorithm.CSharp
SetSecurityInitializer(security => security.FeeModel = new ConstantFeeModel(0));
// Basket of 6 liquid real estate ETFs
Func<string, Symbol> ToSymbol = x => QuantConnect.Symbol.Create(x, SecurityType.Equity, Market.USA);
var realEstateETFs = new[] { "VNQ", "REET", "TAO", "FREL", "SRET", "HIPS" }.Select(ToSymbol).ToArray();
Func<string, Symbol> toSymbol = x => QuantConnect.Symbol.Create(x, SecurityType.Equity, Market.USA);
var realEstateETFs = new[] { "VNQ", "REET", "TAO", "FREL", "SRET", "HIPS" }.Select(toSymbol).ToArray();
SetUniverseSelection(new ManualUniverseSelectionModel(realEstateETFs));
SetAlpha(new MortgageRateVolatilityAlphaModel(this));
@@ -64,8 +63,6 @@ namespace QuantConnect.Algorithm.CSharp
SetRiskManagement(new NullRiskManagementModel());
}
public void OnData(QuandlMortgagePriceColumns data) { }
private class MortgageRateVolatilityAlphaModel : AlphaModel
{
@@ -79,7 +76,7 @@ namespace QuantConnect.Algorithm.CSharp
private readonly StandardDeviation _mortgageRateStd;
public MortgageRateVolatilityAlphaModel(
QCAlgorithmFramework algorithm,
QCAlgorithm algorithm,
int indicatorPeriod = 15,
double insightMagnitude = 0.0005,
int deviations = 2,
@@ -102,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
WarmUpIndicators(algorithm);
}
public override IEnumerable<Insight> Update(QCAlgorithmFramework algorithm, Slice data)
public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data)
{
var insights = new List<Insight>();
@@ -141,7 +138,7 @@ namespace QuantConnect.Algorithm.CSharp
return insights;
}
private void WarmUpIndicators(QCAlgorithmFramework algorithm)
private void WarmUpIndicators(QCAlgorithm algorithm)
{
// Make a history call and update the indicators
algorithm.History(new[] { _mortgageRate }, _indicatorPeriod, _resolution).PushThrough(bar =>

View File

@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
@@ -303,21 +303,39 @@ namespace QuantConnect.Algorithm.CSharp
{"Drawdown", "0.400%"},
{"Expectancy", "-1"},
{"Net Profit", "-0.323%"},
{"Sharpe Ratio", "-0.888"},
{"Sharpe Ratio", "-11.098"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.035"},
{"Beta", "0.183"},
{"Annual Standard Deviation", "0.004"},
{"Alpha", "-0.002"},
{"Beta", "0.099"},
{"Annual Standard Deviation", "0.002"},
{"Annual Variance", "0"},
{"Information Ratio", "12.058"},
{"Tracking Error", "0.017"},
{"Treynor Ratio", "-0.018"},
{"Information Ratio", "9.899"},
{"Tracking Error", "0.019"},
{"Treynor Ratio", "-0.23"},
{"Total Fees", "$2.00"},
{"Fitness Score", "0.213"},
{"OrderListHash", "904167951"}
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "-73.456"},
{"Portfolio Turnover", "0.426"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1990039314"}
};
}
}

View File

@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "1"},
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
@@ -141,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "687310345"}
{"OrderListHash", "-91832511"}
};
}
}

View File

@@ -160,7 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Information Ratio", "0"},
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$4.00"},
{"Total Fees", "$3.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0.327"},
{"Kelly Criterion Probability Value", "1"},
@@ -180,7 +180,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "50.0482%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "352959406"}
{"OrderListHash", "-695205588"}
};
}
}

View File

@@ -144,7 +144,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Annual Variance", "0.027"},
{"Information Ratio", "-0.391"},
{"Tracking Error", "0.239"},
{"Treynor Ratio", "-1.416"},
{"Treynor Ratio", "-1.435"},
{"Total Fees", "$755.29"},
{"Fitness Score", "0.024"},
{"Kelly Criterion Estimate", "-0.84"},

View File

@@ -38,6 +38,10 @@ namespace QuantConnect.Algorithm.CSharp
// Find more symbols here: http://quantconnect.com/data
AddSecurity(SecurityType.Equity, "SPY", Resolution.Second);
// Disabling the benchmark / setting to a fixed value
// SetBenchmark(time => 0);
// Set the benchmark to AAPL US Equity
SetBenchmark("AAPL");
}

View File

@@ -0,0 +1,260 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression test to demonstrate setting custom Symbol Properties and Market Hours for a custom data import
/// </summary>
/// <meta name="tag" content="using data" />
/// <meta name="tag" content="custom data" />
/// <meta name="tag" content="crypto" />
/// <meta name="tag" content="regression test" />
public class CustomDataPropertiesRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private string _ticker = "BTC";
private Security _bitcoin;
/// <summary>
/// Initialize the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2011, 9, 13);
SetEndDate(2015, 12, 01);
//Set the cash for the strategy:
SetCash(100000);
// Define our custom data properties and exchange hours
var properties = new SymbolProperties("Bitcoin", "USD", 1, 0.01m, 0.01m, _ticker);
var exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork);
// Add the custom data to our algorithm with our custom properties and exchange hours
_bitcoin = AddData<Bitcoin>(_ticker, properties, exchangeHours);
//Verify our symbol properties were changed and loaded into this security
if (_bitcoin.SymbolProperties != properties)
{
throw new Exception("Failed to set and retrieve custom SymbolProperties for BTC");
}
//Verify our exchange hours were changed and loaded into this security
if (_bitcoin.Exchange.Hours != exchangeHours)
{
throw new Exception("Failed to set and retrieve custom ExchangeHours for BTC");
}
// For regression purposes on AddData overloads, this call is simply to ensure Lean can accept this
// with default params and is not routed to a breaking function.
AddData<Bitcoin>("BTCUSD");
}
/// <summary>
/// Event Handler for Bitcoin Data Events: These Bitcoin objects are created from our
/// "Bitcoin" type below and fired into this event handler.
/// </summary>
/// <param name="data">One(1) Bitcoin Object, streamed into our algorithm synchronized in time with our other data streams</param>
public void OnData(Bitcoin data)
{
//If we don't have any bitcoin "SHARES" -- invest"
if (!Portfolio.Invested)
{
//Bitcoin used as a tradable asset, like stocks, futures etc.
if (data.Close != 0)
{
//Access custom data symbols using <ticker>.<custom-type>
Order("BTC.Bitcoin", Portfolio.MarginRemaining / Math.Abs(data.Close + 1));
}
}
}
public override void OnEndOfAlgorithm()
{
// Reset our Symbol property value, for testing purposes.
SymbolPropertiesDatabase.SetEntry(Market.USA, MarketHoursDatabase.GetDatabaseSymbolKey(_bitcoin.Symbol), SecurityType.Base,
SymbolProperties.GetDefault("USD"));
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "155.262%"},
{"Drawdown", "84.800%"},
{"Expectancy", "0"},
{"Net Profit", "5123.242%"},
{"Sharpe Ratio", "2.067"},
{"Probabilistic Sharpe Ratio", "68.833%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.732"},
{"Beta", "0.037"},
{"Annual Standard Deviation", "0.841"},
{"Annual Variance", "0.707"},
{"Information Ratio", "1.902"},
{"Tracking Error", "0.848"},
{"Treynor Ratio", "46.992"},
{"Total Fees", "$0.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "2.238"},
{"Return Over Maximum Drawdown", "1.832"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "508036553"}
};
/// <summary>
/// Custom Data Type: Bitcoin data from Quandl - http://www.quandl.com/help/api-for-bitcoin-data
/// </summary>
public class Bitcoin : BaseData
{
[JsonProperty("timestamp")]
public int Timestamp = 0;
[JsonProperty("open")]
public decimal Open = 0;
[JsonProperty("high")]
public decimal High = 0;
[JsonProperty("low")]
public decimal Low = 0;
[JsonProperty("last")]
public decimal Close = 0;
[JsonProperty("bid")]
public decimal Bid = 0;
[JsonProperty("ask")]
public decimal Ask = 0;
[JsonProperty("vwap")]
public decimal WeightedPrice = 0;
[JsonProperty("volume")]
public decimal VolumeBTC = 0;
public decimal VolumeUSD = 0;
/// <summary>
/// 1. DEFAULT CONSTRUCTOR: Custom data types need a default constructor.
/// We search for a default constructor so please provide one here. It won't be used for data, just to generate the "Factory".
/// </summary>
public Bitcoin()
{
Symbol = "BTC";
}
/// <summary>
/// 2. RETURN THE STRING URL SOURCE LOCATION FOR YOUR DATA:
/// This is a powerful and dynamic select source file method. If you have a large dataset, 10+mb we recommend you break it into smaller files. E.g. One zip per year.
/// We can accept raw text or ZIP files. We read the file extension to determine if it is a zip file.
/// </summary>
/// <param name="config">Configuration object</param>
/// <param name="date">Date of this source file</param>
/// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
/// <returns>String URL of source file.</returns>
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
{
if (isLiveMode)
{
return new SubscriptionDataSource("https://www.bitstamp.net/api/ticker/", SubscriptionTransportMedium.Rest);
}
//return "http://my-ftp-server.com/futures-data-" + date.ToString("Ymd") + ".zip";
// OR simply return a fixed small data file. Large files will slow down your backtest
return new SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.RemoteFile);
}
/// <summary>
/// 3. READER METHOD: Read 1 line from data source and convert it into Object.
/// Each line of the CSV File is presented in here. The backend downloads your file, loads it into memory and then line by line
/// feeds it into your algorithm
/// </summary>
/// <param name="line">string line from the data source file submitted above</param>
/// <param name="config">Subscription data, symbol name, data type</param>
/// <param name="date">Current date we're requesting. This allows you to break up the data source into daily files.</param>
/// <param name="isLiveMode">true if we're in live mode, false for backtesting mode</param>
/// <returns>New Bitcoin Object which extends BaseData.</returns>
public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
{
var coin = new Bitcoin();
if (isLiveMode)
{
//Example Line Format:
//{"high": "441.00", "last": "421.86", "timestamp": "1411606877", "bid": "421.96", "vwap": "428.58", "volume": "14120.40683975", "low": "418.83", "ask": "421.99"}
try
{
coin = JsonConvert.DeserializeObject<Bitcoin>(line);
coin.EndTime = DateTime.UtcNow.ConvertFromUtc(config.ExchangeTimeZone);
coin.Value = coin.Close;
}
catch { /* Do nothing, possible error in json decoding */ }
return coin;
}
//Example Line Format:
//Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
//2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356
try
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
coin.Close = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
coin.VolumeBTC = Convert.ToDecimal(data[5], CultureInfo.InvariantCulture);
coin.VolumeUSD = Convert.ToDecimal(data[6], CultureInfo.InvariantCulture);
coin.WeightedPrice = Convert.ToDecimal(data[7], CultureInfo.InvariantCulture);
coin.Value = coin.Close;
}
catch { /* Do nothing, skip first title row */ }
return coin;
}
}
}
}

View File

@@ -100,25 +100,25 @@ namespace QuantConnect.Algorithm.CSharp
{"Drawdown", "1.300%"},
{"Expectancy", "0"},
{"Net Profit", "1.634%"},
{"Sharpe Ratio", "2.476"},
{"Probabilistic Sharpe Ratio", "92.194%"},
{"Sharpe Ratio", "2.495"},
{"Probabilistic Sharpe Ratio", "92.298%"},
{"Loss Rate", "0%"},
{"Win Rate", "100%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.006"},
{"Beta", "0.158"},
{"Annual Standard Deviation", "0.032"},
{"Annual Standard Deviation", "0.033"},
{"Annual Variance", "0.001"},
{"Information Ratio", "-4.89"},
{"Information Ratio", "-4.942"},
{"Tracking Error", "0.08"},
{"Treynor Ratio", "0.509"},
{"Treynor Ratio", "0.517"},
{"Total Fees", "$3.70"},
{"Fitness Score", "0.019"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "1.362"},
{"Return Over Maximum Drawdown", "9.699"},
{"Portfolio Turnover", "0.022"},
{"Portfolio Turnover", "0.023"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -132,7 +132,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1252326142"}
{"OrderListHash", "528208939"}
};
}
}

View File

@@ -45,7 +45,7 @@ namespace QuantConnect.Algorithm.CSharp
SetEndDate(2007, 05, 25); //Set End Date
SetCash(100000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddSecurity(SecurityType.Equity, "AAA", Resolution.Daily);
AddSecurity(SecurityType.Equity, "AAA.1", Resolution.Daily);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily);
}
@@ -58,7 +58,7 @@ namespace QuantConnect.Algorithm.CSharp
_dataCount += data.Bars.Count;
if (Transactions.OrdersCount == 0)
{
SetHoldings("AAA", 1);
SetHoldings("AAA.1", 1);
Debug("Purchased Stock");
}
@@ -71,7 +71,7 @@ namespace QuantConnect.Algorithm.CSharp
// the slice can also contain delisting data: data.Delistings in a dictionary string->Delisting
var aaa = Securities["AAA"];
var aaa = Securities["AAA.1"];
if (aaa.IsDelisted && aaa.IsTradable)
{
throw new Exception("Delisted security must NOT be tradable");
@@ -179,7 +179,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-2022527947"}
{"OrderListHash", "-335704027"}
};
}
}

View File

@@ -0,0 +1,148 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Securities;
using System.Collections.Generic;
using System.Linq;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm reproducing issue #5160 where delisting order would be cancelled because it was placed at the market close on the delisting day
/// </summary>
public class DelistingFutureOptionRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private bool _traded;
private int _lastMonth;
public override void Initialize()
{
SetStartDate(2012, 1, 1);
SetEndDate(2013, 1, 1);
SetCash(10000000);
var dc = AddFuture(Futures.Dairy.ClassIIIMilk, Resolution.Minute, Market.CME);
dc.SetFilter(1, 120);
AddFutureOption(dc.Symbol, universe => universe.Strikes(-2, 2));
_lastMonth = -1;
}
public override void OnData(Slice data)
{
if (Time.Month != _lastMonth)
{
_lastMonth = Time.Month;
var investedSymbols = Securities.Values
.Where(security => security.Invested)
.Select(security => security.Symbol)
.ToList();
var delistedSecurity = investedSymbols.Where(symbol => symbol.ID.Date.AddDays(1) < Time).ToList();
if (delistedSecurity.Count > 0)
{
throw new Exception($"[{UtcTime}] We hold a delisted securities: {string.Join(",", delistedSecurity)}");
}
Log($"Holdings({Time}): {string.Join(",", investedSymbols)}");
}
if (Portfolio.Invested)
{
return;
}
foreach (var chain in data.OptionChains.Values)
{
foreach (var contractsValue in chain.Contracts.Values)
{
MarketOrder(contractsValue.Symbol, 1);
_traded = true;
}
}
}
public override void OnEndOfAlgorithm()
{
if (!_traded)
{
throw new Exception("We expected some FOP trading to happen");
}
if (Portfolio.Invested)
{
throw new Exception("We shouldn't be invested anymore");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "16"},
{"Average Win", "0.01%"},
{"Average Loss", "-0.02%"},
{"Compounding Annual Return", "-0.111%"},
{"Drawdown", "0.100%"},
{"Expectancy", "-0.679"},
{"Net Profit", "-0.112%"},
{"Sharpe Ratio", "-1.052"},
{"Probabilistic Sharpe Ratio", "0.000%"},
{"Loss Rate", "80%"},
{"Win Rate", "20%"},
{"Profit-Loss Ratio", "0.61"},
{"Alpha", "-0.001"},
{"Beta", "-0.001"},
{"Annual Standard Deviation", "0.001"},
{"Annual Variance", "0"},
{"Information Ratio", "-1.187"},
{"Tracking Error", "0.115"},
{"Treynor Ratio", "1.545"},
{"Total Fees", "$37.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.128"},
{"Return Over Maximum Drawdown", "-0.995"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "657651179"}
};
}
}

View File

@@ -85,11 +85,11 @@ namespace QuantConnect.Algorithm.CSharp
{
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "-0.01%"},
{"Compounding Annual Return", "-0.500%"},
{"Drawdown", "0.000%"},
{"Average Loss", "-0.12%"},
{"Compounding Annual Return", "-9.062%"},
{"Drawdown", "0.100%"},
{"Expectancy", "-1"},
{"Net Profit", "-0.006%"},
{"Net Profit", "-0.121%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "100%"},
@@ -103,12 +103,12 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.22"},
{"Treynor Ratio", "0"},
{"Total Fees", "$6.41"},
{"Fitness Score", "0.248"},
{"Fitness Score", "0.249"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "-82.815"},
{"Portfolio Turnover", "0.497"},
{"Return Over Maximum Drawdown", "-79.031"},
{"Portfolio Turnover", "0.498"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1213851303"}
{"OrderListHash", "-1760998125"}
};
}
}

View File

@@ -0,0 +1,123 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression test algorithm simply fetch and compare data of minute resolution around daylight saving period
/// reproduces issue reported in GB issue GH issue https://github.com/QuantConnect/Lean/issues/4925
/// related issues https://github.com/QuantConnect/Lean/issues/3707; https://github.com/QuantConnect/Lean/issues/4630
/// </summary>
public class FillForwardEnumeratorOutOfOrderBarRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private decimal _exptectedClose = 84.09m;
private DateTime _exptectedTime = new DateTime(2008, 3, 10, 9, 30, 0);
private Symbol _shy;
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2008, 3, 7);
SetEndDate(2008, 3, 10);
_shy = AddEquity("SHY", Resolution.Minute).Symbol;
// just to make debugging easier, less subscriptions
SetBenchmark(time => 1);
}
public override void OnData(Slice slice)
{
var trackingBar = slice.Bars.Values.FirstOrDefault(s => s.Time.Equals(_exptectedTime));
if (trackingBar != null)
{
if (!Portfolio.Invested)
{
SetHoldings(_shy, 1);
}
if (trackingBar.Close != _exptectedClose)
{
throw new Exception(
$"Bar at {_exptectedTime.ToStringInvariant()} closed at price {trackingBar.Close.ToStringInvariant()}; expected {_exptectedClose.ToStringInvariant()}");
}
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "0"},
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$5.93"},
{"Fitness Score", "0.499"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "-105.726"},
{"Portfolio Turnover", "0.998"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-850144190"}
};
}
}

View File

@@ -0,0 +1,169 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using QuantConnect.Data;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Interfaces;
using QuantConnect.Securities.Option;
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm checks FillForwardEnumerator should FF the data until it reaches the delisting date
/// replicates GH issue https://github.com/QuantConnect/Lean/issues/4872
/// </summary>
public class FillForwardUntilExpiryRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private DateTime _realEndDate = new DateTime(2014, 06, 07);
private SecurityExchange _exchange;
private Dictionary<Symbol, HashSet<DateTime>> _options;
private string[] _contracts =
{
"TWX 140621P00067500",
"TWX 140621C00067500",
"TWX 140621C00070000",
"TWX 140621P00070000"
};
public override void Initialize()
{
SetStartDate(2014, 06, 05);
SetEndDate(2014, 06, 30);
_options = new Dictionary<Symbol, HashSet<DateTime>>();
var _twxOption = AddOption("TWX", Resolution.Minute);
_exchange = _twxOption.Exchange;
_twxOption.SetFilter((x) => x
.Contracts(c => c.Where(s => _contracts.Contains(s.Value))));
SetBenchmark(t => 1);
}
public override void OnData(Slice data)
{
foreach (var value in data.OptionChains.Values)
{
foreach (var contact in value.Contracts)
{
BaseData bar = null;
QuoteBar quoteBar;
if (bar == null && value.QuoteBars.TryGetValue(contact.Key, out quoteBar))
{
bar = quoteBar;
}
TradeBar tradeBar;
if (bar == null && value.TradeBars.TryGetValue(contact.Key, out tradeBar))
{
bar = tradeBar;
}
if (bar.IsFillForward)
{
_options[contact.Key].Add(value.Time.Date);
}
}
}
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
foreach (var security in changes.AddedSecurities.OfType<Option>())
{
_options.Add(security.Symbol, new HashSet<DateTime>());
}
}
public override void OnEndOfAlgorithm()
{
if (_options.Count != _contracts.Length)
{
throw new Exception($"Options weren't setup properly. Expected: {_contracts.Length}");
}
foreach (var option in _options)
{
for (DateTime date = _realEndDate; date < option.Key.ID.Date; date = date.AddDays(1))
{
if (_exchange.Hours.IsDateOpen(date) &&
!option.Value.Contains(date))
{
throw new Exception("Delisted security should be FF until expiry date");
}
}
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "0"},
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "371857150"}
};
}
}

View File

@@ -92,12 +92,12 @@ namespace QuantConnect.Algorithm.CSharp
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.093"},
{"Beta", "-0.1"},
{"Beta", "-0.099"},
{"Annual Standard Deviation", "0.18"},
{"Annual Variance", "0.032"},
{"Information Ratio", "-0.001"},
{"Tracking Error", "0.267"},
{"Treynor Ratio", "-0.846"},
{"Treynor Ratio", "-0.847"},
{"Total Fees", "$41.17"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "38.884"},

View File

@@ -43,11 +43,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
var es20h20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -124,31 +119,31 @@ namespace QuantConnect.Algorithm.CSharp
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "6"},
{"Average Win", "2.94%"},
{"Average Win", "2.93%"},
{"Average Loss", "-4.15%"},
{"Compounding Annual Return", "-5.601%"},
{"Drawdown", "5.600%"},
{"Expectancy", "-0.146"},
{"Net Profit", "-2.771%"},
{"Sharpe Ratio", "-0.49"},
{"Probabilistic Sharpe Ratio", "10.583%"},
{"Compounding Annual Return", "-6.023%"},
{"Drawdown", "5.700%"},
{"Expectancy", "-0.148"},
{"Net Profit", "-2.802%"},
{"Sharpe Ratio", "-0.501"},
{"Probabilistic Sharpe Ratio", "10.679%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.71"},
{"Alpha", "-0.043"},
{"Profit-Loss Ratio", "0.70"},
{"Alpha", "-0.045"},
{"Beta", "-0.001"},
{"Annual Standard Deviation", "0.087"},
{"Annual Standard Deviation", "0.089"},
{"Annual Variance", "0.008"},
{"Information Ratio", "0.96"},
{"Tracking Error", "0.192"},
{"Treynor Ratio", "58.394"},
{"Information Ratio", "0.966"},
{"Tracking Error", "0.195"},
{"Treynor Ratio", "55.977"},
{"Total Fees", "$14.80"},
{"Fitness Score", "0.018"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.096"},
{"Return Over Maximum Drawdown", "-0.993"},
{"Portfolio Turnover", "0.043"},
{"Sortino Ratio", "-0.103"},
{"Return Over Maximum Drawdown", "-1.063"},
{"Portfolio Turnover", "0.045"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -162,7 +157,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-290004562"}
{"OrderListHash", "79413316"}
};
}
}

View File

@@ -16,7 +16,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Orders;
@@ -46,11 +45,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -132,12 +126,7 @@ namespace QuantConnect.Algorithm.CSharp
private void AssertFutureOptionOrderExercise(OrderEvent orderEvent, Security future, Security optionContract)
{
// We expect the liquidation to occur on the day of the delisting (while the market is open),
// but currently we liquidate at the next market open (AAPL open) which happens to be
// at 9:30:00 Eastern Time. For unknown reasons, the delisting happens two minutes after the
// market open.
// Read more about the issue affecting this test here: https://github.com/QuantConnect/Lean/issues/4980
var expectedLiquidationTimeUtc = new DateTime(2020, 6, 22, 13, 32, 0);
var expectedLiquidationTimeUtc = new DateTime(2020, 6, 19, 20, 0, 0);
if (orderEvent.Direction == OrderDirection.Sell && future.Holdings.Quantity != 0)
{
@@ -214,31 +203,31 @@ namespace QuantConnect.Algorithm.CSharp
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "3"},
{"Average Win", "1.25%"},
{"Average Win", "1.22%"},
{"Average Loss", "-7.42%"},
{"Compounding Annual Return", "-12.413%"},
{"Compounding Annual Return", "-13.222%"},
{"Drawdown", "6.300%"},
{"Expectancy", "-0.416"},
{"Net Profit", "-6.257%"},
{"Sharpe Ratio", "-1.325"},
{"Probabilistic Sharpe Ratio", "0.004%"},
{"Expectancy", "-0.417"},
{"Net Profit", "-6.282%"},
{"Sharpe Ratio", "-1.345"},
{"Probabilistic Sharpe Ratio", "0.005%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.17"},
{"Alpha", "-0.102"},
{"Alpha", "-0.105"},
{"Beta", "-0.003"},
{"Annual Standard Deviation", "0.076"},
{"Annual Standard Deviation", "0.078"},
{"Annual Variance", "0.006"},
{"Information Ratio", "0.673"},
{"Tracking Error", "0.188"},
{"Treynor Ratio", "33.559"},
{"Information Ratio", "0.678"},
{"Tracking Error", "0.191"},
{"Treynor Ratio", "33.18"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.205"},
{"Return Over Maximum Drawdown", "-1.983"},
{"Portfolio Turnover", "0.023"},
{"Sortino Ratio", "-0.217"},
{"Return Over Maximum Drawdown", "-2.105"},
{"Portfolio Turnover", "0.024"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -252,7 +241,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "23301049"}
{"OrderListHash", "-1947859887"}
};
}
}

View File

@@ -42,11 +42,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -166,31 +161,31 @@ namespace QuantConnect.Algorithm.CSharp
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "3"},
{"Average Win", "28.04%"},
{"Average Win", "27.44%"},
{"Average Loss", "-62.81%"},
{"Compounding Annual Return", "-78.165%"},
{"Drawdown", "52.400%"},
{"Expectancy", "-0.277"},
{"Net Profit", "-52.379%"},
{"Sharpe Ratio", "-0.865"},
{"Probabilistic Sharpe Ratio", "0.019%"},
{"Compounding Annual Return", "-80.444%"},
{"Drawdown", "52.600%"},
{"Expectancy", "-0.282"},
{"Net Profit", "-52.604%"},
{"Sharpe Ratio", "-0.867"},
{"Probabilistic Sharpe Ratio", "0.021%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.45"},
{"Alpha", "-0.596"},
{"Beta", "-0.031"},
{"Annual Standard Deviation", "0.681"},
{"Annual Variance", "0.463"},
{"Information Ratio", "-0.514"},
{"Tracking Error", "0.703"},
{"Treynor Ratio", "18.748"},
{"Profit-Loss Ratio", "0.44"},
{"Alpha", "-0.611"},
{"Beta", "-0.033"},
{"Annual Standard Deviation", "0.695"},
{"Annual Variance", "0.484"},
{"Information Ratio", "-0.513"},
{"Tracking Error", "0.718"},
{"Treynor Ratio", "18.473"},
{"Total Fees", "$66.60"},
{"Fitness Score", "0.157"},
{"Fitness Score", "0.162"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.133"},
{"Return Over Maximum Drawdown", "-1.492"},
{"Portfolio Turnover", "0.411"},
{"Sortino Ratio", "-0.136"},
{"Return Over Maximum Drawdown", "-1.529"},
{"Portfolio Turnover", "0.427"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -204,7 +199,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "151392833"}
{"OrderListHash", "1153646593"}
};
}
}

View File

@@ -26,11 +26,13 @@ namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This regression algorithm tests Out of The Money (OTM) future option expiry for calls.
/// We expect 1 order from the algorithm, which are:
/// We expect 2 orders from the algorithm, which are:
///
/// * Initial entry, buy ES Call Option (expiring OTM)
/// - contract expires worthless, not exercised, so never opened a position in the underlying
///
/// * Liquidation of worthless ES call option (expiring OTM)
///
/// Additionally, we test delistings for future options and assert that our
/// portfolio holdings reflect the orders the algorithm has submitted.
/// </summary>
@@ -49,11 +51,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -183,28 +180,28 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "-4.03%"},
{"Compounding Annual Return", "-8.088%"},
{"Compounding Annual Return", "-8.595%"},
{"Drawdown", "4.000%"},
{"Expectancy", "-1"},
{"Net Profit", "-4.029%"},
{"Sharpe Ratio", "-1.274"},
{"Probabilistic Sharpe Ratio", "0.015%"},
{"Sharpe Ratio", "-1.294"},
{"Probabilistic Sharpe Ratio", "0.017%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "-0.066"},
{"Alpha", "-0.069"},
{"Beta", "-0.002"},
{"Annual Standard Deviation", "0.052"},
{"Annual Standard Deviation", "0.053"},
{"Annual Variance", "0.003"},
{"Information Ratio", "0.9"},
{"Tracking Error", "0.179"},
{"Treynor Ratio", "28.537"},
{"Information Ratio", "0.911"},
{"Tracking Error", "0.182"},
{"Treynor Ratio", "28.46"},
{"Total Fees", "$3.70"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.183"},
{"Return Over Maximum Drawdown", "-2.007"},
{"Sortino Ratio", "-0.195"},
{"Return Over Maximum Drawdown", "-2.134"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -219,7 +216,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1116221764"}
{"OrderListHash", "-1004351165"}
};
}
}

View File

@@ -0,0 +1,147 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This regression test tests for the loading of futures options contracts with a contract month of 2020-03 can live
/// and be loaded from the same ZIP file that the 2020-04 contract month Future Option contract lives in.
/// </summary>
public class FutureOptionMultipleContractsInDifferentContractMonthsWithSameUnderlyingFutureRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private readonly Dictionary<Symbol, bool> _expectedSymbols = new Dictionary<Symbol, bool>
{
{ CreateOption(new DateTime(2020, 3, 26), OptionRight.Call, 1650), false },
{ CreateOption(new DateTime(2020, 3, 26), OptionRight.Put, 1540), false },
{ CreateOption(new DateTime(2020, 2, 25), OptionRight.Call, 1600), false },
{ CreateOption(new DateTime(2020, 2, 25), OptionRight.Put, 1545), false }
};
public override void Initialize()
{
SetStartDate(2020, 1, 5);
SetEndDate(2020, 1, 6);
var goldFutures = AddFuture("GC", Resolution.Minute, Market.COMEX);
goldFutures.SetFilter(0, 365);
AddFutureOption(goldFutures.Symbol);
}
public override void OnData(Slice data)
{
foreach (var symbol in data.QuoteBars.Keys)
{
if (_expectedSymbols.ContainsKey(symbol))
{
var invested = _expectedSymbols[symbol];
if (!invested)
{
MarketOrder(symbol, 1);
}
_expectedSymbols[symbol] = true;
}
}
}
public override void OnEndOfAlgorithm()
{
var notEncountered = _expectedSymbols.Where(kvp => !kvp.Value).ToList();
if (notEncountered.Any())
{
throw new Exception($"Expected all Symbols encountered and invested in, but the following were not found: {string.Join(", ", notEncountered.Select(kvp => kvp.Value.ToStringInvariant()))}");
}
if (!Portfolio.Invested)
{
throw new Exception("Expected holdings at the end of algorithm, but none were found.");
}
}
private static Symbol CreateOption(DateTime expiry, OptionRight optionRight, decimal strikePrice)
{
return QuantConnect.Symbol.CreateOption(
QuantConnect.Symbol.CreateFuture("GC", Market.COMEX, new DateTime(2020, 4, 28)),
Market.COMEX,
OptionStyle.American,
optionRight,
strikePrice,
expiry);
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "4"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "-8.289%"},
{"Drawdown", "3.500%"},
{"Expectancy", "0"},
{"Net Profit", "-0.047%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "-14.395"},
{"Tracking Error", "0.043"},
{"Treynor Ratio", "0"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.019"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "-194.237"},
{"Portfolio Turnover", "0.038"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1328857323"}
};
}
}

View File

@@ -46,11 +46,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -132,12 +127,7 @@ namespace QuantConnect.Algorithm.CSharp
private void AssertFutureOptionOrderExercise(OrderEvent orderEvent, Security future, Security optionContract)
{
// We expect the liquidation to occur on the day of the delisting (while the market is open),
// but currently we liquidate at the next market open (AAPL open) which happens to be
// at 9:30:00 Eastern Time. For unknown reasons, the delisting happens two minutes after the
// market open.
// Read more about the issue affecting this test here: https://github.com/QuantConnect/Lean/issues/4980
var expectedLiquidationTimeUtc = new DateTime(2020, 6, 22, 13, 32, 0);
var expectedLiquidationTimeUtc = new DateTime(2020, 6, 19, 20, 0, 0);
if (orderEvent.Direction == OrderDirection.Buy && future.Holdings.Quantity != 0)
{
@@ -214,31 +204,31 @@ namespace QuantConnect.Algorithm.CSharp
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "3"},
{"Average Win", "4.18%"},
{"Average Win", "4.15%"},
{"Average Loss", "-8.27%"},
{"Compounding Annual Return", "-8.879%"},
{"Drawdown", "4.400%"},
{"Expectancy", "-0.247"},
{"Net Profit", "-4.432%"},
{"Sharpe Ratio", "-1.391"},
{"Compounding Annual Return", "-9.486%"},
{"Drawdown", "4.500%"},
{"Expectancy", "-0.249"},
{"Net Profit", "-4.457%"},
{"Sharpe Ratio", "-1.412"},
{"Probabilistic Sharpe Ratio", "0.002%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.51"},
{"Alpha", "-0.073"},
{"Profit-Loss Ratio", "0.50"},
{"Alpha", "-0.076"},
{"Beta", "-0.002"},
{"Annual Standard Deviation", "0.052"},
{"Annual Standard Deviation", "0.053"},
{"Annual Variance", "0.003"},
{"Information Ratio", "0.863"},
{"Tracking Error", "0.179"},
{"Treynor Ratio", "38.46"},
{"Information Ratio", "0.871"},
{"Tracking Error", "0.183"},
{"Treynor Ratio", "37.798"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.224"},
{"Return Over Maximum Drawdown", "-2.003"},
{"Portfolio Turnover", "0.023"},
{"Sortino Ratio", "-0.238"},
{"Return Over Maximum Drawdown", "-2.128"},
{"Portfolio Turnover", "0.024"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -252,7 +242,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-675079082"}
{"OrderListHash", "1657883738"}
};
}
}

View File

@@ -26,11 +26,13 @@ namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This regression algorithm tests Out of The Money (OTM) future option expiry for puts.
/// We expect 1 order from the algorithm, which are:
/// We expect 2 orders from the algorithm, which are:
///
/// * Initial entry, buy ES Put Option (expiring OTM)
/// - contract expires worthless, not exercised, so never opened a position in the underlying
///
/// * Liquidation of worthless ES Put OTM contract
///
/// Additionally, we test delistings for future options and assert that our
/// portfolio holdings reflect the orders the algorithm has submitted.
/// </summary>
@@ -48,11 +50,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -182,28 +179,28 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "-5.12%"},
{"Compounding Annual Return", "-10.212%"},
{"Compounding Annual Return", "-10.844%"},
{"Drawdown", "5.100%"},
{"Expectancy", "-1"},
{"Net Profit", "-5.116%"},
{"Sharpe Ratio", "-1.26"},
{"Probabilistic Sharpe Ratio", "0.016%"},
{"Sharpe Ratio", "-1.28"},
{"Probabilistic Sharpe Ratio", "0.017%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "-0.084"},
{"Alpha", "-0.086"},
{"Beta", "-0.003"},
{"Annual Standard Deviation", "0.066"},
{"Annual Standard Deviation", "0.067"},
{"Annual Variance", "0.004"},
{"Information Ratio", "0.785"},
{"Tracking Error", "0.184"},
{"Treynor Ratio", "28.158"},
{"Information Ratio", "0.794"},
{"Tracking Error", "0.187"},
{"Treynor Ratio", "28.078"},
{"Total Fees", "$3.70"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.181"},
{"Return Over Maximum Drawdown", "-1.995"},
{"Sortino Ratio", "-0.193"},
{"Return Over Maximum Drawdown", "-2.12"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -218,7 +215,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "515984318"}
{"OrderListHash", "-49211561"}
};
}
}

View File

@@ -46,11 +46,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -194,29 +189,29 @@ namespace QuantConnect.Algorithm.CSharp
{
{"Total Trades", "3"},
{"Average Win", "10.05%"},
{"Average Loss", "-5.60%"},
{"Compounding Annual Return", "8.121%"},
{"Average Loss", "-5.63%"},
{"Compounding Annual Return", "8.619%"},
{"Drawdown", "0.500%"},
{"Expectancy", "0.396"},
{"Net Profit", "3.880%"},
{"Sharpe Ratio", "1.192"},
{"Probabilistic Sharpe Ratio", "58.203%"},
{"Expectancy", "0.393"},
{"Net Profit", "3.855%"},
{"Sharpe Ratio", "1.212"},
{"Probabilistic Sharpe Ratio", "59.039%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "1.79"},
{"Alpha", "0.069"},
{"Alpha", "0.071"},
{"Beta", "0.003"},
{"Annual Standard Deviation", "0.057"},
{"Annual Standard Deviation", "0.058"},
{"Annual Variance", "0.003"},
{"Information Ratio", "1.641"},
{"Tracking Error", "0.18"},
{"Treynor Ratio", "22.101"},
{"Information Ratio", "1.663"},
{"Tracking Error", "0.183"},
{"Treynor Ratio", "22.266"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.021"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "17.255"},
{"Return Over Maximum Drawdown", "18.319"},
{"Portfolio Turnover", "0.021"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -231,7 +226,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1118389718"}
{"OrderListHash", "-120798310"}
};
}
}

View File

@@ -26,11 +26,13 @@ namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This regression algorithm tests Out of The Money (OTM) future option expiry for short calls.
/// We expect 1 order from the algorithm, which are:
/// We expect 2 orders from the algorithm, which are:
///
/// * Initial entry, sell ES Call Option (expiring OTM)
/// - Profit the option premium, since the option was not assigned.
///
/// * Liquidation of ES call OTM contract on the last trade date
///
/// Additionally, we test delistings for future options and assert that our
/// portfolio holdings reflect the orders the algorithm has submitted.
/// </summary>
@@ -45,11 +47,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -176,28 +173,28 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "2"},
{"Average Win", "1.81%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "3.745%"},
{"Compounding Annual Return", "3.996%"},
{"Drawdown", "0.000%"},
{"Expectancy", "0"},
{"Net Profit", "1.809%"},
{"Sharpe Ratio", "1.292"},
{"Probabilistic Sharpe Ratio", "65.890%"},
{"Sharpe Ratio", "1.315"},
{"Probabilistic Sharpe Ratio", "66.818%"},
{"Loss Rate", "0%"},
{"Win Rate", "100%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.031"},
{"Alpha", "0.032"},
{"Beta", "0.001"},
{"Annual Standard Deviation", "0.024"},
{"Annual Variance", "0.001"},
{"Information Ratio", "1.496"},
{"Tracking Error", "0.173"},
{"Treynor Ratio", "27.281"},
{"Information Ratio", "1.516"},
{"Tracking Error", "0.176"},
{"Treynor Ratio", "27.339"},
{"Total Fees", "$3.70"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "95.176"},
{"Return Over Maximum Drawdown", "101.571"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -212,7 +209,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1364902860"}
{"OrderListHash", "-404864705"}
};
}
}

View File

@@ -46,11 +46,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -191,30 +186,30 @@ namespace QuantConnect.Algorithm.CSharp
{
{"Total Trades", "3"},
{"Average Win", "10.18%"},
{"Average Loss", "-8.02%"},
{"Compounding Annual Return", "2.773%"},
{"Average Loss", "-8.05%"},
{"Compounding Annual Return", "2.902%"},
{"Drawdown", "0.500%"},
{"Expectancy", "0.135"},
{"Net Profit", "1.343%"},
{"Sharpe Ratio", "0.939"},
{"Probabilistic Sharpe Ratio", "46.842%"},
{"Expectancy", "0.133"},
{"Net Profit", "1.318%"},
{"Sharpe Ratio", "0.95"},
{"Probabilistic Sharpe Ratio", "47.360%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "1.27"},
{"Alpha", "0.023"},
{"Alpha", "0.024"},
{"Beta", "0.002"},
{"Annual Standard Deviation", "0.025"},
{"Annual Variance", "0.001"},
{"Information Ratio", "1.45"},
{"Tracking Error", "0.173"},
{"Treynor Ratio", "14.62"},
{"Information Ratio", "1.467"},
{"Tracking Error", "0.176"},
{"Treynor Ratio", "14.729"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.021"},
{"Fitness Score", "0.022"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "5.815"},
{"Portfolio Turnover", "0.022"},
{"Return Over Maximum Drawdown", "6.087"},
{"Portfolio Turnover", "0.023"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -228,7 +223,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "980293281"}
{"OrderListHash", "-1218521879"}
};
}
}

View File

@@ -26,11 +26,13 @@ namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// This regression algorithm tests Out of The Money (OTM) future option expiry for short puts.
/// We expect 1 order from the algorithm, which are:
/// We expect 2 order from the algorithm, which are:
///
/// * Initial entry, sell ES Put Option (expiring OTM)
/// - Profit the option premium, since the option was not assigned.
///
/// * Liquidation of ES put OTM contract on the last trade date
///
/// Additionally, we test delistings for future options and assert that our
/// portfolio holdings reflect the orders the algorithm has submitted.
/// </summary>
@@ -45,11 +47,6 @@ namespace QuantConnect.Algorithm.CSharp
SetStartDate(2020, 1, 5);
SetEndDate(2020, 6, 30);
// We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
// which causes delisting events to never be processed, thus leading to options that might never
// be exercised until the next data point arrives.
AddEquity("AAPL", Resolution.Daily);
_es19m20 = AddFutureContract(
QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -175,28 +172,28 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "2"},
{"Average Win", "3.28%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "6.852%"},
{"Compounding Annual Return", "7.317%"},
{"Drawdown", "0.000%"},
{"Expectancy", "0"},
{"Net Profit", "3.284%"},
{"Sharpe Ratio", "1.319"},
{"Probabilistic Sharpe Ratio", "66.574%"},
{"Sharpe Ratio", "1.343"},
{"Probabilistic Sharpe Ratio", "67.503%"},
{"Loss Rate", "0%"},
{"Win Rate", "100%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.058"},
{"Alpha", "0.06"},
{"Beta", "0.002"},
{"Annual Standard Deviation", "0.043"},
{"Annual Standard Deviation", "0.044"},
{"Annual Variance", "0.002"},
{"Information Ratio", "1.614"},
{"Tracking Error", "0.176"},
{"Treynor Ratio", "28.2"},
{"Information Ratio", "1.636"},
{"Tracking Error", "0.179"},
{"Treynor Ratio", "28.253"},
{"Total Fees", "$3.70"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "150.252"},
{"Return Over Maximum Drawdown", "160.505"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -211,7 +208,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-418839052"}
{"OrderListHash", "-2019978457"}
};
}
}

View File

@@ -0,0 +1,198 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Orders;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Tests delistings for Futures and Futures Options to ensure that they are delisted at the expected times.
/// </summary>
public class FuturesAndFuturesOptionsExpiryTimeAndLiquidationRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private bool _invested;
private int _liquidated;
private int _delistingsReceived;
private Symbol _esFuture;
private Symbol _esFutureOption;
private readonly DateTime _expectedExpiryWarningTime = new DateTime(2020, 6, 19);
private readonly DateTime _expectedExpiryDelistingTime = new DateTime(2020, 6, 20);
private readonly DateTime _expectedLiquidationTime = new DateTime(2020, 6, 19, 16, 0, 0);
public override void Initialize()
{
SetStartDate(2020, 1, 5);
SetEndDate(2020, 12, 1);
SetCash(100000);
var es = QuantConnect.Symbol.CreateFuture(
Futures.Indices.SP500EMini,
Market.CME,
new DateTime(2020, 6, 19));
var esOption = QuantConnect.Symbol.CreateOption(
es,
Market.CME,
OptionStyle.American,
OptionRight.Put,
3400m,
new DateTime(2020, 6, 19));
_esFuture = AddFutureContract(es, Resolution.Minute).Symbol;
_esFutureOption = AddFutureOptionContract(esOption, Resolution.Minute).Symbol;
}
public override void OnData(Slice data)
{
foreach (var delisting in data.Delistings.Values)
{
// Two warnings and two delisted events should be received for a grand total of 4 events.
_delistingsReceived++;
if (delisting.Type == DelistingType.Warning &&
delisting.Time != _expectedExpiryWarningTime)
{
throw new Exception($"Expiry warning with time {delisting.Time} but is expected to be {_expectedExpiryWarningTime}");
}
if (delisting.Type == DelistingType.Warning && delisting.Time != Time.Date)
{
throw new Exception($"Delisting warning received at an unexpected date: {Time} - expected {delisting.Time}");
}
if (delisting.Type == DelistingType.Delisted &&
delisting.Time != _expectedExpiryDelistingTime)
{
throw new Exception($"Delisting occurred at unexpected time: {delisting.Time} - expected: {_expectedExpiryDelistingTime}");
}
if (delisting.Type == DelistingType.Delisted &&
delisting.Time != Time.Date)
{
throw new Exception($"Delisting notice received at an unexpected date: {Time} - expected {delisting.Time}");
}
}
if (!_invested &&
(data.Bars.ContainsKey(_esFuture) || data.QuoteBars.ContainsKey(_esFuture)) &&
(data.Bars.ContainsKey(_esFutureOption) || data.QuoteBars.ContainsKey(_esFutureOption)))
{
_invested = true;
MarketOrder(_esFuture, 1);
MarketOrder(_esFutureOption, 1);
}
}
public override void OnOrderEvent(OrderEvent orderEvent)
{
if (orderEvent.Direction != OrderDirection.Sell || orderEvent.Status != OrderStatus.Filled)
{
return;
}
// * Future Liquidation
// * Future Option Exercise
// * We expect NO Underlying Future Liquidation because we already hold a Long future position so the FOP Put selling leaves us breakeven
_liquidated++;
if (orderEvent.Symbol.SecurityType == SecurityType.FutureOption && _expectedLiquidationTime != Time)
{
throw new Exception($"Expected to liquidate option {orderEvent.Symbol} at {_expectedLiquidationTime}, instead liquidated at {Time}");
}
if (orderEvent.Symbol.SecurityType == SecurityType.Future && _expectedLiquidationTime.AddMinutes(-1) != Time && _expectedLiquidationTime != Time)
{
throw new Exception($"Expected to liquidate future {orderEvent.Symbol} at {_expectedLiquidationTime} (+1 minute), instead liquidated at {Time}");
}
}
public override void OnEndOfAlgorithm()
{
if (!_invested)
{
throw new Exception("Never invested in ES futures and FOPs");
}
if (_delistingsReceived != 4)
{
throw new Exception($"Expected 4 delisting events received, found: {_delistingsReceived}");
}
if (_liquidated != 2)
{
throw new Exception($"Expected 3 liquidation events, found {_liquidated}");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "3"},
{"Average Win", "10.15%"},
{"Average Loss", "-11.34%"},
{"Compounding Annual Return", "-5.054%"},
{"Drawdown", "2.300%"},
{"Expectancy", "-0.053"},
{"Net Profit", "-2.345%"},
{"Sharpe Ratio", "-1.289"},
{"Probabilistic Sharpe Ratio", "0.028%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.89"},
{"Alpha", "-0.031"},
{"Beta", "-0.001"},
{"Annual Standard Deviation", "0.024"},
{"Annual Variance", "0.001"},
{"Information Ratio", "1.155"},
{"Tracking Error", "0.176"},
{"Treynor Ratio", "29.128"},
{"Total Fees", "$7.40"},
{"Fitness Score", "0.007"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.354"},
{"Return Over Maximum Drawdown", "-2.155"},
{"Portfolio Turnover", "0.024"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "2109976361"}
};
}
}

View File

@@ -35,7 +35,7 @@ namespace QuantConnect.Algorithm.CSharp
SetCash(100000);
SetBenchmark(x => 0);
_symbol = AddEquity("VXX", Resolution.Hour).Symbol;
_symbol = AddEquity("VXX.1", Resolution.Hour).Symbol;
}
public void OnData(TradeBars tradeBars)
@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1795141360"}
{"OrderListHash", "105744170"}
};
}
}

View File

@@ -116,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Annual Variance", "0.013"},
{"Information Ratio", "-0.234"},
{"Tracking Error", "0.214"},
{"Treynor Ratio", "-0.775"},
{"Treynor Ratio", "-0.774"},
{"Total Fees", "$443.74"},
{"Fitness Score", "0.013"},
{"Kelly Criterion Estimate", "0"},

View File

@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Annual Variance", "0.038"},
{"Information Ratio", "0.262"},
{"Tracking Error", "0.346"},
{"Treynor Ratio", "-0.862"},
{"Treynor Ratio", "-0.863"},
{"Total Fees", "$13.69"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},

View File

@@ -77,7 +77,7 @@ namespace QuantConnect.Algorithm.CSharp
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "22"},
{"Total Trades", "24"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
@@ -101,8 +101,8 @@ namespace QuantConnect.Algorithm.CSharp
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "-50.218"},
{"Portfolio Turnover", "6.713"},
{"Return Over Maximum Drawdown", "-50.725"},
{"Portfolio Turnover", "8.14"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -116,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1597098916"}
{"OrderListHash", "-2017313615"}
};
}
}

View File

@@ -160,7 +160,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "2037056244"}
{"OrderListHash", "1393663292"}
};
}
}

View File

@@ -0,0 +1,160 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Linq;
using QuantConnect.Interfaces;
using QuantConnect.Securities;
using System.Collections.Generic;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Algorithm.Framework.Selection;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm reproducing GH issue #3914 where the option chain subscriptions wouldn't get removed
/// </summary>
public class OptionChainSubscriptionRemovalRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private int _optionCount;
public override void Initialize()
{
UniverseSettings.Resolution = Resolution.Minute;
SetStartDate(2014, 06, 05);
SetEndDate(2014, 06, 09);
// this line is the key of this test it changed the behavior if the resolution used
// is < that Minute which is the Option resolution
AddEquity("SPY", Resolution.Second);
SetUniverseSelection(new TestOptionUniverseSelectionModel(SelectOptionChainSymbols));
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
_optionCount += changes.AddedSecurities.Count(security => security.Symbol.SecurityType == SecurityType.Option);
Log($"{GetStatusLog()} CHANGES: {changes}");
}
public override void OnEndOfAlgorithm()
{
if (_optionCount != 30)
{
throw new Exception($"Unexpected option count {_optionCount}, expected 30");
}
}
private static IEnumerable<Symbol> SelectOptionChainSymbols(DateTime utcTime)
{
var newYorkTime = utcTime.ConvertFromUtc(TimeZones.NewYork);
if (newYorkTime.Date < new DateTime(2014, 06, 06))
{
yield return QuantConnect.Symbol.Create("TWX", SecurityType.Option, Market.USA, "?TWX");
}
if (newYorkTime.Date >= new DateTime(2014, 06, 06))
{
yield return QuantConnect.Symbol.Create("AAPL", SecurityType.Option, Market.USA, "?AAPL");
}
}
private string GetStatusLog()
{
Plot("Status", "UniverseCount", UniverseManager.Count);
Plot("Status", "SubscriptionCount", SubscriptionManager.Subscriptions.Count());
Plot("Status", "ActiveSymbolsCount", UniverseManager.ActiveSecurities.Count);
// why 50? we select 15 option contracts, which add trade/quote/openInterest = 45 + SPY & underlying trade/quote + universe subscription => 50
if (SubscriptionManager.Subscriptions.Count() > 50)
{
throw new Exception("Subscriptions aren't getting removed as expected!");
}
return $"{Time} | UniverseCount {UniverseManager.Count}. " +
$"SubscriptionCount {SubscriptionManager.Subscriptions.Count()}. " +
$"ActiveSymbols {string.Join(",", UniverseManager.ActiveSecurities.Keys)}";
}
class TestOptionUniverseSelectionModel : OptionUniverseSelectionModel
{
public TestOptionUniverseSelectionModel(Func<DateTime, IEnumerable<Symbol>> optionChainSymbolSelector)
: base(TimeSpan.FromDays(1), optionChainSymbolSelector)
{
}
protected override OptionFilterUniverse Filter(OptionFilterUniverse filter)
{
return filter.BackMonth().Contracts(filter.Take(15));
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "-25.506"},
{"Tracking Error", "0.042"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "371857150"}
};
}
}

View File

@@ -0,0 +1,252 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm which reproduces GH issue #5079, where option chain universes would sometimes not get removed from the
/// UniverseManager causing new universes not to get added
/// </summary>
public class OptionChainUniverseRemovalRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
// initialize our changes to nothing
private SecurityChanges _changes = SecurityChanges.None;
private int _optionCount;
private Symbol _lastEquityAdded;
private Symbol _aapl;
public override void Initialize()
{
_aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
UniverseSettings.Resolution = Resolution.Minute;
SetStartDate(2014, 06, 06);
SetEndDate(2014, 06, 10);
var toggle = true;
var selectionUniverse = AddUniverse(enumerable =>
{
if (toggle)
{
toggle = false;
return new []{ _aapl };
}
toggle = true;
return Enumerable.Empty<Symbol>();
});
AddUniverseOptions(selectionUniverse, universe =>
{
if (universe.Underlying == null)
{
throw new Exception("Underlying data point is null! This shouldn't happen, each OptionChainUniverse handles and should provide this");
}
return universe.IncludeWeeklys()
.BackMonth() // back month so that they don't get removed because of being delisted
.Contracts(universe.Take(5));
});
}
public override void OnData(Slice data)
{
// if we have no changes, do nothing
if (_changes == SecurityChanges.None ||
_changes.AddedSecurities.Any(security => security.Price == 0))
{
return;
}
Debug(GetStatusLog());
foreach (var security in _changes.AddedSecurities)
{
if (!security.Symbol.HasUnderlying)
{
_lastEquityAdded = security.Symbol;
}
else
{
// options added should all match prev added security
if (security.Symbol.Underlying != _lastEquityAdded)
{
throw new Exception($"Unexpected symbol added {security.Symbol}");
}
_optionCount++;
}
}
_changes = SecurityChanges.None;
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
Debug($"{GetStatusLog()}. CHANGES {changes}");
if (Time.Day == 6)
{
if (Time.Hour != 0 && Time.Hour != 9)
{
throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}");
}
if (changes.RemovedSecurities.Count != 0)
{
throw new Exception($"Unexpected removals: {changes}");
}
if (Time.Hour == 0)
{
// first we expect the equity to get Added
if (changes.AddedSecurities.Count != 1 || changes.AddedSecurities[0].Symbol != _aapl)
{
throw new Exception($"Unexpected SecurityChanges: {changes}");
}
}
else
{
// later we expect the options to be Added
if (changes.AddedSecurities.Count != 5 || changes.AddedSecurities.Any(security => security.Symbol.SecurityType != SecurityType.Option))
{
throw new Exception($"Unexpected SecurityChanges: {changes}");
}
}
}
// We expect the equity to get Removed
else if (Time.Day == 7)
{
if (Time.Hour != 0)
{
throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}");
}
if (changes.AddedSecurities.Count != 0)
{
throw new Exception($"Unexpected additions: {changes}");
}
if (changes.RemovedSecurities.Count != 1 || changes.RemovedSecurities[0].Symbol != _aapl)
{
throw new Exception($"Unexpected SecurityChanges: {changes}");
}
}
// We expect the options to get Removed, happens in the next loop after removing the equity
else if (Time.Day == 9)
{
if (Time.Hour != 0)
{
throw new Exception($"Unexpected SecurityChanges time: {Time} {changes}");
}
// later we expect the options to be Removed
if (changes.RemovedSecurities.Count != 6
// the removal of the raw underlying subscription from the option chain universe
|| changes.RemovedSecurities.Single(security => security.Symbol.SecurityType != SecurityType.Option).Symbol != _aapl
// the removal of the 5 option contracts
|| changes.RemovedSecurities.Count(security => security.Symbol.SecurityType == SecurityType.Option) != 5)
{
throw new Exception($"Unexpected SecurityChanges: {changes}");
}
}
_changes += changes;
}
public override void OnEndOfAlgorithm()
{
if (_optionCount == 0)
{
throw new Exception("Option universe chain did not add any option!");
}
if (UniverseManager.Any(pair => pair.Value.DisposeRequested))
{
throw new Exception("There shouldn't be any disposed universe, they should be removed and replaced by new universes");
}
}
private string GetStatusLog()
{
Plot("Status", "UniverseCount", UniverseManager.Count);
Plot("Status", "SubscriptionCount", SubscriptionManager.Subscriptions.Count());
Plot("Status", "ActiveSymbolsCount", UniverseManager.ActiveSecurities.Count);
return $"{Time} | UniverseCount {UniverseManager.Count}. " +
$"SubscriptionCount {SubscriptionManager.Subscriptions.Count()}. " +
$"ActiveSymbols {string.Join(",", UniverseManager.ActiveSecurities.Keys)}";
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "0"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0"},
{"Annual Variance", "0"},
{"Information Ratio", "-9.31"},
{"Tracking Error", "0.008"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Return Over Maximum Drawdown", "79228162514264337593543950335"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "371857150"}
};
}
}

View File

@@ -161,7 +161,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1726463684"}
{"OrderListHash", "-1004315474"}
};
}
}

View File

@@ -40,14 +40,14 @@ namespace QuantConnect.Algorithm.CSharp
SetEndDate(2013, 07, 02);
SetCash(1000000);
var option = AddOption("FOXA");
var option = AddOption("TFCFA");
_optionSymbol = option.Symbol;
// set our strike/expiry filter for this option chain
option.SetFilter(-1, +1, TimeSpan.Zero, TimeSpan.MaxValue);
// use the underlying equity as the benchmark
SetBenchmark("FOXA");
SetBenchmark("TFCFA");
}
/// <summary>
@@ -182,7 +182,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-932374"}
{"OrderListHash", "-1383033718"}
};
}
}

View File

@@ -1,95 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{39A81C16-A1E8-425E-A8F2-1433ADB80228}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Algorithm.CSharp</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.CSharp</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>net462</TargetFramework>
<LangVersion>6</LangVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accord, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.3.6.0\lib\net462\Accord.dll</HintPath>
</Reference>
<Reference Include="Accord.Fuzzy, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Fuzzy.3.6.0\lib\net462\Accord.Fuzzy.dll</HintPath>
</Reference>
<Reference Include="Accord.MachineLearning, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.MachineLearning.3.6.0\lib\net462\Accord.MachineLearning.dll</HintPath>
</Reference>
<Reference Include="Accord.Math, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Math.3.6.0\lib\net462\Accord.Math.dll</HintPath>
</Reference>
<Reference Include="Accord.Math.Core, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Math.3.6.0\lib\net462\Accord.Math.Core.dll</HintPath>
</Reference>
<Reference Include="Accord.Statistics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Statistics.3.6.0\lib\net462\Accord.Statistics.dll</HintPath>
</Reference>
<Reference Include="DynamicInterop, Version=0.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DynamicInterop.0.7.4\lib\net40\DynamicInterop.dll</HintPath>
</Reference>
<Reference Include="MathNet.Numerics, Version=3.19.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.3.19.0\lib\net40\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="RDotNet, Version=1.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\R.NET.Community.1.6.5\lib\net40\RDotNet.dll</HintPath>
</Reference>
<Reference Include="RDotNet.NativeLibrary, Version=1.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\R.NET.Community.1.6.5\lib\net40\RDotNet.NativeLibrary.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
@@ -99,14 +33,9 @@
<IsLinux Condition="'$(IsWindows)' != 'true' AND '$(IsOSX)' != 'true' AND '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugDocker|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>portable</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Target Name="PrintRID" BeforeTargets="Build">
<Message Text="IsWindows $(IsWindows)" Importance="high" />
@@ -118,367 +47,58 @@
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AddAlphaModelAlgorithm.cs" />
<Compile Include="CustomBuyingPowerModelAlgorithm.cs" />
<Compile Include="AddFutureOptionContractDataStreamingRegressionAlgorithm.cs" />
<Compile Include="AddFutureOptionSingleOptionChainSelectedInUniverseFilterRegressionAlgorithm.cs" />
<Compile Include="AddOptionContractExpiresRegressionAlgorithm.cs" />
<Compile Include="AltData\QuiverWallStreetBetsDataAlgorithm.cs" />
<Compile Include="FutureOptionCallITMGreeksExpiryRegressionAlgorithm.cs" />
<Compile Include="OnOrderEventExceptionRegression.cs" />
<Compile Include="FutureOptionCallITMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionCallOTMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionPutITMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionPutOTMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionBuySellCallIntradayRegressionAlgorithm.cs" />
<Compile Include="FutureOptionShortCallITMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionShortCallOTMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionShortPutOTMExpiryRegressionAlgorithm.cs" />
<Compile Include="FutureOptionShortPutITMExpiryRegressionAlgorithm.cs" />
<Compile Include="ScaledFillForwardDataRegressionAlgorithm.cs" />
<Compile Include="DailyHistoryForDailyResolutionRegressionAlgorithm.cs" />
<Compile Include="DailyHistoryForMinuteResolutionRegressionAlgorithm.cs" />
<Compile Include="ExtendedMarketHoursHistoryRegressionAlgorithm.cs" />
<Compile Include="EquityTickQuoteAdjustedModeRegressionAlgorithm.cs" />
<Compile Include="AddOptionContractFromUniverseRegressionAlgorithm.cs" />
<Compile Include="CoarseFineOptionUniverseChainRegressionAlgorithm.cs" />
<Compile Include="OptionChainedAndUniverseSelectionRegressionAlgorithm.cs" />
<Compile Include="OptionAssignmentRegressionAlgorithm.cs" />
<Compile Include="SwitchDataModeRegressionAlgorithm.cs" />
<Compile Include="AddRemoveOptionUniverseRegressionAlgorithm.cs" />
<Compile Include="AddRemoveSecurityRegressionAlgorithm.cs" />
<Compile Include="AddRiskManagementAlgorithm.cs" />
<Compile Include="AddUniverseSelectionModelAlgorithm.cs" />
<Compile Include="AddUniverseSelectionModelCoarseAlgorithm.cs" />
<Compile Include="Alphas\GasAndCrudeOilEnergyCorrelationAlpha.cs" />
<Compile Include="Alphas\GreenblattMagicFormulaAlpha.cs" />
<Compile Include="Alphas\IntradayReversalCurrencyMarketsAlpha.cs" />
<Compile Include="Alphas\ShareClassMeanReversionAlpha.cs" />
<Compile Include="Alphas\SykesShortMicroCapAlpha.cs" />
<Compile Include="Alphas\GlobalEquityMeanReversionIBSAlpha.cs" />
<Compile Include="Alphas\MeanReversionLunchBreakAlpha.cs" />
<Compile Include="Alphas\RebalancingLeveragedETFAlpha.cs" />
<Compile Include="Alphas\TriangleExchangeRateArbitrageAlpha.cs" />
<Compile Include="Alphas\TripleLeveragedETFPairVolatilityDecayAlpha.cs" />
<Compile Include="Alphas\VixDualThrustAlpha.cs" />
<Compile Include="AltData\CachedAlternativeDataAlgorithm.cs" />
<Compile Include="AltData\BenzingaNewsAlgorithm.cs" />
<Compile Include="AltData\SECReport8KAlgorithm.cs" />
<Compile Include="AltData\SmartInsiderTransactionAlgorithm.cs" />
<Compile Include="AltData\USTreasuryYieldCurveRateAlgorithm.cs" />
<Compile Include="AltData\TradingEconomicsAlgorithm.cs" />
<Compile Include="AltData\TiingoNewsAlgorithm.cs" />
<Compile Include="AutomaticIndicatorWarmupDataTypeRegressionAlgorithm.cs" />
<Compile Include="AutomaticIndicatorWarmupRegressionAlgorithm.cs" />
<Compile Include="BacktestingBrokerageRegressionAlgorithm.cs" />
<Compile Include="ExtendedMarketTradingRegressionAlgorithm.cs" />
<Compile Include="CoarseTiingoNewsUniverseSelectionAlgorithm.cs" />
<Compile Include="DelistedFutureLiquidateRegressionAlgorithm.cs" />
<Compile Include="EmaCrossFuturesFrontMonthAlgorithm.cs" />
<Compile Include="OpenInterestFuturesRegressionAlgorithm.cs" />
<Compile Include="CustomPartialFillModelAlgorithm.cs" />
<Compile Include="EquityTradeAndQuotesRegressionAlgorithm.cs" />
<Compile Include="BasicTemplateConstituentUniverseAlgorithm.cs" />
<Compile Include="ConsolidateRegressionAlgorithm.cs" />
<Compile Include="DefaultResolutionRegressionAlgorithm.cs" />
<Compile Include="BasicPythonIntegrationTemplateAlgorithm.cs" />
<Compile Include="BasicSetAccountCurrencyAlgorithm.cs" />
<Compile Include="FineFundamentalFilteredUniverseRegressionAlgorithm.cs" />
<Compile Include="FutureSharingTickerRegressionAlgorithm.cs" />
<Compile Include="LongOnlyAlphaStreamAlgorithm.cs" />
<Compile Include="Benchmarks\SECReportBenchmarkAlgorithm.cs" />
<Compile Include="Benchmarks\SmartInsiderEventBenchmarkAlgorithm.cs" />
<Compile Include="CustomBenchmarkRegressionAlgorithm.cs" />
<Compile Include="CustomDataAddDataOnSecuritiesChangedRegressionAlgorithm.cs" />
<Compile Include="CustomDataAddDataCoarseSelectionRegressionAlgorithm.cs" />
<Compile Include="CustomDataAddDataRegressionAlgorithm.cs" />
<Compile Include="DynamicSecurityDataAlgorithm.cs" />
<Compile Include="ConfidenceWeightedFrameworkAlgorithm.cs" />
<Compile Include="AccumulativeInsightPortfolioRegressionAlgorithm.cs" />
<Compile Include="EqualWeightingPortfolioConstructionModelFutureRegressionAlgorithm.cs" />
<Compile Include="FreePortfolioValueRegressionAlgorithm.cs" />
<Compile Include="LeveragePrecedenceRegressionAlgorithm.cs" />
<Compile Include="LiquidETFUniverseFrameworkAlgorithm.cs" />
<Compile Include="MarginCallClosedMarketRegressionAlgorithm.cs" />
<Compile Include="MarginRemainingRegressionAlgorithm.cs" />
<Compile Include="NoMarginCallExpectedRegressionAlgorithm.cs" />
<Compile Include="ObjectStoreExampleAlgorithm.cs" />
<Compile Include="OrderImmutabilityRegressionAlgorithm.cs" />
<Compile Include="OrderSubmissionDataRegressionAlgorithm.cs" />
<Compile Include="RegisterIndicatorRegressionAlgorithm.cs" />
<Compile Include="ScheduledEventsOrderRegressionAlgorithm.cs" />
<Compile Include="SectorWeightingFrameworkAlgorithm.cs" />
<Compile Include="OnEndOfDayAddDataRegressionAlgorithm.cs" />
<Compile Include="PortfolioRebalanceOnCustomFuncRegressionAlgorithm.cs" />
<Compile Include="PortfolioRebalanceOnDateRulesRegressionAlgorithm.cs" />
<Compile Include="PortfolioRebalanceOnInsightChangesRegressionAlgorithm.cs" />
<Compile Include="PortfolioRebalanceOnSecurityChangesRegressionAlgorithm.cs" />
<Compile Include="ResolutionSwitchingAlgorithm.cs" />
<Compile Include="SetHoldingsFutureRegressionAlgorithm.cs" />
<Compile Include="StringToSymbolImplicitConversionRegressionAlgorithm.cs" />
<Compile Include="TimeRulesDefaultTimeZoneRegressionAlgorithm.cs" />
<Compile Include="SetHoldingsMultipleTargetsRegressionAlgorithm.cs" />
<Compile Include="SetHoldingsMarketOnOpenRegressionAlgorithm.cs" />
<Compile Include="SmartInsiderDataAlgorithm.cs" />
<Compile Include="BasicTemplateAlgorithm.cs" />
<Compile Include="Benchmarks\StatefulCoarseUniverseSelectionBenchmark.cs" />
<Compile Include="Benchmarks\StatelessCoarseUniverseSelectionBenchmark.cs" />
<Compile Include="CapmAlphaRankingFrameworkAlgorithm.cs" />
<Compile Include="CustomUniverseWithBenchmarkRegressionAlgorithm.cs" />
<Compile Include="CoarseSelectionTimeRegressionAlgorithm.cs" />
<Compile Include="CustomUniverseSelectionRegressionAlgorithm.cs" />
<Compile Include="OnEndOfDayRegressionAlgorithm.cs" />
<Compile Include="TrainingInitializeRegressionAlgorithm.cs" />
<Compile Include="TrainingExampleAlgorithm.cs" />
<Compile Include="UniverseSharingSubscriptionTradableRegressionAlgorithm.cs" />
<Compile Include="UniverseUnchangedRegressionAlgorithm.cs" />
<Compile Include="USTreasuryYieldCurveDataAlgorithm.cs" />
<Compile Include="SECReportDataAlgorithm.cs" />
<Compile Include="CustomDataUsingMapFileRegressionAlgorithm.cs" />
<Compile Include="ConstituentsUniverseDataGeneratorAlgorithm.cs" />
<Compile Include="ConstituentsUniverseRegressionAlgorithm.cs" />
<Compile Include="G10CurrencySelectionModelFrameworkAlgorithm.cs" />
<Compile Include="ExpiryHelperAlphaModelFrameworkAlgorithm.cs" />
<Compile Include="CfdTimeZonesRegressionAlgorithm.cs" />
<Compile Include="EmitInsightCryptoCashAccountType.cs" />
<Compile Include="EmitInsightsAlgorithm.cs" />
<Compile Include="EmitInsightNoAlphaModelAlgorithm.cs" />
<Compile Include="CoarseNoLookAheadBiasAlgorithm.cs" />
<Compile Include="ConvertToFrameworkAlgorithm.cs" />
<Compile Include="HistoryWithSymbolChangesRegressionAlgorithm.cs" />
<Compile Include="FeeModelNotUsingAccountCurrency.cs" />
<Compile Include="InsightWeightingFrameworkAlgorithm.cs" />
<Compile Include="MaximumPortfolioDrawdownFrameworkAlgorithm.cs" />
<Compile Include="CompositeRiskManagementModelFrameworkAlgorithm.cs" />
<Compile Include="ProcessSplitSymbolsRegressionAlgorithm.cs" />
<Compile Include="RawPricesUniverseRegressionAlgorithm.cs" />
<Compile Include="SetAccountCurrencyCashBuyingPowerModelRegressionAlgorithm.cs" />
<Compile Include="SetAccountCurrencySecurityMarginModelRegressionAlgorithm.cs" />
<Compile Include="SetCashOnDataRegressionAlgorithm.cs" />
<Compile Include="SmaCrossUniverseSelectionAlgorithm.cs" />
<Compile Include="StartingCapitalRegressionAlgorithm.cs" />
<Compile Include="StopLossOnOrderEventRegressionAlgorithm.cs" />
<Compile Include="TotalPortfolioValueRegressionAlgorithm.cs" />
<Compile Include="TradingEconomicsCalendarIndicatorAlgorithm.cs" />
<Compile Include="TrailingStopRiskFrameworkAlgorithm.cs" />
<Compile Include="BasicTemplateFuturesFrameworkAlgorithm.cs" />
<Compile Include="BasicTemplateOptionsFrameworkAlgorithm.cs" />
<Compile Include="BlackLittermanPortfolioOptimizationFrameworkAlgorithm.cs" />
<Compile Include="DailyResolutionSplitRegressionAlgorithm.cs" />
<Compile Include="MeanVarianceOptimizationFrameworkAlgorithm.cs" />
<Compile Include="TiingoPriceAlgorithm.cs" />
<Compile Include="OptionExpiryDateOnHolidayCase.cs" />
<Compile Include="OptionDataNullReferenceRegressionAlgorithm.cs" />
<Compile Include="CancelOpenOrdersRegressionAlgorithm.cs" />
<Compile Include="OptionDelistedDataRegressionAlgorithm.cs" />
<Compile Include="PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.cs" />
<Compile Include="RawPricesCoarseUniverseAlgorithm.cs" />
<Compile Include="CompositeAlphaModelFrameworkAlgorithm.cs" />
<Compile Include="SectorExposureRiskFrameworkAlgorithm.cs" />
<Compile Include="DuplicateSecurityWithBenchmarkRegressionAlgorithm.cs" />
<Compile Include="BasicTemplateCryptoAlgorithm.cs" />
<Compile Include="BasicTemplateCryptoFrameworkAlgorithm.cs" />
<Compile Include="BasicTemplateIntrinioEconomicData.cs" />
<Compile Include="BasicTemplateFrameworkAlgorithm.cs" />
<Compile Include="BasicTemplateLibrary.cs" />
<Compile Include="Benchmarks\EmptyMinute400EquityBenchmark.cs" />
<Compile Include="Benchmarks\BasicTemplateBenchmark.cs" />
<Compile Include="Benchmarks\EmptySingleSecuritySecondEquityBenchmark.cs" />
<Compile Include="CustomFrameworkModelsAlgorithm.cs" />
<Compile Include="EmaCrossUniverseSelectionFrameworkAlgorithm.cs" />
<Compile Include="FinancialAdvisorDemoAlgorithm.cs" />
<Compile Include="ForexInternalFeedOnDataHigherResolutionRegressionAlgorithm.cs" />
<Compile Include="ForexInternalFeedOnDataSameResolutionRegressionAlgorithm.cs" />
<Compile Include="RollingWindowAlgorithm.cs" />
<Compile Include="BasicTemplateDailyAlgorithm.cs" />
<Compile Include="CallingRFromCSharp.cs" />
<Compile Include="FuturesMomentumAlgorithm.cs" />
<Compile Include="BasicTemplateFuturesConsolidationAlgorithm.cs" />
<Compile Include="BasicTemplateFuturesHistoryAlgorithm.cs" />
<Compile Include="BasicTemplateMultiAssetAlgorithm.cs" />
<Compile Include="FilteredIdentityAlgorithm.cs" />
<Compile Include="OptionExerciseAssignRegressionAlgorithm.cs" />
<Compile Include="BasicTemplateOptionsFilterUniverseAlgorithm.cs" />
<Compile Include="BasicTemplateOptionsHistoryAlgorithm.cs" />
<Compile Include="BasicTemplateOptionTradesAlgorithm.cs" />
<Compile Include="OptionChainConsistencyRegressionAlgorithm.cs" />
<Compile Include="OptionOpenInterestRegressionAlgorithm.cs" />
<Compile Include="RegressionChannelAlgorithm.cs" />
<Compile Include="BasicTemplateFuturesAlgorithm.cs" />
<Compile Include="BasicTemplateOptionStrategyAlgorithm.cs" />
<Compile Include="CoarseFineFundamentalRegressionAlgorithm.cs" />
<Compile Include="CoarseFineFundamentalComboAlgorithm.cs" />
<Compile Include="FuzzyInferenceAlgorithm.cs" />
<Compile Include="OptionRenameRegressionAlgorithm.cs" />
<Compile Include="OptionSplitRegressionAlgorithm.cs" />
<Compile Include="PortfolioOptimizationNumericsAlgorithm.cs" />
<Compile Include="BasicTemplateForexAlgorithm.cs" />
<Compile Include="AccordVectorMachinesAlgorithm.cs" />
<Compile Include="BasicTemplateOptionsAlgorithm.cs" />
<Compile Include="CoarseFundamentalTop3Algorithm.cs" />
<Compile Include="CustomBenchmarkAlgorithm.cs" />
<Compile Include="CustomBrokerageMessageHandlerAlgorithm.cs" />
<Compile Include="FractionalQuantityRegressionAlgorithm.cs" />
<Compile Include="CustomDataRegressionAlgorithm.cs" />
<Compile Include="CustomDataUniverseAlgorithm.cs" />
<Compile Include="CustomModelsAlgorithm.cs" />
<Compile Include="CustomSecurityInitializerAlgorithm.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="DelistingEventsAlgorithm.cs" />
<Compile Include="DropboxBaseDataUniverseSelectionAlgorithm.cs" />
<Compile Include="HistoryAlgorithm.cs" />
<Compile Include="IndicatorWarmupAlgorithm.cs" />
<Compile Include="LimitFillRegressionAlgorithm.cs" />
<Compile Include="BasicTemplateFillForwardAlgorithm.cs" />
<Compile Include="BrokerageModelAlgorithm.cs" />
<Compile Include="BubbleAlgorithm.cs" />
<Compile Include="CustomChartingAlgorithm.cs" />
<Compile Include="CustomDataBitcoinAlgorithm.cs" />
<Compile Include="CustomDataNIFTYAlgorithm.cs" />
<Compile Include="DailyAlgorithm.cs" />
<Compile Include="DataConsolidationAlgorithm.cs" />
<Compile Include="DisplacedMovingAverageRibbon.cs" />
<Compile Include="DividendAlgorithm.cs" />
<Compile Include="ETFGlobalRotationAlgorithm.cs" />
<Compile Include="IndicatorSuiteAlgorithm.cs" />
<Compile Include="LiveFeaturesAlgorithm.cs" />
<Compile Include="OpeningBreakoutAlgorithm.cs" />
<Compile Include="DropboxUniverseSelectionAlgorithm.cs" />
<Compile Include="ParameterizedAlgorithm.cs" />
<Compile Include="HourReverseSplitRegressionAlgorithm.cs" />
<Compile Include="HourSplitRegressionAlgorithm.cs" />
<Compile Include="ScheduledUniverseSelectionModelRegressionAlgorithm.cs" />
<Compile Include="StandardDeviationExecutionModelRegressionAlgorithm.cs" />
<Compile Include="TimeInForceAlgorithm.cs" />
<Compile Include="UniverseSelectionDefinitionsAlgorithm.cs" />
<Compile Include="UniverseSharingSecurityDifferentSubscriptionRequestRegressionAlgorithm.cs" />
<Compile Include="UniverseSharingSubscriptionRequestRegressionAlgorithm.cs" />
<Compile Include="EstimizeDataAlgorithm.cs" />
<Compile Include="USEnergyInformationAdministrationAlgorithm.cs" />
<Compile Include="UserDefinedUniverseAlgorithm.cs" />
<Compile Include="VolumeWeightedAveragePriceExecutionModelRegressionAlgorithm.cs" />
<Compile Include="WarmUpAfterIntializeRegression.cs" />
<Compile Include="WarmupAlgorithm.cs" />
<Compile Include="WarmupConversionRatesRegressionAlgorithm.cs" />
<Compile Include="WarmupHistoryAlgorithm.cs" />
<Compile Include="MACDTrendAlgorithm.cs" />
<Compile Include="MarginCallEventsAlgorithm.cs" />
<Compile Include="MarketOnOpenOnCloseAlgorithm.cs" />
<Compile Include="MovingAverageCrossAlgorithm.cs" />
<Compile Include="MultipleSymbolConsolidationAlgorithm.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QuandlFuturesDataAlgorithm.cs" />
<Compile Include="QuandlImporterAlgorithm.cs" />
<Compile Include="RegressionAlgorithm.cs" />
<Compile Include="RenkoConsolidatorAlgorithm.cs" />
<Compile Include="ScheduledEventsAlgorithm.cs" />
<Compile Include="ScheduledQueuingAlgorithm.cs" />
<Compile Include="StressSymbolsAlgorithm.cs" />
<Compile Include="StressSymbols.cs" />
<Compile Include="TickDataFilteringAlgorithm.cs" />
<Compile Include="EmaCrossUniverseSelectionAlgorithm.cs" />
<Compile Include="UniverseSelectionRegressionAlgorithm.cs" />
<Compile Include="UpdateOrderLiveTestAlgorithm.cs" />
<Compile Include="UpdateOrderRegressionAlgorithm.cs" />
<Compile Include="OrderTicketDemoAlgorithm.cs" />
<Compile Include="WarmupIndicatorRegressionAlgorithm.cs" />
<Compile Include="InceptionDateSelectionRegressionAlgorithm.cs" />
<Compile Include="WeeklyUniverseSelectionRegressionAlgorithm.cs" />
<Compile Include="OptionChainProviderAlgorithm.cs" />
<Compile Include="ConstituentsQC500GeneratorAlgorithm.cs" />
<Compile Include="CustomDataIndicatorExtensionsAlgorithm.cs" />
<Compile Include="Benchmarks\ScheduledEventsBenchmark.cs" />
<Compile Include="Benchmarks\HistoryRequestBenchmark.cs" />
<Compile Include="Benchmarks\CoarseFineUniverseSelectionBenchmark.cs" />
<Compile Include="Benchmarks\IndicatorRibbonBenchmark.cs" />
<Compile Include="ZeroFeeRegressionAlgorithm.cs" />
<PackageReference Include="Accord" Version="3.6.0" />
<PackageReference Include="Accord.Fuzzy" Version="3.6.0" />
<PackageReference Include="Accord.MachineLearning" Version="3.6.0" />
<PackageReference Include="Accord.Math" Version="3.6.0" />
<PackageReference Include="Accord.Statistics" Version="3.6.0" />
<PackageReference Include="DynamicInterop" Version="0.7.4" />
<PackageReference Include="MathNet.Numerics" Version="3.19.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
<PackageReference Include="R.NET.Community" Version="1.6.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm.Framework\QuantConnect.Algorithm.Framework.csproj">
<Project>{75981418-7246-4b91-b136-482728e02901}</Project>
<Name>QuantConnect.Algorithm.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj">
<Project>{3240aca4-bdd4-4d24-ac36-bbb651c39212}</Project>
<Name>QuantConnect.Algorithm</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj">
<Project>{73fb2522-c3ed-4e47-8e3d-afad48a6b888}</Project>
<Name>QuantConnect.Indicators</Name>
</ProjectReference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
<ProjectReference Include="..\Algorithm.Framework\QuantConnect.Algorithm.Framework.csproj" />
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="DaylightSavingTimeHistoryRegressionAlgorithm.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
<Error Condition="!Exists('..\packages\Accord.3.6.0\build\Accord.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Accord.3.6.0\build\Accord.targets'))" />
</Target>
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Import Project="..\packages\Accord.3.6.0\build\Accord.targets" Condition="Exists('..\packages\Accord.3.6.0\build\Accord.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -0,0 +1,211 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Collections.Generic;
using QuantConnect.Brokerages;
using QuantConnect.Data;
using QuantConnect.Data.Shortable;
using QuantConnect.Interfaces;
using QuantConnect.Orders;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Tests that orders are denied if they exceed the max shortable quantity.
/// </summary>
public class ShortableProviderOrdersRejectedRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _spy;
private Symbol _aig;
private readonly List<OrderTicket> _ordersAllowed = new List<OrderTicket>();
private readonly List<OrderTicket> _ordersDenied = new List<OrderTicket>();
private bool _initialize;
private bool _invalidatedAllowedOrder;
private bool _invalidatedNewOrderWithPortfolioHoldings;
public override void Initialize()
{
SetStartDate(2013, 10, 4);
SetEndDate(2013, 10, 11);
SetCash(10000000);
_spy = AddEquity("SPY", Resolution.Minute).Symbol;
_aig = AddEquity("AIG", Resolution.Minute).Symbol;
SetBrokerageModel(new RegressionTestShortableBrokerageModel());
}
public override void OnData(Slice data)
{
if (!_initialize)
{
HandleOrder(LimitOrder(_spy, -1001, 10000m)); // Should be canceled, exceeds the max shortable quantity
HandleOrder(LimitOrder(_spy, -1000, 10000m)); // Allowed, orders at or below 1000 should be accepted
HandleOrder(LimitOrder(_spy, -10, 0.01m)); // Should be canceled, the total quantity we would be short would exceed the max shortable quantity.
_initialize = true;
return;
}
if (!_invalidatedAllowedOrder)
{
if (_ordersAllowed.Count != 1)
{
throw new Exception($"Expected 1 successful order, found: {_ordersAllowed.Count}");
}
if (_ordersDenied.Count != 2)
{
throw new Exception($"Expected 2 failed orders, found: {_ordersDenied.Count}");
}
var allowedOrder = _ordersAllowed[0];
var orderUpdate = new UpdateOrderFields()
{
LimitPrice = 0.01m,
Quantity = -1001,
Tag = "Testing updating and exceeding maximum quantity"
};
var response = allowedOrder.Update(orderUpdate);
if (response.ErrorCode != OrderResponseErrorCode.ExceedsShortableQuantity)
{
throw new Exception($"Expected order to fail due to exceeded shortable quantity, found: {response.ErrorCode.ToString()}");
}
var cancelResponse = allowedOrder.Cancel();
if (cancelResponse.IsError)
{
throw new Exception("Expected to be able to cancel open order after bad qty update");
}
_invalidatedAllowedOrder = true;
_ordersDenied.Clear();
_ordersAllowed.Clear();
return;
}
if (!_invalidatedNewOrderWithPortfolioHoldings)
{
HandleOrder(MarketOrder(_spy, -1000)); // Should succeed, no holdings and no open orders to stop this
var spyShares = Portfolio[_spy].Quantity;
if (spyShares != -1000m)
{
throw new Exception($"Expected -1000 shares in portfolio, found: {spyShares}");
}
HandleOrder(LimitOrder(_spy, -1, 0.01m)); // Should fail, portfolio holdings are at the max shortable quantity.
if (_ordersDenied.Count != 1)
{
throw new Exception($"Expected limit order to fail due to existing holdings, but found {_ordersDenied.Count} failures");
}
_ordersAllowed.Clear();
_ordersDenied.Clear();
HandleOrder(MarketOrder(_aig, -1001));
if (_ordersAllowed.Count != 1)
{
throw new Exception($"Expected market order of -1001 BAC to not fail");
}
_invalidatedNewOrderWithPortfolioHoldings = true;
}
}
private void HandleOrder(OrderTicket orderTicket)
{
if (orderTicket.SubmitRequest.Status == OrderRequestStatus.Error)
{
_ordersDenied.Add(orderTicket);
return;
}
_ordersAllowed.Add(orderTicket);
}
private class RegressionTestShortableProvider : LocalDiskShortableProvider
{
public RegressionTestShortableProvider() : base(SecurityType.Equity, "testbrokerage", Market.USA)
{
}
}
public class RegressionTestShortableBrokerageModel : DefaultBrokerageModel
{
public RegressionTestShortableBrokerageModel() : base()
{
ShortableProvider = new RegressionTestShortableProvider();
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "-1.719%"},
{"Drawdown", "0.100%"},
{"Expectancy", "0"},
{"Net Profit", "-0.036%"},
{"Sharpe Ratio", "-1.741"},
{"Probabilistic Sharpe Ratio", "35.789%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0.004"},
{"Beta", "-0.023"},
{"Annual Standard Deviation", "0.005"},
{"Annual Variance", "0"},
{"Information Ratio", "-2.512"},
{"Tracking Error", "0.216"},
{"Treynor Ratio", "0.367"},
{"Total Fees", "$10.01"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-4.849"},
{"Return Over Maximum Drawdown", "-21.738"},
{"Portfolio Turnover", "0.003"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1777297925"}
};
}
}

View File

@@ -0,0 +1,147 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm reproducing github issue #5191 where the symbol was removed from the cache
/// even if a subscription is still present
/// </summary>
public class UniverseSelectionSymbolCacheRemovalRegressionTest : QCAlgorithm, IRegressionAlgorithmDefinition
{
private bool _optionWasRemoved;
private Symbol _optionContract;
private Symbol _equitySymbol;
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2014, 06, 05);
SetEndDate(2014, 06, 23);
AddEquity("AAPL", Resolution.Daily);
_equitySymbol = AddEquity("TWX", Resolution.Minute).Symbol;
var contracts = OptionChainProvider.GetOptionContractList(_equitySymbol, UtcTime).ToList();
var callOptionSymbol = contracts
.Where(c => c.ID.OptionRight == OptionRight.Call)
.OrderBy(c => c.ID.Date)
.First();
_optionContract = AddOptionContract(callOptionSymbol).Symbol;
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
var symbol = SymbolCache.GetSymbol("TWX");
if (symbol == null)
{
throw new Exception("Unexpected removal of symbol from cache!");
}
foreach (var dataDelisting in data.Delistings.Where(pair => pair.Value.Type == DelistingType.Delisted))
{
if (dataDelisting.Key != _optionContract)
{
throw new Exception("Unexpected delisting event!");
}
_optionWasRemoved = true;
}
if (!Portfolio.Invested)
{
SetHoldings("AAPL", 0.1);
}
}
public override void OnEndOfAlgorithm()
{
if (!_optionWasRemoved)
{
throw new Exception("Option contract was not removed!");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "-3.072%"},
{"Drawdown", "0.400%"},
{"Expectancy", "0"},
{"Net Profit", "-0.162%"},
{"Sharpe Ratio", "-2.017"},
{"Probabilistic Sharpe Ratio", "23.009%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "-0.024"},
{"Beta", "-0.007"},
{"Annual Standard Deviation", "0.012"},
{"Annual Variance", "0"},
{"Information Ratio", "-4.487"},
{"Tracking Error", "0.053"},
{"Treynor Ratio", "3.645"},
{"Total Fees", "$1.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-3.347"},
{"Return Over Maximum Drawdown", "-8.314"},
{"Portfolio Turnover", "0.006"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "112416549"}
};
}
}

View File

@@ -25,7 +25,7 @@ namespace QuantConnect.Algorithm.CSharp
/// Regression algorithm to test warming up after initialize behavior, should throw if used outside of initialize
/// Reference GH Issue #4939
/// </summary>
public class WarmUpAfterIntializeRegression : QCAlgorithm, IRegressionAlgorithmDefinition
public class WarmUpAfterInitializeRegression : QCAlgorithm, IRegressionAlgorithmDefinition
{
public override void Initialize()
{

View File

@@ -0,0 +1,117 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System.Collections.Generic;
using QuantConnect.Benchmarks;
using QuantConnect.Brokerages;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression algorithm to test zeroed benchmark through BrokerageModel override
/// </summary>
public class ZeroedBenchmarkRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _spy;
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2013, 10, 07); //Set Start Date
SetEndDate(2013, 10, 08); //Set End Date
SetCash(100000); //Set Strategy Cash
// Add equity
_spy = AddEquity("SPY", Resolution.Hour).Symbol;
// Use our Test Brokerage Model with zeroed default benchmark
SetBrokerageModel(new TestBrokerageModel());
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
if (!Portfolio.Invested)
{
SetHoldings(_spy, 1);
Debug("Purchased Stock");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Total Fees", "$3.25"},
{"Fitness Score", "0.498"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "79228162514264337593543950335"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "-1491193070"}
};
internal class TestBrokerageModel : DefaultBrokerageModel
{
public override IBenchmark GetBenchmark(SecurityManager securities)
{
return new FuncBenchmark(x => 0);
}
}
}
}

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Accord" version="3.6.0" targetFramework="net462" />
<package id="Accord.Fuzzy" version="3.6.0" targetFramework="net462" />
<package id="Accord.MachineLearning" version="3.6.0" targetFramework="net462" />
<package id="Accord.Math" version="3.6.0" targetFramework="net462" />
<package id="Accord.Statistics" version="3.6.0" targetFramework="net462" />
<package id="DynamicInterop" version="0.7.4" targetFramework="net452" />
<package id="MathNet.Numerics" version="3.19.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
<package id="R.NET.Community" version="1.6.5" targetFramework="net452" />
</packages>

View File

@@ -1,58 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>7702711a-0c09-40d4-b151-e308d1520738</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>QuantConnect.Algorithm.FSharp</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.FSharp</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFramework>net462</TargetFramework>
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
<Name>QuantConnect.Algorithm.FSharp</Name>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<OutputPath>bin\$(Configuration)\</OutputPath>
<WarningLevel>3</WarningLevel>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.Algorithm.FSharp.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Debug\QuantConnect.Algorithm.FSharp.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>bin\Release\QuantConnect.Algorithm.FSharp.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="NodaTime">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
@@ -71,79 +43,41 @@
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="BasicTemplateAlgorithm.fs" />
<None Include="packages.config" />
<PackageReference Update="FSharp.Core" Version="$(TargetFSharpCoreVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj">
<Name>QuantConnect.Algorithm</Name>
<Project>{3240aca4-bdd4-4d24-ac36-bbb651c39212}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Name>QuantConnect</Name>
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj">
<Name>QuantConnect.Indicators</Name>
<Project>{73fb2522-c3ed-4e47-8e3d-afad48a6b888}</Project>
<Private>True</Private>
</ProjectReference>
<Reference Include="mscorlib" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj" />
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
</packages>

View File

@@ -1,76 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{75981418-7246-4B91-B136-482728E02901}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Algorithm.Framework</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.Framework</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<TargetFramework>net462</TargetFramework>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.Algorithm.Framework.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<PackageTags>Library</PackageTags>
<LangVersion>6</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<DocumentationFile>bin\Debug\QuantConnect.Algorithm.Framework.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\QuantConnect.Algorithm.Framework.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accord, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.3.6.0\lib\net462\Accord.dll</HintPath>
</Reference>
<Reference Include="Accord.Math, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Math.3.6.0\lib\net462\Accord.Math.dll</HintPath>
</Reference>
<Reference Include="Accord.Math.Core, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Math.3.6.0\lib\net462\Accord.Math.Core.dll</HintPath>
</Reference>
<Reference Include="Accord.Statistics, Version=3.6.0.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7, processorArchitecture=MSIL">
<HintPath>..\packages\Accord.Statistics.3.6.0\lib\net462\Accord.Statistics.dll</HintPath>
</Reference>
<Reference Include="MathNet.Numerics, Version=3.19.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.3.19.0\lib\net40\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
@@ -85,94 +41,59 @@
<Message Text="IsLinux $(IsLinux)" Importance="high" />
<Message Text="ForceLinuxBuild $(ForceLinuxBuild)" Importance="high" />
</Target>
<ItemGroup>
<PackageReference Include="Accord" Version="3.6.0" />
<PackageReference Include="Accord.Math" Version="3.6.0" />
<PackageReference Include="Accord.Statistics" Version="3.6.0" />
<PackageReference Include="MathNet.Numerics" Version="3.19.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
</ItemGroup>
<Choose>
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Alphas\PearsonCorrelationPairsTradingAlphaModel.cs" />
<Compile Include="Alphas\EmaCrossAlphaModel.cs" />
<Compile Include="Alphas\BasePairsTradingAlphaModel.cs" />
<Compile Include="Alphas\RsiAlphaModel.cs" />
<Compile Include="Execution\StandardDeviationExecutionModel.cs" />
<Compile Include="Execution\VolumeWeightedAveragePriceExecutionModel.cs" />
<Compile Include="NotifiedSecurityChanges.cs" />
<Compile Include="Portfolio\BlackLittermanOptimizationPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\ConfidenceWeightedPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\SectorWeightingPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\InsightWeightingPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\UnconstrainedMeanVariancePortfolioOptimizer.cs" />
<Compile Include="Portfolio\MaximumSharpeRatioPortfolioOptimizer.cs" />
<Compile Include="Portfolio\MeanVarianceOptimizationPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\MinimumVariancePortfolioOptimizer.cs" />
<Compile Include="Portfolio\EqualWeightingPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\AccumulativeInsightPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\ReturnsSymbolData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Risk\MaximumDrawdownPercentPortfolio.cs" />
<Compile Include="Risk\MaximumDrawdownPercentPerSecurity.cs" />
<Compile Include="Risk\MaximumSectorExposureRiskManagementModel.cs" />
<Compile Include="Risk\MaximumUnrealizedProfitPercentPerSecurity.cs" />
<Compile Include="Risk\TrailingStopRiskManagementModel.cs" />
<Compile Include="Selection\CoarseFundamentalUniverseSelectionModel.cs" />
<Compile Include="Selection\LiquidETFUniverse.cs" />
<Compile Include="Selection\FineFundamentalUniverseSelectionModel.cs" />
<Compile Include="Selection\FundamentalUniverseSelectionModel.cs" />
<Compile Include="Selection\EmaCrossUniverseSelectionModel.cs" />
<Compile Include="Alphas\ConstantAlphaModel.cs" />
<Compile Include="Alphas\MacdAlphaModel.cs" />
<Compile Include="Selection\FutureUniverseSelectionModel.cs" />
<Compile Include="Selection\OpenInterestFutureUniverseSelectionModel.cs" />
<Compile Include="Selection\OptionUniverseSelectionModel.cs" />
<Compile Include="Selection\ScheduledUniverseSelectionModel.cs" />
<Compile Include="Selection\QC500UniverseSelectionModel.cs" />
<Compile Include="Alphas\HistoricalReturnsAlphaModel.cs" />
<Compile Include="Selection\InceptionDateUniverseSelectionModel.cs" />
<Compile Include="Selection\EnergyETFUniverse.cs" />
<Compile Include="Selection\MetalsETFUniverse.cs" />
<Compile Include="Selection\SP500SectorsETFUniverse.cs" />
<Compile Include="Selection\TechnologyETFUniverse.cs" />
<Compile Include="Selection\USTreasuriesETFUniverse.cs" />
<Compile Include="Selection\VolatilityETFUniverse.cs" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj">
<Project>{3240ACA4-BDD4-4D24-AC36-BBB651C39212}</Project>
<Name>QuantConnect.Algorithm</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545C0B4-FABB-49C9-8DD1-9AD7EE23F86B}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj">
<Project>{73fb2522-c3ed-4e47-8e3d-afad48a6b888}</Project>
<Name>QuantConnect.Indicators</Name>
</ProjectReference>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Content Include="Portfolio\BlackLittermanOptimizationPortfolioConstructionModel.py">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -268,29 +189,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
<Error Condition="!Exists('..\packages\Accord.3.6.0\build\Accord.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Accord.3.6.0\build\Accord.targets'))" />
</Target>
<Import Project="..\packages\Accord.3.6.0\build\Accord.targets" Condition="Exists('..\packages\Accord.3.6.0\build\Accord.targets')" />
</Project>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Accord" version="3.6.0" targetFramework="net462" />
<package id="Accord.Math" version="3.6.0" targetFramework="net462" />
<package id="Accord.Statistics" version="3.6.0" targetFramework="net462" />
<package id="MathNet.Numerics" version="3.19.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
</packages>

View File

@@ -0,0 +1,111 @@
### QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
### Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
###
### Licensed under the Apache License, Version 2.0 (the "License");
### you may not use this file except in compliance with the License.
### You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
###
### Unless required by applicable law or agreed to in writing, software
### distributed under the License is distributed on an "AS IS" BASIS,
### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
### See the License for the specific language governing permissions and
### limitations under the License.
from datetime import date
import QuantConnect
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Brokerages import *
from QuantConnect.Data import *
from QuantConnect.Data.Shortable import *
from QuantConnect.Data.UniverseSelection import *
from QuantConnect.Interfaces import *
from QuantConnect import *
class AllShortableSymbolsRegressionAlgorithmBrokerageModel(DefaultBrokerageModel):
def __init__(self):
self.ShortableProvider = LocalDiskShortableProvider(SecurityType.Equity, "testbrokerage", Market.USA)
### <summary>
### Tests filtering in coarse selection by shortable quantity
### </summary>
class AllShortableSymbolsCoarseSelectionRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self._20140325 = date(2014, 3, 25);
self._20140326 = date(2014, 3, 26);
self._20140327 = date(2014, 3, 27);
self._20140328 = date(2014, 3, 28);
self._20140329 = date(2014, 3, 29);
self.aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
self.bac = QuantConnect.Symbol.Create("BAC", SecurityType.Equity, Market.USA);
self.gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
self.goog = QuantConnect.Symbol.Create("GOOG", SecurityType.Equity, Market.USA);
self.qqq = QuantConnect.Symbol.Create("QQQ", SecurityType.Equity, Market.USA);
self.spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
self.lastTradeDate = date(1, 1, 1);
self.coarseSelected = {
self._20140325: False,
self._20140326: False,
self._20140327: False,
self._20140328: False
}
self.expectedSymbols = {
self._20140325: [self.bac, self.qqq, self.spy],
self._20140326: [self.spy],
self._20140327: [self.aapl, self.bac, self.gme, self.qqq, self.spy],
self._20140328: [self.goog],
self._20140329: []
}
self.SetStartDate(2014, 3, 25);
self.SetEndDate(2014, 3, 29);
self.SetCash(10000000);
self.AddUniverse(self.CoarseSelectionFunc);
self.UniverseSettings.Resolution = QuantConnect.Resolution.Daily;
self.SetBrokerageModel(AllShortableSymbolsRegressionAlgorithmBrokerageModel());
def OnData(self, data):
if self.Time.date() == self.lastTradeDate:
return
for symbol in self.ActiveSecurities.Keys:
if not symbol in self.Portfolio or not self.Portfolio[symbol].Invested:
if not self.Shortable(symbol):
raise Exception(f"Expected {symbol} to be shortable on {self.Time}")
# Buy at least once into all Symbols. Since daily data will always use
# MOO orders, it makes the testing of liquidating buying into Symbols difficult
self.MarketOrder(symbol, -float(self.ShortableQuantity(symbol)))
self.lastTradeDate = self.Time.date()
def CoarseSelectionFunc(self, coarse):
shortableSymbols = self.AllShortableSymbols();
selectedSymbols = list(sorted([x.Symbol for x in coarse if x.Symbol in shortableSymbols and shortableSymbols[x.Symbol] >= 500]))
expectedMissing = 0;
if self.Time.date() == self._20140327:
gme = QuantConnect.Symbol.Create("GME", SecurityType.Equity, Market.USA);
if gme not in shortableSymbols:
raise Exception("Expected unmapped GME in shortable symbols list on 2014-03-27");
if len([x.Symbol.Value for x in coarse if x.Symbol.Value == "GME"]) == 0:
raise Exception("Expected mapped GME in coarse symbols on 2014-03-27");
expectedMissing = 1;
missing = [i for i in self.expectedSymbols[self.Time.date()] if i not in selectedSymbols]
if (len(missing) != expectedMissing):
raise Exception(f"Expected Symbols selected on {self.Time.date()} to match expected Symbols, but the following Symbols were missing: {', '.join([str(s) for s in missing])}")
self.coarseSelected[self.Time.date()] = True;
return selectedSymbols
def OnEndOfAlgorithm(self):
if not all(list(self.coarseSelected.values())):
raise Exception(f"Expected coarse selection on all dates, but didn't run on: {', '.join([str(k) for k, v in self.coarseSelected.items() if not v])}")

View File

@@ -35,7 +35,11 @@ class CustomBenchmarkAlgorithm(QCAlgorithm):
self.SetCash(100000) #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
self.AddEquity("SPY", Resolution.Second)
# Disabling the benchmark / setting to a fixed value
# self.SetBenchmark(lambda x: 0)
# Set the benchmark to AAPL US Equity
self.SetBenchmark(Symbol.Create("AAPL", SecurityType.Equity, Market.USA))
def OnData(self, data):
@@ -46,4 +50,4 @@ class CustomBenchmarkAlgorithm(QCAlgorithm):
tupleResult = SymbolCache.TryGetSymbol("AAPL", None)
if tupleResult[0]:
raise Exception("Benchmark Symbol is not expected to be added to the Symbol cache")
raise Exception("Benchmark Symbol is not expected to be added to the Symbol cache")

View File

@@ -0,0 +1,140 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from clr import AddReference
AddReference("System.Core")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Algorithm.Framework")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Algorithm.Framework import *
from QuantConnect.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData
from QuantConnect.Securities import *
from datetime import datetime
import json
### <summary>
### Regression test to demonstrate setting custom Symbol Properties and Market Hours for a custom data import
### </summary>
### <meta name="tag" content="using data" />
### <meta name="tag" content="importing data" />
### <meta name="tag" content="custom data" />
### <meta name="tag" content="crypto" />
### <meta name="tag" content="regression test" />
class CustomDataPropertiesRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2011,9,13) # Set Start Date
self.SetEndDate(2015,12,1) # Set End Date
self.SetCash(100000) # Set Strategy Cash
# Define our custom data properties and exchange hours
self.ticker = 'BTC'
properties = SymbolProperties("Bitcoin", "USD", 1, 0.01, 0.01, self.ticker)
exchangeHours = SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork)
# Add the custom data to our algorithm with our custom properties and exchange hours
self.bitcoin = self.AddData(Bitcoin, self.ticker, properties, exchangeHours)
# Verify our symbol properties were changed and loaded into this security
if self.bitcoin.SymbolProperties != properties :
raise Exception("Failed to set and retrieve custom SymbolProperties for BTC")
# Verify our exchange hours were changed and loaded into this security
if self.bitcoin.Exchange.Hours != exchangeHours :
raise Exception("Failed to set and retrieve custom ExchangeHours for BTC")
# For regression purposes on AddData overloads, this call is simply to ensure Lean can accept this
# with default params and is not routed to a breaking function.
self.AddData(Bitcoin, "BTCUSD");
def OnData(self, data):
if not self.Portfolio.Invested:
if data['BTC'].Close != 0 :
self.Order('BTC', self.Portfolio.MarginRemaining/abs(data['BTC'].Close + 1))
def OnEndOfAlgorithm(self):
#Reset our Symbol property value, for testing purposes.
self.SymbolPropertiesDatabase.SetEntry(Market.USA, self.MarketHoursDatabase.GetDatabaseSymbolKey(self.bitcoin.Symbol), SecurityType.Base,
SymbolProperties.GetDefault("USD"));
class Bitcoin(PythonData):
'''Custom Data Type: Bitcoin data from Quandl - http://www.quandl.com/help/api-for-bitcoin-data'''
def GetSource(self, config, date, isLiveMode):
if isLiveMode:
return SubscriptionDataSource("https://www.bitstamp.net/api/ticker/", SubscriptionTransportMedium.Rest)
#return "http://my-ftp-server.com/futures-data-" + date.ToString("Ymd") + ".zip"
# OR simply return a fixed small data file. Large files will slow down your backtest
return SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.RemoteFile)
def Reader(self, config, line, date, isLiveMode):
coin = Bitcoin()
coin.Symbol = config.Symbol
if isLiveMode:
# Example Line Format:
# {"high": "441.00", "last": "421.86", "timestamp": "1411606877", "bid": "421.96", "vwap": "428.58", "volume": "14120.40683975", "low": "418.83", "ask": "421.99"}
try:
liveBTC = json.loads(line)
# If value is zero, return None
value = liveBTC["last"]
if value == 0: return None
coin.Time = datetime.now()
coin.Value = value
coin["Open"] = float(liveBTC["open"])
coin["High"] = float(liveBTC["high"])
coin["Low"] = float(liveBTC["low"])
coin["Close"] = float(liveBTC["last"])
coin["Ask"] = float(liveBTC["ask"])
coin["Bid"] = float(liveBTC["bid"])
coin["VolumeBTC"] = float(liveBTC["volume"])
coin["WeightedPrice"] = float(liveBTC["vwap"])
return coin
except ValueError:
# Do nothing, possible error in json decoding
return None
# Example Line Format:
# Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
# 2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356
if not (line.strip() and line[0].isdigit()): return None
try:
data = line.split(',')
coin.Time = datetime.strptime(data[0], "%Y-%m-%d")
coin.Value = float(data[4])
coin["Open"] = float(data[1])
coin["High"] = float(data[2])
coin["Low"] = float(data[3])
coin["Close"] = float(data[4])
coin["VolumeBTC"] = float(data[5])
coin["VolumeUSD"] = float(data[6])
coin["WeightedPrice"] = float(data[7])
return coin
except ValueError:
# Do nothing, possible error in json decoding
return None

View File

@@ -46,11 +46,6 @@ class FutureOptionBuySellCallIntradayRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es20h20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -43,11 +43,6 @@ class FutureOptionCallITMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -102,12 +97,7 @@ class FutureOptionCallITMExpiryRegressionAlgorithm(QCAlgorithm):
self.Log(f"{self.Time} -- {orderEvent.Symbol} :: Price: {self.Securities[orderEvent.Symbol].Holdings.Price} Qty: {self.Securities[orderEvent.Symbol].Holdings.Quantity} Direction: {orderEvent.Direction} Msg: {orderEvent.Message}")
def AssertFutureOptionOrderExercise(self, orderEvent: OrderEvent, future: Security, optionContract: Security):
# We expect the liquidation to occur on the day of the delisting (while the market is open),
# but currently we liquidate at the next market open (AAPL open) which happens to be
# at 9:30:00 Eastern Time. For unknown reasons, the delisting happens two minutes after the
# market open.
# Read more about the issue affecting this test here: https://github.com/QuantConnect/Lean/issues/4980
expectedLiquidationTimeUtc = datetime(2020, 6, 22, 13, 32, 0)
expectedLiquidationTimeUtc = datetime(2020, 6, 19, 20, 0, 0)
if orderEvent.Direction == OrderDirection.Sell and future.Holdings.Quantity != 0:
# We expect the contract to have been liquidated immediately

View File

@@ -28,11 +28,13 @@ from QuantConnect import Market
### <summary>
### This regression algorithm tests Out of The Money (OTM) future option expiry for calls.
### We expect 1 order from the algorithm, which are:
### We expect 2 orders from the algorithm, which are:
###
### * Initial entry, buy ES Call Option (expiring OTM)
### - contract expires worthless, not exercised, so never opened a position in the underlying
###
### * Liquidation of worthless ES call option (expiring OTM)
###
### Additionally, we test delistings for future options and assert that our
### portfolio holdings reflect the orders the algorithm has submitted.
### </summary>
@@ -45,11 +47,6 @@ class FutureOptionCallOTMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -0,0 +1,75 @@
### QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
### Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
###
### Licensed under the Apache License, Version 2.0 (the "License");
### you may not use this file except in compliance with the License.
### You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
###
### Unless required by applicable law or agreed to in writing, software
### distributed under the License is distributed on an "AS IS" BASIS,
### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
### See the License for the specific language governing permissions and
### limitations under the License.
from datetime import datetime
from System import *
from System.Reflection import *
import QuantConnect
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data import *
from QuantConnect.Data.Market import *
from QuantConnect.Orders import *
from QuantConnect.Securities import *
from QuantConnect.Securities.Future import *
from QuantConnect import Market
### <summary>
### This regression test tests for the loading of futures options contracts with a contract month of 2020-03 can live
### and be loaded from the same ZIP file that the 2020-04 contract month Future Option contract lives in.
### </summary>
class FutureOptionMultipleContractsInDifferentContractMonthsWithSameUnderlyingFutureRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self.expectedSymbols = {
self._createOption(datetime(2020, 3, 26), OptionRight.Call, 1650.0): False,
self._createOption(datetime(2020, 3, 26), OptionRight.Put, 1540.0): False,
self._createOption(datetime(2020, 2, 25), OptionRight.Call, 1600.0): False,
self._createOption(datetime(2020, 2, 25), OptionRight.Put, 1545.0): False
}
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 1, 6)
goldFutures = self.AddFuture("GC", Resolution.Minute, QuantConnect.Market.COMEX)
goldFutures.SetFilter(0, 365)
self.AddFutureOption(goldFutures.Symbol)
def OnData(self, data: Slice):
for symbol in data.QuoteBars.Keys:
if symbol in self.expectedSymbols:
invested = self.expectedSymbols[symbol]
if not invested:
self.MarketOrder(symbol, 1)
self.expectedSymbols[symbol] = True
def OnEndOfAlgorithm(self):
notEncountered = [str(k) for k,v in self.expectedSymbols.items() if not v]
if any(notEncountered):
raise AggregateException(f"Expected all Symbols encountered and invested in, but the following were not found: {', '.join(notEncountered)}")
if not self.Portfolio.Invested:
raise AggregateException("Expected holdings at the end of algorithm, but none were found.")
def _createOption(self, expiry: datetime, optionRight: OptionRight, strikePrice: float) -> Symbol:
return QuantConnect.Symbol.CreateOption(
QuantConnect.Symbol.CreateFuture("GC", QuantConnect.Market.COMEX, datetime(2020, 4, 28)),
QuantConnect.Market.COMEX,
OptionStyle.American,
optionRight,
strikePrice,
expiry
)

View File

@@ -42,11 +42,6 @@ class FutureOptionPutITMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,
@@ -101,12 +96,7 @@ class FutureOptionPutITMExpiryRegressionAlgorithm(QCAlgorithm):
self.Log(f"{self.Time} -- {orderEvent.Symbol} :: Price: {self.Securities[orderEvent.Symbol].Holdings.Price} Qty: {self.Securities[orderEvent.Symbol].Holdings.Quantity} Direction: {orderEvent.Direction} Msg: {orderEvent.Message}")
def AssertFutureOptionOrderExercise(self, orderEvent: OrderEvent, future: Security, optionContract: Security):
# We expect the liquidation to occur on the day of the delisting (while the market is open),
# but currently we liquidate at the next market open (AAPL open) which happens to be
# at 9:30:00 Eastern Time. For unknown reasons, the delisting happens two minutes after the
# market open.
# Read more about the issue affecting this test here: https://github.com/QuantConnect/Lean/issues/4980
expectedLiquidationTimeUtc = datetime(2020, 6, 22, 13, 32, 0)
expectedLiquidationTimeUtc = datetime(2020, 6, 19, 20, 0, 0)
if orderEvent.Direction == OrderDirection.Buy and future.Holdings.Quantity != 0:
# We expect the contract to have been liquidated immediately

View File

@@ -28,10 +28,12 @@ from QuantConnect import Market
### <summary>
### This regression algorithm tests Out of The Money (OTM) future option expiry for puts.
### We expect 1 order from the algorithm, which are:
### We expect 2 orders from the algorithm, which are:
###
### * Initial entry, buy ES Put Option (expiring OTM)
### - contract expires worthless, not exercised, so never opened a position in the underlying
###
### * Liquidation of worthless ES Put OTM contract
###
### Additionally, we test delistings for future options and assert that our
### portfolio holdings reflect the orders the algorithm has submitted.
@@ -44,11 +46,6 @@ class FutureOptionPutOTMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -42,11 +42,6 @@ class FutureOptionShortCallITMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -28,11 +28,13 @@ from QuantConnect import Market
### <summary>
### This regression algorithm tests Out of The Money (OTM) future option expiry for short calls.
### We expect 1 order from the algorithm, which are:
### We expect 2 orders from the algorithm, which are:
###
### * Initial entry, sell ES Call Option (expiring OTM)
### - Profit the option premium, since the option was not assigned.
###
### * Liquidation of ES call OTM contract on the last trade date
###
### Additionally, we test delistings for future options and assert that our
### portfolio holdings reflect the orders the algorithm has submitted.
### </summary>
@@ -41,11 +43,6 @@ class FutureOptionShortCallOTMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -42,11 +42,6 @@ class FutureOptionShortPutITMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -28,11 +28,13 @@ from QuantConnect import Market
### <summary>
### This regression algorithm tests Out of The Money (OTM) future option expiry for short puts.
### We expect 1 order from the algorithm, which are:
### We expect 2 orders from the algorithm, which are:
###
### * Initial entry, sell ES Put Option (expiring OTM)
### - Profit the option premium, since the option was not assigned.
###
### * Liquidation of ES put OTM contract on the last trade date
###
### Additionally, we test delistings for future options and assert that our
### portfolio holdings reflect the orders the algorithm has submitted.
### </summary>
@@ -41,11 +43,6 @@ class FutureOptionShortPutOTMExpiryRegressionAlgorithm(QCAlgorithm):
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 6, 30)
# We add AAPL as a temporary workaround for https://github.com/QuantConnect/Lean/issues/4872
# which causes delisting events to never be processed, thus leading to options that might never
# be exercised until the next data point arrives.
self.AddEquity("AAPL", Resolution.Daily)
self.es19m20 = self.AddFutureContract(
Symbol.CreateFuture(
Futures.Indices.SP500EMini,

View File

@@ -0,0 +1,95 @@
from datetime import datetime, timedelta
from QuantConnect.Algorithm import *
from QuantConnect.Data import *
from QuantConnect.Data.Market import *
from QuantConnect.Orders import *
from QuantConnect import *
### <summary>
### Tests delistings for Futures and Futures Options to ensure that they are delisted at the expected times.
### </summary>
class FuturesAndFuturesOptionsExpiryTimeAndLiquidationRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self.invested = False
self.liquidated = 0
self.delistingsReceived = 0
self.expectedExpiryWarningTime = datetime(2020, 6, 19)
self.expectedExpiryDelistingTime = datetime(2020, 6, 20)
self.expectedLiquidationTime = datetime(2020, 6, 19, 16, 0, 0)
self.SetStartDate(2020, 1, 5)
self.SetEndDate(2020, 12, 1)
self.SetCash(100000)
es = Symbol.CreateFuture(
"ES",
Market.CME,
datetime(2020, 6, 19)
)
esOption = Symbol.CreateOption(
es,
Market.CME,
OptionStyle.American,
OptionRight.Put,
3400.0,
datetime(2020, 6, 19)
)
self.esFuture = self.AddFutureContract(es, Resolution.Minute).Symbol
self.esFutureOption = self.AddFutureOptionContract(esOption, Resolution.Minute).Symbol
def OnData(self, data: Slice):
for delisting in data.Delistings.Values:
self.delistingsReceived += 1
if delisting.Type == DelistingType.Warning and delisting.Time != self.expectedExpiryWarningTime:
raise AssertionError(f"Expiry warning with time {delisting.Time} but is expected to be {self.expectedExpiryWarningTime}")
if delisting.Type == DelistingType.Warning and delisting.Time != datetime(self.Time.year, self.Time.month, self.Time.day):
raise AssertionError(f"Delisting warning received at an unexpected date: {self.Time} - expected {delisting.Time}")
if delisting.Type == DelistingType.Delisted and delisting.Time != self.expectedExpiryDelistingTime:
raise AssertionError(f"Delisting occurred at unexpected time: {delisting.Time} - expected: {self.expectedExpiryDelistingTime}")
if delisting.Type == DelistingType.Delisted and delisting.Time != datetime(self.Time.year, self.Time.month, self.Time.day):
raise AssertionError(f"Delisting notice received at an unexpected date: {self.Time} - expected {delisting.Time}")
if not self.invested and \
(self.esFuture in data.Bars or self.esFuture in data.QuoteBars) and \
(self.esFutureOption in data.Bars or self.esFutureOption in data.QuoteBars):
self.invested = True
self.MarketOrder(self.esFuture, 1)
self.MarketOrder(self.esFutureOption, 1)
def OnOrderEvent(self, orderEvent: OrderEvent):
if orderEvent.Direction != OrderDirection.Sell or orderEvent.Status != OrderStatus.Filled:
return
# * Future Liquidation
# * Future Option Exercise
# * We expect NO Underlying Future Liquidation because we already hold a Long future position so the FOP Put selling leaves us breakeven
self.liquidated += 1
if orderEvent.Symbol.SecurityType == SecurityType.FutureOption and self.expectedLiquidationTime != self.Time:
raise AssertionError(f"Expected to liquidate option {orderEvent.Symbol} at {self.expectedLiquidationTime}, instead liquidated at {self.Time}")
if orderEvent.Symbol.SecurityType == SecurityType.Future and \
(self.expectedLiquidationTime - timedelta(minutes=1)) != self.Time and \
self.expectedLiquidationTime != self.Time:
raise AssertionError(f"Expected to liquidate future {orderEvent.Symbol} at {self.expectedLiquidationTime} (+1 minute), instead liquidated at {self.Time}")
def OnEndOfAlgorithm(self):
if not self.invested:
raise AssertionError("Never invested in ES futures and FOPs")
if self.delistingsReceived != 4:
raise AssertionError(f"Expected 4 delisting events received, found: {self.delistingsReceived}")
if self.liquidated != 2:
raise AssertionError(f"Expected 3 liquidation events, found {self.liquidated}")

View File

@@ -1,6 +1,5 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
@@ -17,10 +16,8 @@ using System.Runtime.InteropServices;
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7007a02a-8d01-4a85-84e4-fcd58dc943e2")]
// Version information for an assembly consists of the following four values:
//
// Major Version

View File

@@ -1,48 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{48289996-CE56-4EDF-B451-4A2B1519EBC3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Algorithm.Python</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.Python</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>net462</TargetFramework>
<LangVersion>6</LangVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<OutputPath>bin\$(Configuration)\</OutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
<IsOSX>false</IsOSX>
<IsOSX Condition="'$(IsWindows)' != 'true' AND '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux>false</IsLinux>
<IsLinux Condition="'$(IsWindows)' != 'true' AND '$(IsOSX)' != 'true' AND '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent Condition="'$(OS)' == 'Windows_NT' ">
build
</PostBuildEvent>
<PostBuildEvent Condition="'$(OS)' != 'Windows_NT'">
./build.sh
</PostBuildEvent>
</PropertyGroup>
<Target Name="PrintRID" BeforeTargets="Build">
<Message Text="IsWindows $(IsWindows)" Importance="high" />
<Message Text="IsOSX $(IsOSX)" Importance="high" />
<Message Text="IsLinux $(IsLinux)" Importance="high" />
<Message Text="ForceLinuxBuild $(ForceLinuxBuild)" Importance="high" />
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
</ItemGroup>
<ItemGroup>
<Content Include="AccumulativeInsightPortfolioRegressionAlgorithm.py" />
<Content Include="AddAlphaModelAlgorithm.py" />
@@ -95,6 +109,7 @@
<Content Include="CustomDataAddDataOnSecuritiesChangedRegressionAlgorithm.py" />
<Content Include="CustomDataAddDataCoarseSelectionRegressionAlgorithm.py" />
<None Include="CustomBuyingPowerModelAlgorithm.py" />
<Content Include="CustomDataPropertiesRegressionAlgorithm.py" />
<Content Include="DynamicSecurityDataAlgorithm.py" />
<Content Include="ConfidenceWeightedFrameworkAlgorithm.py" />
<Content Include="ExtendedMarketTradingRegressionAlgorithm.py" />
@@ -103,12 +118,14 @@
<Content Include="FutureOptionBuySellCallIntradayRegressionAlgorithm.py" />
<Content Include="FutureOptionCallITMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionCallOTMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionMultipleContractsInDifferentContractMonthsWithSameUnderlyingFutureRegressionAlgorithm.py" />
<Content Include="FutureOptionPutITMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionPutOTMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionShortCallITMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionShortCallOTMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionShortPutITMExpiryRegressionAlgorithm.py" />
<Content Include="FutureOptionShortPutOTMExpiryRegressionAlgorithm.py" />
<Content Include="FuturesAndFuturesOptionsExpiryTimeAndLiquidationRegressionAlgorithm.py" />
<Content Include="KerasNeuralNetworkAlgorithm.py" />
<Content Include="CustomDataUsingMapFileRegressionAlgorithm.py" />
<Content Include="LiquidETFUniverseFrameworkAlgorithm.py" />
@@ -120,6 +137,7 @@
<Content Include="RegisterIndicatorRegressionAlgorithm.py" />
<Content Include="SectorWeightingFrameworkAlgorithm.py" />
<Content Include="SetHoldingsMultipleTargetsRegressionAlgorithm.py" />
<Content Include="ShortableProviderOrdersRejectedRegressionAlgorithm.py" />
<Content Include="SliceGetByTypeRegressionAlgorithm.py" />
<Content Include="StringToSymbolImplicitConversionRegressionAlgorithm.py" />
<Content Include="TalibIndicatorsAlgorithm.py" />
@@ -142,20 +160,15 @@
<Content Include="ExpiryHelperAlphaModelFrameworkAlgorithm.py" />
<Content Include="BasicTemplateFuturesFrameworkAlgorithm.py" />
<Content Include="BasicTemplateOptionsFrameworkAlgorithm.py" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="InsightWeightingFrameworkAlgorithm.py" />
<None Include="CompositeRiskManagementModelFrameworkAlgorithm.py" />
<None Include="BlackLittermanPortfolioOptimizationFrameworkAlgorithm.py" />
<None Include="packages.config" />
<None Include="TensorFlowNeuralNetworkAlgorithm.py" />
<None Include="TiingoPriceAlgorithm.py" />
<None Include="PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm.py" />
</ItemGroup>
<ItemGroup>
<None Include="AddRemoveSecurityRegressionAlgorithm.py" />
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="BasicTemplateAlgorithm.py" />
<None Include="BasicTemplateCryptoAlgorithm.py" />
<None Include="BasicTemplateDailyAlgorithm.py" />
@@ -267,18 +280,9 @@
<None Include="Benchmarks\ScheduledEventsBenchmark.py" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj">
<Project>{3240aca4-bdd4-4d24-ac36-bbb651c39212}</Project>
<Name>QuantConnect.Algorithm</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj">
<Project>{73fb2522-c3ed-4e47-8e3d-afad48a6b888}</Project>
<Name>QuantConnect.Indicators</Name>
</ProjectReference>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="ConvertToFrameworkAlgorithm.py" />
@@ -286,54 +290,29 @@
<ItemGroup>
<None Include="OptionDataNullReferenceRegressionAlgorithm.py" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
<IsOSX>false</IsOSX>
<IsOSX Condition="'$(IsWindows)' != 'true' AND '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux>false</IsLinux>
<IsLinux Condition="'$(IsWindows)' != 'true' AND '$(IsOSX)' != 'true' AND '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<Target Name="PrintRID" BeforeTargets="Build">
<Message Text="IsWindows $(IsWindows)" Importance="high" />
<Message Text="IsOSX $(IsOSX)" Importance="high" />
<Message Text="IsLinux $(IsLinux)" Importance="high" />
<Message Text="ForceLinuxBuild $(ForceLinuxBuild)" Importance="high" />
</Target>
<Choose>
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition="'$(OS)' == 'Windows_NT' ">
build
@@ -342,23 +321,4 @@
./build.sh
</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,103 @@
### QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
### Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
###
### Licensed under the Apache License, Version 2.0 (the "License");
### you may not use this file except in compliance with the License.
### You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
###
### Unless required by applicable law or agreed to in writing, software
### distributed under the License is distributed on an "AS IS" BASIS,
### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
### See the License for the specific language governing permissions and
### limitations under the License.
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Brokerages import *
from QuantConnect.Data import *
from QuantConnect.Data.Shortable import *
from QuantConnect.Interfaces import *
from QuantConnect.Orders import *
class RegressionTestShortableBrokerageModel(DefaultBrokerageModel):
def __init__(self):
self.ShortableProvider = LocalDiskShortableProvider(SecurityType.Equity, "testbrokerage", Market.USA)
### <summary>
### Tests that orders are denied if they exceed the max shortable quantity.
### </summary>
class ShortableProviderOrdersRejectedRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self.ordersAllowed = []
self.ordersDenied = []
self.initialize = False
self.invalidatedAllowedOrder = False
self.invalidatedNewOrderWithPortfolioHoldings = False
self.SetStartDate(2013, 10, 4)
self.SetEndDate(2013, 10, 11)
self.SetCash(10000000)
self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
self.aig = self.AddEquity("AIG", Resolution.Minute).Symbol
self.SetBrokerageModel(RegressionTestShortableBrokerageModel())
def OnData(self, data):
if not self.initialize:
self.HandleOrder(self.LimitOrder(self.spy, -1001, 10000)) # Should be canceled, exceeds the max shortable quantity
self.HandleOrder(self.LimitOrder(self.spy, -1000, 10000)) # Allowed, orders at or below 1000 should be accepted
self.HandleOrder(self.LimitOrder(self.spy, -10, 0.01)) # Should be canceled, the total quantity we would be short would exceed the max shortable quantity.
self.initialize = True
return
if not self.invalidatedAllowedOrder:
if len(self.ordersAllowed) != 1:
raise Exception(f"Expected 1 successful order, found: {len(self.ordersAllowed)}")
if len(self.ordersDenied) != 2:
raise Exception(f"Expected 2 failed orders, found: {len(self.ordersDenied)}")
allowedOrder = self.ordersAllowed[0]
orderUpdate = UpdateOrderFields()
orderUpdate.LimitPrice = 0.01
orderUpdate.Quantity = -1001
orderUpdate.Tag = "Testing updating and exceeding maximum quantity"
response = allowedOrder.Update(orderUpdate)
if response.ErrorCode != OrderResponseErrorCode.ExceedsShortableQuantity:
raise Exception(f"Expected order to fail due to exceeded shortable quantity, found: {response.ErrorCode}")
cancelResponse = allowedOrder.Cancel()
if cancelResponse.IsError:
raise Exception("Expected to be able to cancel open order after bad qty update")
self.invalidatedAllowedOrder = True
self.ordersDenied.clear()
self.ordersAllowed.clear()
return
if not self.invalidatedNewOrderWithPortfolioHoldings:
self.HandleOrder(self.MarketOrder(self.spy, -1000)) # Should succeed, no holdings and no open orders to stop this
spyShares = self.Portfolio[self.spy].Quantity
if spyShares != -1000:
raise Exception(f"Expected -1000 shares in portfolio, found: {spyShares}")
self.HandleOrder(self.LimitOrder(self.spy, -1, 0.01)) # Should fail, portfolio holdings are at the max shortable quantity.
if len(self.ordersDenied) != 1:
raise Exception(f"Expected limit order to fail due to existing holdings, but found {len(self.ordersDenied)} failures")
self.ordersAllowed.clear()
self.ordersDenied.clear()
self.HandleOrder(self.MarketOrder(self.aig, -1001))
if len(self.ordersAllowed) != 1:
raise Exception(f"Expected market order of -1001 BAC to not fail")
self.invalidatedNewOrderWithPortfolioHoldings = True
def HandleOrder(self, orderTicket):
if orderTicket.SubmitRequest.Status == OrderRequestStatus.Error:
self.ordersDenied.append(orderTicket)
return
self.ordersAllowed.append(orderTicket)

View File

@@ -0,0 +1,59 @@
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from clr import AddReference
AddReference("System.Core")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Brokerages import *
from QuantConnect.Benchmarks import *
from QuantConnect.Data import *
from QuantConnect.Securities import *
### <summary>
### Regression algorithm to test zeroed benchmark through BrokerageModel override
### </summary>
### <meta name="tag" content="regression test" />
class ZeroedBenchmarkRegressionAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetCash(100000)
self.SetStartDate(2013,10,7)
self.SetEndDate(2013,10,8)
# Add Equity
self.AddEquity("SPY", Resolution.Hour)
# Use our Test Brokerage Model with zerod default benchmark
self.SetBrokerageModel(TestBrokerageModel())
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)
class TestBrokerageModel(DefaultBrokerageModel):
def GetBenchmark(self, securities):
return FuncBenchmark(self.func)
def func(self, datetime):
return 0;

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
</packages>

View File

@@ -41,12 +41,12 @@ Before we enable python support, follow the [installation instructions](https://
2. Install [pandas=0.25.3](https://pandas.pydata.org/) and its [dependencies](https://pandas.pydata.org/pandas-docs/stable/install.html#dependencies).
3. Install [wrapt=1.11.2](https://pypi.org/project/wrapt/) module.
*Note:* If you encounter the "System.DllNotFoundException: python3.6m" runtime error when running Python algorithms on macOS:
*Note:* If you encounter the "System.DllNotFoundException: python3.6m" runtime error when running Python algorithms, or generating reports, on macOS:
1. Find `libpython3.6m.dylib` in your Python installation folder. If you installed Python with Anaconda, it may be found at
```
/Users/{your_user_name}/anaconda3/lib/libpython3.6m.dylib
```
2. Open `Lean/Launcher/bin/Debug/Python.Runtime.dll.config`, add the following text under `<configuration> ... </configuration>` and save:
2. Open `Lean/Common/Python/Python.Runtime.dll.config`, add the following text under `<configuration> ... </configuration>` and save:
```
<dllmap dll="python3.6m" target="{the path in step 1 including libpython3.6m.dylib}" os="osx"/>
```
@@ -81,7 +81,7 @@ conda install -y wrapt=1.11.2
conda create -n qc_environment python=3.6.8 cython=0.29.11 pandas=0.25.3 wrapt=1.11.2
```
2. Open `Lean/Launcher/bin/Debug/Python.Runtime.dll.config`, add the following text under `<configuration> ... </configuration>` and save:
2. Open `Lean/Common/Python/Python.Runtime.dll.config`, add the following text under `<configuration> ... </configuration>` and save:
```
<dllmap dll="python3.6m" target="{the path in step 1 including libpython3.6m.so}" os="linux"/>
```

View File

@@ -44,7 +44,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />

View File

@@ -14,6 +14,7 @@
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Alphas.Analysis;
@@ -31,6 +32,7 @@ namespace QuantConnect.Algorithm
{
private readonly ISecurityValuesProvider _securityValuesProvider;
private bool _isEmitWarmupInsightWarningSent;
private bool _isEmitDelistedInsightWarningSent;
/// <summary>
/// Enables additional logging of framework models including:
@@ -111,14 +113,21 @@ namespace QuantConnect.Algorithm
continue;
}
if (ukvp.Value.DisposeRequested)
{
// have to remove in the next loop after the universe is marked as disposed, when 'Dispose()' is called it will trigger universe selection
// and deselect all symbols, sending the removed security changes, which are picked up by the AlgorithmManager and tags securities
// as non tradable as long as they are not active in any universe (uses UniverseManager.ActiveSecurities)
// but they will remain tradable if a position is still being hold since they won't be remove from the UniverseManager
// but this last part will not happen if we remove the universe from the UniverseManager right away, since it won't be part of 'UniverseManager'.
// And we have to remove the universe even if it's present at 'universes' because that one is another New universe that should get added!
// 'UniverseManager' will skip duplicate entries getting added.
UniverseManager.Remove(universeSymbol);
}
Universe universe;
if (!universes.TryGetValue(universeSymbol, out universe))
{
if (ukvp.Value.DisposeRequested)
{
UniverseManager.Remove(universeSymbol);
}
// mark this universe as disposed to remove all child subscriptions
ukvp.Value.Dispose();
}
@@ -147,7 +156,8 @@ namespace QuantConnect.Algorithm
// only fire insights generated event if we actually have insights
if (insights.Length != 0)
{
OnInsightsGenerated(insights.Select(InitializeInsightFields));
insights = InitializeInsights(insights);
OnInsightsGenerated(insights);
}
ProcessInsights(insights);
@@ -226,7 +236,7 @@ namespace QuantConnect.Algorithm
Log($"{Time}: RISK ADJUSTED TARGETS: {string.Join(" | ", riskAdjustedTargets.Select(t => t.ToString()).OrderBy(t => t))}");
}
}
Execution.Execute(this, riskAdjustedTargets);
}
@@ -382,7 +392,8 @@ namespace QuantConnect.Algorithm
return;
}
OnInsightsGenerated(insights.Select(InitializeInsightFields));
insights = InitializeInsights(insights);
OnInsightsGenerated(insights);
ProcessInsights(insights);
}
@@ -394,7 +405,52 @@ namespace QuantConnect.Algorithm
/// <param name="insight">The insight to be emitted</param>
public void EmitInsights(Insight insight)
{
EmitInsights(new []{insight});
EmitInsights(new[] { insight });
}
/// <summary>
/// Helper method used to validate insights and prepare them to be emitted
/// </summary>
/// <param name="insights">insights preparing to be emitted</param>
/// <returns>Validated insights</returns>
private Insight[] InitializeInsights(Insight[] insights)
{
List<Insight> validInsights = null;
for (var i = 0; i < insights.Length; i++)
{
if (Securities[insights[i].Symbol].IsDelisted)
{
if (!_isEmitDelistedInsightWarningSent)
{
Error($"QCAlgorithm.EmitInsights(): Warning: cannot emit insights for delisted securities, these will be discarded");
_isEmitDelistedInsightWarningSent = true;
}
// If this is our first invalid insight, create the list and fill it with previous values
if (validInsights == null)
{
validInsights = new List<Insight>() {};
for (var j = 0; j < i; j++)
{
validInsights.Add(insights[j]);
}
}
}
else
{
// Initialize the insight fields
insights[i] = InitializeInsightFields(insights[i]);
// If we already had an invalid insight, this will have been initialized storing the valid ones.
if (validInsights != null)
{
validInsights.Add(insights[i]);
}
}
}
return validInsights == null ? insights : validInsights.ToArray();
}
/// <summary>

View File

@@ -126,6 +126,28 @@ namespace QuantConnect.Algorithm
return averageDirectionalIndex;
}
/// <summary>
/// Creates a new Awesome Oscillator from the specified periods.
/// </summary>
/// <param name="symbol">The symbol whose Awesome Oscillator we seek</param>
/// <param name="resolution">The resolution.</param>
/// <param name="fastPeriod">The period of the fast moving average associated with the AO</param>
/// <param name="slowPeriod">The period of the slow moving average associated with the AO</param>
/// <param name="type">The type of moving average used when computing the fast and slow term. Defaults to simple moving average.</param>
public AwesomeOscillator AO(Symbol symbol, int slowPeriod, int fastPeriod, MovingAverageType type, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"AO({fastPeriod},{slowPeriod},{type})", resolution);
var awesomeOscillator = new AwesomeOscillator(name, fastPeriod, slowPeriod, type);
RegisterIndicator(symbol, awesomeOscillator, resolution, selector);
if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, awesomeOscillator, resolution);
}
return awesomeOscillator;
}
/// <summary>
/// Creates a new AverageDirectionalMovementIndexRating indicator.
/// </summary>
@@ -354,6 +376,28 @@ namespace QuantConnect.Algorithm
return commodityChannelIndex;
}
/// <summary>
/// Creates a new ChaikinMoneyFlow indicator.
/// </summary>
/// <param name="symbol">The symbol whose CMF we want</param>
/// <param name="period">The period over which to compute the CMF</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The ChaikinMoneyFlow indicator for the requested symbol over the specified period</returns>
public ChaikinMoneyFlow CMF(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CMF({period})", resolution);
var chaikinMoneyFlow = new ChaikinMoneyFlow(name, period);
RegisterIndicator(symbol, chaikinMoneyFlow, resolution, selector);
if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, chaikinMoneyFlow, resolution);
}
return chaikinMoneyFlow;
}
/// <summary>
/// Creates a new ChandeMomentumOscillator indicator.
@@ -376,7 +420,31 @@ namespace QuantConnect.Algorithm
return chandeMomentumOscillator;
}
///<summary>
/// Creates a new DeMarker Indicator (DEM), an oscillator-type indicator measuring changes in terms of an asset's
/// High and Low tradebar values.
///</summary>
/// <param name="symbol">The symbol whose DEM we seek.</param>
/// <param name="period">The period of the moving average implemented</param>
/// <param name="movingAverageType">Specifies the type of moving average to be used</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The DeMarker indicator for the requested symbol.</returns>
public DeMarkerIndicator DEM(Symbol symbol, int period, MovingAverageType type, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"DEM({period},{type})", resolution);
var deMarkerIndicator = new DeMarkerIndicator(name, period, type);
RegisterIndicator(symbol, deMarkerIndicator, resolution, selector);
if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, deMarkerIndicator, resolution);
}
return deMarkerIndicator;
}
/// <summary>
/// Creates a new Donchian Channel indicator which will compute the Upper Band and Lower Band.
/// The indicator will be automatically updated on the given resolution.
@@ -1350,6 +1418,28 @@ namespace QuantConnect.Algorithm
return relativeStrengthIndex;
}
/// <summary>
/// Creates a new RelativeVigorIndex indicator.
/// </summary>
/// <param name="symbol">The symbol whose RVI we want</param>
/// <param name="period">The period over which to compute the RVI</param>
/// <param name="movingAverageType">The type of moving average to use</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The RelativeVigorIndex indicator for the requested symbol over the specified period</returns>
public RelativeVigorIndex RVI(Symbol symbol, int period, MovingAverageType movingAverageType = MovingAverageType.Simple, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"RVI({period},{movingAverageType})", resolution);
var relativeVigorIndex = new RelativeVigorIndex(name, period, movingAverageType);
RegisterIndicator(symbol, relativeVigorIndex, resolution, selector);
if (EnableAutomaticIndicatorWarmUp)
{
WarmUpIndicator(symbol, relativeVigorIndex, resolution);
}
return relativeVigorIndex;
}
/// <summary>
/// Creates an SimpleMovingAverage indicator for the symbol. The indicator will be automatically
@@ -2543,4 +2633,4 @@ namespace QuantConnect.Algorithm
return new BaseDataConsolidator(calendar);
}
}
}
}

View File

@@ -188,6 +188,32 @@ namespace QuantConnect.Algorithm
return AddDataImpl(dataType, symbol, resolution, timeZone, fillDataForward, leverage);
}
/// <summary>
/// AddData a new user defined data source including symbol properties and exchange hours,
/// all other vars are not required and will use defaults.
/// This overload reflects the C# equivalent for custom properties and market hours
/// </summary>
/// <param name="type">Data source type</param>
/// <param name="ticker">Key/Ticker for data</param>
/// <param name="properties">The properties of this new custom data</param>
/// <param name="exchangeHours">The Exchange hours of this symbol</param>
/// <param name="resolution">Resolution of the Data Required</param>
/// <param name="fillDataForward">When no data available on a tradebar, return the last data that was generated</param>
/// <param name="leverage">Custom leverage per security</param>
/// <returns>The new <see cref="Security"/></returns>
public Security AddData(PyObject type, string ticker, SymbolProperties properties, SecurityExchangeHours exchangeHours, Resolution? resolution = null, bool fillDataForward = false, decimal leverage = 1.0m)
{
// Get the right key for storage of base type symbols
var dataType = type.CreateType();
var key = SecurityIdentifier.GenerateBaseSymbol(dataType, ticker);
// Add entries to our Symbol Properties DB and MarketHours DB
SetDatabaseEntries(key, properties, exchangeHours);
// Then add the data
return AddData(dataType, ticker, resolution, null, fillDataForward, leverage);
}
/// <summary>
/// Creates and adds a new Future Option contract to the algorithm.
/// </summary>

View File

@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
@@ -46,6 +46,7 @@ using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Risk;
using QuantConnect.Algorithm.Framework.Selection;
using QuantConnect.Algorithm.Selection;
using QuantConnect.Data.Shortable;
using QuantConnect.Storage;
namespace QuantConnect.Algorithm
@@ -87,9 +88,6 @@ namespace QuantConnect.Algorithm
private bool _checkedForOnDataSlice;
private Action<Slice> _onDataSlice;
// set by SetBenchmark helper API functions
private Symbol _benchmarkSymbol = QuantConnect.Symbol.Empty;
// flips to true when the user
private bool _userSetSecurityInitializer = false;
@@ -554,20 +552,10 @@ namespace QuantConnect.Algorithm
FrameworkPostInitialize();
// if the benchmark hasn't been set yet, set it
// if the benchmark hasn't been set yet, load in the default from the brokerage model
if (Benchmark == null)
{
if (_benchmarkSymbol == null)
{
_benchmarkSymbol = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
}
var security = Securities.CreateSecurity(_benchmarkSymbol,
new List<SubscriptionDataConfig>(),
leverage: 1,
addToSymbolCache:false);
Benchmark = new SecurityBenchmark(security);
Benchmark = BrokerageModel.GetBenchmark(Securities);
}
// perform end of time step checks, such as enforcing underlying securities are in raw data mode
@@ -1055,7 +1043,8 @@ namespace QuantConnect.Algorithm
market = Market.USA;
}
_benchmarkSymbol = QuantConnect.Symbol.Create(symbol, securityType, market);
var benchmarkSymbol = QuantConnect.Symbol.Create(symbol, securityType, market);
SetBenchmark(benchmarkSymbol);
}
/// <summary>
@@ -1068,31 +1057,24 @@ namespace QuantConnect.Algorithm
/// </remarks>
public void SetBenchmark(string ticker)
{
if (_locked)
{
throw new InvalidOperationException("Algorithm.SetBenchmark(): Cannot change Benchmark after algorithm initialized.");
}
Symbol symbol;
Security security;
// lets first check the cache and use that symbol to check the securities collection
// else use the first matching the given ticker in the collection
if (!SymbolCache.TryGetSymbol(ticker, out symbol)
|| !Securities.TryGetValue(symbol, out security))
// Check the cache for the symbol
if (!SymbolCache.TryGetSymbol(ticker, out symbol))
{
ticker = ticker.LazyToUpper();
security = Securities.FirstOrDefault(x => x.Key.Value == ticker).Value;
// Check our securities for a symbol matched with this ticker
symbol = Securities.FirstOrDefault(x => x.Key.Value == ticker).Key;
// If we didn't find a symbol matching our ticker, create one.
if (symbol == null)
{
Debug($"Warning: SetBenchmark({ticker}): no existing symbol found, benchmark security will be added with {SecurityType.Equity} type.");
symbol = QuantConnect.Symbol.Create(ticker, SecurityType.Equity, Market.USA);
}
}
if (security == null)
{
Debug($"Warning: SetBenchmark({ticker}): no existing security found, benchmark security will be added with {SecurityType.Equity} type.");
_benchmarkSymbol = QuantConnect.Symbol.Create(ticker, SecurityType.Equity, Market.USA);
}
else
{
_benchmarkSymbol = security.Symbol;
}
// Send our symbol through
SetBenchmark(symbol);
}
/// <summary>
@@ -1105,7 +1087,9 @@ namespace QuantConnect.Algorithm
{
throw new InvalidOperationException("Algorithm.SetBenchmark(): Cannot change Benchmark after algorithm initialized.");
}
_benchmarkSymbol = symbol;
// Create our security benchmark
Benchmark = SecurityBenchmark.CreateInstance(Securities, symbol);
}
/// <summary>
@@ -1119,6 +1103,7 @@ namespace QuantConnect.Algorithm
{
throw new InvalidOperationException("Algorithm.SetBenchmark(): Cannot change Benchmark after algorithm initialized.");
}
Benchmark = new FuncBenchmark(benchmark);
}
@@ -1978,6 +1963,30 @@ namespace QuantConnect.Algorithm
return AddData(typeof(T), underlying, resolution, timeZone, fillDataForward, leverage);
}
/// <summary>
/// AddData<typeparam name="T"/> a new user defined data source including symbol properties and exchange hours,
/// all other vars are not required and will use defaults.
/// </summary>
/// <param name="ticker">Key/Ticker for data</param>
/// <param name="properties">The properties of this new custom data</param>
/// <param name="exchangeHours">The Exchange hours of this symbol</param>
/// <param name="resolution">Resolution of the Data Required</param>
/// <param name="fillDataForward">When no data available on a tradebar, return the last data that was generated</param>
/// <param name="leverage">Custom leverage per security</param>
/// <returns>The new <see cref="Security"/></returns>
public Security AddData<T>(string ticker, SymbolProperties properties, SecurityExchangeHours exchangeHours, Resolution? resolution = null, bool fillDataForward = false, decimal leverage = 1.0m)
where T : IBaseData, new()
{
// Get the right key for storage of base type symbols
var key = SecurityIdentifier.GenerateBaseSymbol(typeof(T), ticker);
// Set our database entries for this data type
SetDatabaseEntries(key, properties, exchangeHours);
// Then add the data
return AddData(typeof(T), ticker, resolution, null, fillDataForward, leverage);
}
/// <summary>
/// Send a debug message to the web console:
/// </summary>
@@ -2286,17 +2295,15 @@ namespace QuantConnect.Algorithm
/// </summary>
/// <param name="insights">The collection of insights generaed at the current time step</param>
/// <param name="clone">Will emit a clone of the generated insights</param>
private void OnInsightsGenerated(IEnumerable<Insight> insights, bool clone = true)
private void OnInsightsGenerated(Insight[] insights, bool clone = true)
{
var insightCollection = insights.ToArray();
// debug printing of generated insights
if (DebugMode)
{
Log($"{Time}: ALPHA: {string.Join(" | ", insightCollection.Select(i => i.ToString()).OrderBy(i => i))}");
Log($"{Time}: ALPHA: {string.Join(" | ", insights.Select(i => i.ToString()).OrderBy(i => i))}");
}
InsightsGenerated?.Invoke(this, new GeneratedInsightsCollection(UtcTime, insightCollection, clone: clone));
InsightsGenerated?.Invoke(this, new GeneratedInsightsCollection(UtcTime, insights, clone: clone));
}
/// <summary>
@@ -2326,5 +2333,76 @@ namespace QuantConnect.Algorithm
{
ObjectStore = new ObjectStore(objectStore);
}
/// <summary>
/// Determines if the Symbol is shortable at the brokerage
/// </summary>
/// <param name="symbol">Symbol to check if shortable</param>
/// <returns>True if shortable</returns>
public bool Shortable(Symbol symbol)
{
return Shortable(symbol, 0);
}
/// <summary>
/// Determines if the Symbol is shortable at the brokerage
/// </summary>
/// <param name="symbol">Symbol to check if shortable</param>
/// <param name="shortQuantity">Order's quantity to check if it is currently shortable, taking into account current holdings and open orders</param>
/// <returns>True if shortable</returns>
public bool Shortable(Symbol symbol, decimal shortQuantity)
{
var shortableQuantity = BrokerageModel.GetShortableProvider().ShortableQuantity(symbol, Time);
if (shortableQuantity == null)
{
return true;
}
var openOrderQuantity = Transactions.GetOpenOrdersRemainingQuantity(symbol);
var portfolioQuantity = Portfolio.ContainsKey(symbol) ? Portfolio[symbol].Quantity : 0;
// We check portfolio and open orders beforehand to ensure that orderQuantity == 0 case does not return
// a true result whenever we have no more shares left to short.
if (portfolioQuantity + openOrderQuantity <= -shortableQuantity)
{
return false;
}
shortQuantity = -Math.Abs(shortQuantity);
return portfolioQuantity + shortQuantity + openOrderQuantity >= -shortableQuantity;
}
/// <summary>
/// Gets the quantity shortable for the given asset
/// </summary>
/// <returns>
/// Quantity shortable for the given asset. Zero if not
/// shortable, or a number greater than zero if shortable.
/// </returns>
public long ShortableQuantity(Symbol symbol)
{
var shortableSymbols = AllShortableSymbols();
return shortableSymbols.ContainsKey(symbol) ? shortableSymbols[symbol] : 0;
}
/// <summary>
/// Gets all Symbols that are shortable, as well as the quantity shortable for them
/// </summary>
/// <returns>All shortable Symbols, null if all Symbols are shortable</returns>
public Dictionary<Symbol, long> AllShortableSymbols()
{
return BrokerageModel.GetShortableProvider().AllShortableSymbols(Time);
}
/// Set the properties and exchange hours for a given key into our databases
/// </summary>
/// <param name="key">Key for database storage</param>
/// <param name="properties">Properties to store</param>
/// <param name="exchangeHours">Exchange hours to store</param>
private void SetDatabaseEntries(string key, SymbolProperties properties, SecurityExchangeHours exchangeHours)
{
// Add entries to our Symbol Properties DB and MarketHours DB
SymbolPropertiesDatabase.SetEntry(Market.USA, key, SecurityType.Base, properties);
MarketHoursDatabase.SetEntry(Market.USA, key, SecurityType.Base, exchangeHours);
}
}
}

View File

@@ -1,98 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3240ACA4-BDD4-4D24-AC36-BBB651C39212}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Algorithm</RootNamespace>
<AssemblyName>QuantConnect.Algorithm</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFramework>net462</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<LangVersion>6</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.Algorithm.xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\QuantConnect.Algorithm.xml</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\QuantConnect.Algorithm.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>bin\Debug\QuantConnect.Algorithm.XML</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="MathNet.Numerics, Version=3.19.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.3.19.0\lib\net40\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
@@ -111,102 +58,51 @@
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Alphas\AlphaModel.cs" />
<Compile Include="Alphas\AlphaModelExtensions.cs" />
<Compile Include="Alphas\AlphaModelPythonWrapper.cs" />
<Compile Include="Alphas\CompositeAlphaModel.cs" />
<Compile Include="Alphas\IAlphaModel.cs" />
<Compile Include="Alphas\INamedModel.cs" />
<Compile Include="Alphas\NullAlphaModel.cs" />
<Compile Include="CandlestickPatterns.cs" />
<Compile Include="ConstituentUniverseDefinitions.cs" />
<Compile Include="Execution\ExecutionModel.cs" />
<Compile Include="Execution\ExecutionModelPythonWrapper.cs" />
<Compile Include="Execution\IExecutionModel.cs" />
<Compile Include="Execution\ImmediateExecutionModel.cs" />
<Compile Include="Execution\NullExecutionModel.cs" />
<Compile Include="IndexUniverseDefinitions.cs" />
<Compile Include="DollarVolumeUniverseDefinitions.cs" />
<Compile Include="INotifiedSecurityChanges.cs" />
<Compile Include="Portfolio\PortfolioBias.cs" />
<Compile Include="Portfolio\IPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\IPortfolioOptimizer.cs" />
<Compile Include="Portfolio\NullPortfolioConstructionModel.cs" />
<Compile Include="Portfolio\PortfolioConstructionModel.cs" />
<Compile Include="Portfolio\PortfolioConstructionModelPythonWrapper.cs" />
<Compile Include="QCAlgorithm.Framework.Python.cs" />
<Compile Include="Risk\CompositeRiskManagementModel.cs" />
<Compile Include="Risk\IRiskManagementModel.cs" />
<Compile Include="Risk\NullRiskManagementModel.cs" />
<Compile Include="Risk\RiskManagementModel.cs" />
<Compile Include="Risk\RiskManagementModelPythonWrapper.cs" />
<Compile Include="QCAlgorithm.cs" />
<Compile Include="QCAlgorithm.Framework.cs" />
<Compile Include="QCAlgorithm.History.cs" />
<Compile Include="QCAlgorithm.Python.cs" />
<Compile Include="QCAlgorithm.Trading.cs" />
<Compile Include="QCAlgorithm.Indicators.cs" />
<Compile Include="QCAlgorithm.Plotting.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QCAlgorithm.Universe.cs" />
<Compile Include="Selection\CompositeUniverseSelectionModel.cs" />
<Compile Include="Selection\CustomUniverse.cs" />
<Compile Include="Selection\CustomUniverseSelectionModel.cs" />
<Compile Include="Selection\IUniverseSelectionModel.cs" />
<Compile Include="Selection\ManualUniverse.cs" />
<Compile Include="Selection\ManualUniverseSelectionModel.cs" />
<Compile Include="Selection\NullUniverseSelectionModel.cs" />
<Compile Include="Selection\OptionChainedUniverseSelectionModel.cs" />
<Compile Include="Selection\OptionContractUniverse.cs" />
<Compile Include="Selection\UniverseSelectionModel.cs" />
<Compile Include="Selection\UniverseSelectionModelPythonWrapper.cs" />
<Compile Include="UniverseDefinitions.cs" />
<PackageReference Include="MathNet.Numerics" Version="3.19.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj">
<Project>{0AEB4EA3-28C8-476E-89FD-926F06590B4C}</Project>
<Name>QuantConnect.Configuration</Name>
</ProjectReference>
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj">
<Project>{73FB2522-C3ED-4E47-8E3D-AFAD48A6B888}</Project>
<Name>QuantConnect.Indicators</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545C0B4-FABB-49C9-8DD1-9AD7EE23F86B}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj">
<Project>{01911409-86BE-4E7D-9947-DF714138610D}</Project>
<Name>QuantConnect.Logging</Name>
</ProjectReference>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj" />
<ProjectReference Include="..\Indicators\QuantConnect.Indicators.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="Alphas\NullAlphaModel.py">
@@ -234,35 +130,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MathNet.Numerics" version="3.19.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
</packages>

View File

@@ -101,21 +101,21 @@ while not sys.gettrace():
count = 1
while count <= 10:
try:
pydevd_pycharm.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True, suspend=False)
pydevd_pycharm.settrace('localhost', port=6000, stdoutToServer=True, stderrToServer=True, suspend=False)
print('SUCCESS: Connected to local program')
break
except ConnectionRefusedError:
pass
try:
pydevd_pycharm.settrace('host.docker.internal', port=5678, stdoutToServer=True, stderrToServer=True, suspend=False)
pydevd_pycharm.settrace('host.docker.internal', port=6000, stdoutToServer=True, stderrToServer=True, suspend=False)
print('SUCCESS: Connected to docker container')
break
except ConnectionRefusedError:
pass
print('\n')
print('Failed: Ensure your PyCharm Debugger is actively waiting for a connection at port 5678!')
print('Failed: Ensure your PyCharm Debugger is actively waiting for a connection at port 6000!')
print('Try ' + count.__str__() + ' out of 10')
print('\n')
count += 1

View File

@@ -368,7 +368,7 @@ logging.captureWarnings(True)"
var complete = isolator.ExecuteWithTimeLimit(_loaderTimeLimit, () =>
{
success = TryCreateAlgorithmInstance(assemblyPath, out instance, out error);
}, ramLimit, sleepIntervalMillis:50, workerThread:_workerThread);
}, ramLimit, sleepIntervalMillis:100, workerThread:_workerThread);
algorithmInstance = instance;
errorMessage = error;

View File

@@ -930,5 +930,16 @@ namespace QuantConnect.AlgorithmFactory.Python.Wrappers
/// </summary>
/// <param name="objectStore">The object store</param>
public void SetObjectStore(IObjectStore objectStore) => _baseAlgorithm.SetObjectStore(objectStore);
/// <summary>
/// Checks if the asset is shortable at the brokerage
/// </summary>
/// <param name="symbol">Symbol to check if it is shortable</param>
/// <param name="quantity">Quantity to short</param>
/// <returns>True if shortable at the brokerage</returns>
public bool Shortable(Symbol symbol, decimal quantity)
{
return _baseAlgorithm.Shortable(symbol, quantity);
}
}
}
}

View File

@@ -1,62 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E99D056A-B6FB-48D2-9F7C-683C54CEBBF9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.AlgorithmFactory</RootNamespace>
<AssemblyName>QuantConnect.AlgorithmFactory</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>net462</TargetFramework>
<LangVersion>6</LangVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.AlgorithmFactory.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\QuantConnect.AlgorithmFactory.xml</DocumentationFile>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\QuantConnect.AlgorithmFactory.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<PropertyGroup>
<IsWindows>false</IsWindows>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
@@ -71,89 +39,53 @@
<Message Text="IsLinux $(IsLinux)" Importance="high" />
<Message Text="ForceLinuxBuild $(ForceLinuxBuild)" Importance="high" />
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
</ItemGroup>
<Choose>
<When Condition="$(IsWindows) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsLinux) OR '$(ForceLinuxBuild)' == 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\linux\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition="$(IsOSX) AND '$(ForceLinuxBuild)' != 'true'">
<ItemGroup>
<Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.pythonnet.1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
<HintPath>$(NuGetPackageRoot)\quantconnect.pythonnet\1.0.5.30\lib\osx\Python.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DebuggerHelper.cs" />
<Compile Include="Loader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Python\Wrappers\AlgorithmPythonWrapper.cs" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj">
<Project>{3240ACA4-BDD4-4D24-AC36-BBB651C39212}</Project>
<Name>QuantConnect.Algorithm</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj">
<Project>{0aeb4ea3-28c8-476e-89fd-926f06590b4c}</Project>
<Name>QuantConnect.Configuration</Name>
</ProjectReference>
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj">
<Project>{01911409-86be-4e7d-9947-df714138610d}</Project>
<Name>QuantConnect.Logging</Name>
</ProjectReference>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<ProjectReference Include="..\Algorithm\QuantConnect.Algorithm.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj" />
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets" Condition="Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.pythonnet.1.0.5.30\build\QuantConnect.pythonnet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="QuantConnect.pythonnet" version="1.0.5.30" targetFramework="net452" />
</packages>

View File

@@ -20,6 +20,7 @@ using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using QuantConnect.Interfaces;
using QuantConnect.Logging;
using QuantConnect.Orders;
using RestSharp;
using RestSharp.Extensions;
@@ -383,9 +384,15 @@ namespace QuantConnect.Api
backtestName
}), ParameterType.RequestBody);
Backtest result;
BacktestResponseWrapper result;
ApiConnection.TryRequest(request, out result);
return result;
// Use API Response values for Backtest Values
result.Backtest.Success = result.Success;
result.Backtest.Errors = result.Errors;
// Return only the backtest object
return result.Backtest;
}
/// <summary>
@@ -393,9 +400,10 @@ namespace QuantConnect.Api
/// </summary>
/// <param name="projectId">Project id to read</param>
/// <param name="backtestId">Specific backtest id to read</param>
/// <param name="getCharts">True will return backtest charts</param>
/// <returns><see cref="Backtest"/></returns>
public Backtest ReadBacktest(int projectId, string backtestId)
public Backtest ReadBacktest(int projectId, string backtestId, bool getCharts = true)
{
var request = new RestRequest("backtests/read", Method.POST)
{
@@ -408,9 +416,63 @@ namespace QuantConnect.Api
backtestId
}), ParameterType.RequestBody);
Backtest result;
BacktestResponseWrapper result;
ApiConnection.TryRequest(request, out result);
return result;
if (!result.Success)
{
// place an empty place holder so we can return any errors back to the user and not just null
result.Backtest = new Backtest { BacktestId = backtestId };
}
// Go fetch the charts if the backtest is completed and success
else if (getCharts && result.Backtest.Completed)
{
// For storing our collected charts
var updatedCharts = new Dictionary<string, Chart>();
// Create backtest requests for each chart that is empty
foreach (var chart in result.Backtest.Charts)
{
if (!chart.Value.Series.IsNullOrEmpty())
{
continue;
}
var chartRequest = new RestRequest("backtests/read", Method.POST)
{
RequestFormat = DataFormat.Json
};
chartRequest.AddParameter("application/json", JsonConvert.SerializeObject(new
{
projectId,
backtestId,
chart = chart.Key.Replace(' ', '+')
}), ParameterType.RequestBody);
BacktestResponseWrapper chartResponse;
ApiConnection.TryRequest(chartRequest, out chartResponse);
// Add this chart to our updated collection
if (chartResponse.Success)
{
updatedCharts.Add(chart.Key, chartResponse.Backtest.Charts[chart.Key]);
}
}
// Update our result
foreach(var updatedChart in updatedCharts)
{
result.Backtest.Charts[updatedChart.Key] = updatedChart.Value;
}
}
// Use API Response values for Backtest Values
result.Backtest.Success = result.Success;
result.Backtest.Errors = result.Errors;
// Return only the backtest object
return result.Backtest;
}
/// <summary>
@@ -761,8 +823,29 @@ namespace QuantConnect.Api
var uri = new Uri(link.DataLink);
var client = new RestClient(uri.Scheme + "://" + uri.Host);
var request = new RestRequest(uri.PathAndQuery, Method.GET);
client.DownloadData(request).SaveAs(path);
// MAke a request for the data at the link
var response = client.Execute(request);
// If the response is JSON it doesn't contain any data, try and extract the message and write it
if (response.ContentType.ToLowerInvariant() == "application/json")
{
try
{
var contentObj = JObject.Parse(response.Content);
var message = contentObj["message"].Value<string>();
Log.Error($"Api.DownloadData(): Failed to download zip for {symbol} {resolution} data for date {date}, Api response: {message}");
}
catch
{
Log.Error($"Api.DownloadData(): Failed to download zip for {symbol} {resolution} data for date {date}. Api response could not be parsed.");
}
return false;
}
// Any other case save the content to given path
response.RawBytes.SaveAs(path);
return true;
}
@@ -847,7 +930,20 @@ namespace QuantConnect.Api
// Add a user agent header in case the requested URI contains a query.
client.Headers.Add("user-agent", "QCAlgorithm.Download(): User Agent Header");
return client.DownloadString(address);
try
{
return client.DownloadString(address);
}
catch (WebException exception)
{
var message = $"Api.Download(): Failed to download data from {address}";
if (!userName.IsNullOrEmpty() || !password.IsNullOrEmpty())
{
message += $" with username: {userName} and password {password}";
}
throw new WebException($"{message}. Please verify the source for missing http:// or https://", exception);
}
}
}

View File

@@ -28,11 +28,6 @@ namespace QuantConnect.Api
/// </summary>
public class ApiConnection
{
/// <summary>
/// The current config api url
/// </summary>
public static string ApiUrl = Config.Get("cloud-api-url", "https://www.quantconnect.com/api/v2/");
/// <summary>
/// Authorized client to use for requests.
/// </summary>
@@ -51,7 +46,7 @@ namespace QuantConnect.Api
{
_token = token;
_userId = userId.ToStringInvariant();
Client = new RestClient(ApiUrl);
Client = new RestClient("https://www.quantconnect.com/api/v2/");
}
/// <summary>
@@ -121,6 +116,7 @@ namespace QuantConnect.Api
if (result == null || !result.Success)
{
Log.Debug($"ApiConnection.TryRequest(): Raw response: '{responseContent}'");
return false;
}
}

View File

@@ -1,179 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C5D44209-49A0-4505-A870-043C5EF5FDDF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Api</RootNamespace>
<AssemblyName>QuantConnect.Api</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFramework>net462</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<LangVersion>6</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.Api.xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>$(SelectedOptimization)</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\QuantConnect.Api.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\QuantConnect.Api.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>bin\Debug\QuantConnect.API.XML</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>true</CodeAnalysisFailOnMissingRules>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<Target Name="Print" BeforeTargets="Build">
<Message Text="SelectedOptimization $(SelectedOptimization)" Importance="high" />
</Target>
<ItemGroup>
<Reference Include="DotNetZip, Version=1.13.3.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.3\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=1.2.0.246, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="MathNet.Filtering, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Filtering.0.4.0\lib\net40\MathNet.Filtering.dll</HintPath>
</Reference>
<Reference Include="MathNet.Numerics, Version=3.19.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MathNet.Numerics.3.19.0\lib\net40\MathNet.Numerics.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.6.10.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.6.10\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<PackageReference Include="DotNetZip" Version="1.13.3" />
<PackageReference Include="MathNet.Filtering" Version="0.4.0" />
<PackageReference Include="MathNet.Numerics" Version="3.19.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="RestSharp" Version="106.6.10" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="WebSocketSharpFork" Version="1.0.4" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="websocket-sharp, Version=1.0.4.0, Culture=neutral, PublicKeyToken=5660b08a1845a91e, processorArchitecture=MSIL">
<HintPath>..\packages\WebSocketSharpFork.1.0.4.0\lib\net35\websocket-sharp.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Api.cs" />
<Compile Include="ApiConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj">
<Project>{0AEB4EA3-28C8-476E-89FD-926F06590B4C}</Project>
<Name>QuantConnect.Configuration</Name>
</ProjectReference>
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj">
<Project>{01911409-86be-4e7d-9947-df714138610d}</Project>
<Name>QuantConnect.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj" />
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.13.3" targetFramework="net452" />
<package id="MathNet.Filtering" version="0.4.0" targetFramework="net452" />
<package id="MathNet.Numerics" version="3.19.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.VersionCheckAnalyzer" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="NodaTime" version="1.3.4" targetFramework="net452" />
<package id="RestSharp" version="106.6.10" targetFramework="net452" />
<package id="SharpZipLib" version="1.2.0" targetFramework="net462" />
</packages>

View File

@@ -45,7 +45,7 @@ namespace QuantConnect.Brokerages.Alpaca
return new Tick
{
Symbol = Symbol.Create(response.Symbol, SecurityType.Equity, Market.USA),
Symbol = _symbolMapper.GetLeanSymbol(response.Symbol, SecurityType.Equity, Market.USA),
BidPrice = response.BidPrice,
AskPrice = response.AskPrice,
Time = response.Time,
@@ -95,7 +95,7 @@ namespace QuantConnect.Brokerages.Alpaca
}
CheckRateLimiting();
var task = _alpacaTradingClient.PostOrderAsync(new NewOrderRequest(order.Symbol.Value, quantity, side, type, timeInForce)
var task = _alpacaTradingClient.PostOrderAsync(new NewOrderRequest(_symbolMapper.GetBrokerageSymbol(order.Symbol), quantity, side, type, timeInForce)
{
LimitPrice = limitPrice,
StopPrice = stopPrice
@@ -211,7 +211,7 @@ namespace QuantConnect.Brokerages.Alpaca
var task = _polygonDataClient.ListAggregatesAsync(
new AggregatesRequest(
symbol.Value,
_symbolMapper.GetBrokerageSymbol(symbol),
new AggregationPeriod(
1,
resolution == Resolution.Daily ? AggregationPeriodUnit.Day : AggregationPeriodUnit.Minute
@@ -296,7 +296,7 @@ namespace QuantConnect.Brokerages.Alpaca
var dateUtc = startTimeUtc.Date;
var date = startTimeUtc.ConvertFromUtc(requestedTimeZone).Date;
var task = _polygonDataClient.ListHistoricalTradesAsync(new HistoricalRequest(symbol.Value, date)
var task = _polygonDataClient.ListHistoricalTradesAsync(new HistoricalRequest(_symbolMapper.GetBrokerageSymbol(symbol), date)
{
Timestamp = previousTimestamp
});
@@ -396,7 +396,7 @@ namespace QuantConnect.Brokerages.Alpaca
var instrument = order.Symbol;
var id = order.OrderId.ToString();
qcOrder.Symbol = Symbol.Create(instrument, SecurityType.Equity, Market.USA);
qcOrder.Symbol = _symbolMapper.GetLeanSymbol(instrument, SecurityType.Equity, Market.USA);
if (order.SubmittedAt != null)
{
@@ -429,15 +429,12 @@ namespace QuantConnect.Brokerages.Alpaca
/// <summary>
/// Converts an Alpaca position into a LEAN holding.
/// </summary>
private static Holding ConvertHolding(IPosition position)
private Holding ConvertHolding(IPosition position)
{
const SecurityType securityType = SecurityType.Equity;
var symbol = Symbol.Create(position.Symbol, securityType, Market.USA);
return new Holding
{
Symbol = symbol,
Type = securityType,
Symbol = _symbolMapper.GetLeanSymbol(position.Symbol, SecurityType.Equity, Market.USA),
Type = SecurityType.Equity,
AveragePrice = position.AverageEntryPrice,
MarketPrice = position.AssetCurrentPrice,
MarketValue = position.MarketValue,

View File

@@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.Linq;
using QuantConnect.Brokerages.Alpaca.Markets;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Logging;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
@@ -39,6 +40,7 @@ namespace QuantConnect.Brokerages.Alpaca
private readonly AlpacaTradingClient _alpacaTradingClient;
private readonly PolygonDataClient _polygonDataClient;
private readonly SockClient _sockClient;
private readonly ISymbolMapper _symbolMapper;
/// <summary>
/// This lock is used to sync 'PlaceOrder' and callback 'OnTradeUpdate'
@@ -65,10 +67,11 @@ namespace QuantConnect.Brokerages.Alpaca
/// </summary>
/// <param name="orderProvider">The order provider.</param>
/// <param name="securityProvider">The holdings provider.</param>
/// <param name="mapFileProvider">representing all the map files</param>
/// <param name="accountKeyId">The Alpaca api key id</param>
/// <param name="secretKey">The api secret key</param>
/// <param name="tradingMode">The Alpaca trading mode. paper/live</param>
public AlpacaBrokerage(IOrderProvider orderProvider, ISecurityProvider securityProvider, string accountKeyId, string secretKey, string tradingMode)
public AlpacaBrokerage(IOrderProvider orderProvider, ISecurityProvider securityProvider, IMapFileProvider mapFileProvider, string accountKeyId, string secretKey, string tradingMode)
: base("Alpaca Brokerage")
{
var httpScheme = "https://";
@@ -80,7 +83,7 @@ namespace QuantConnect.Brokerages.Alpaca
_orderProvider = orderProvider;
_securityProvider = securityProvider;
_symbolMapper = new AlpacaSymbolMapper(mapFileProvider);
_marketHours = MarketHoursDatabase.FromDataFolder();
// Alpaca trading client

View File

@@ -19,6 +19,7 @@ using QuantConnect.Configuration;
using QuantConnect.Interfaces;
using QuantConnect.Packets;
using QuantConnect.Securities;
using QuantConnect.Util;
namespace QuantConnect.Brokerages.Alpaca
{
@@ -92,7 +93,8 @@ namespace QuantConnect.Brokerages.Alpaca
return new AlpacaBrokerage(
algorithm.Transactions,
algorithm.Portfolio,
algorithm.Portfolio,
Composer.Instance.GetExportedValueByTypeName<IMapFileProvider>(Config.Get("map-file-provider", "QuantConnect.Data.Auxiliary.LocalDiskMapFileProvider")),
keyId,
secretKey,
tradingMode);

View File

@@ -0,0 +1,88 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using QuantConnect.Interfaces;
namespace QuantConnect.Brokerages.Alpaca
{
/// <summary>
/// Provides the mapping between Lean symbols and Alpaca symbols.
/// </summary>
public class AlpacaSymbolMapper : ISymbolMapper
{
private readonly IMapFileProvider _mapFileProvider;
/// <summary>
/// Constructs InteractiveBrokersSymbolMapper. Default parameters are used.
/// </summary>
public AlpacaSymbolMapper(IMapFileProvider mapFileProvider)
{
_mapFileProvider = mapFileProvider;
}
/// <summary>
/// Converts a Lean symbol instance to an InteractiveBrokers symbol
/// </summary>
/// <param name="symbol">A Lean symbol instance</param>
/// <returns>The InteractiveBrokers symbol</returns>
public string GetBrokerageSymbol(Symbol symbol)
{
if (string.IsNullOrWhiteSpace(symbol?.Value))
throw new ArgumentException("Invalid symbol: " + (symbol == null ? "null" : symbol.ToString()));
if (symbol.SecurityType != SecurityType.Equity)
throw new ArgumentException($"Invalid security type: {symbol.SecurityType}");
var mapFile = _mapFileProvider.Get(symbol.ID.Market).ResolveMapFile(symbol.ID.Symbol, symbol.ID.Date);
return mapFile.GetMappedSymbol(DateTime.UtcNow, symbol.Value);
}
/// <summary>
/// Converts an Alpaca symbol to a Lean symbol instance
/// </summary>
/// <param name="brokerageSymbol">The Alpaca symbol</param>
/// <param name="securityType">The security type</param>
/// <param name="market">The market</param>
/// <param name="expirationDate">Expiration date of the security(if applicable)</param>
/// <param name="strike">The strike of the security (if applicable)</param>
/// <param name="optionRight">The option right of the security (if applicable)</param>
/// <returns>A new Lean Symbol instance</returns>
public Symbol GetLeanSymbol(
string brokerageSymbol,
SecurityType securityType,
string market,
DateTime expirationDate = default(DateTime),
decimal strike = 0,
OptionRight optionRight = OptionRight.Call
)
{
if (string.IsNullOrWhiteSpace(brokerageSymbol))
throw new ArgumentException($"Invalid symbol: {brokerageSymbol}");
if (securityType != SecurityType.Equity)
throw new ArgumentException($"Invalid security type: {securityType}");
try
{
return Symbol.Create(brokerageSymbol, securityType, market);
}
catch (Exception)
{
throw new ArgumentException($"Invalid symbol: {brokerageSymbol}, security type: {securityType}, market: {market}.");
}
}
}
}

View File

@@ -269,7 +269,7 @@ namespace QuantConnect.Brokerages.Backtesting
}
// all order fills are processed on the next bar (except for market orders)
if (order.Time == Algorithm.UtcTime && order.Type != OrderType.Market)
if (order.Time == Algorithm.UtcTime && order.Type != OrderType.Market && order.Type != OrderType.OptionExercise)
{
stillNeedsScan = true;
continue;

View File

@@ -1,60 +0,0 @@
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Newtonsoft.Json;
using QuantConnect.Orders;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace QuantConnect.Brokerages.Binance
{
/// <summary>
/// Binance utility methods
/// </summary>
public class BinanceUtil
{
/// <summary>
/// Convert binance status string value to native Lean OrderStatus
/// </summary>
/// <param name="status">The Binance order status value</param>
/// <returns>Lean order status</returns>
public static OrderStatus ConvertOrderStatus(string status)
{
switch (status.LazyToUpper())
{
case "NEW":
return OrderStatus.New;
case "PARTIALLY_FILLED":
return OrderStatus.PartiallyFilled;
case "FILLED":
return OrderStatus.Filled;
case "PENDING_CANCEL":
return OrderStatus.CancelPending;
case "CANCELED":
return OrderStatus.Canceled;
case "REJECTED":
case "EXPIRED":
return OrderStatus.Invalid;
default:
return Orders.OrderStatus.None;
}
}
}
}

View File

@@ -28,6 +28,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using QuantConnect.Brokerages.Bitfinex.Messages;
using Order = QuantConnect.Orders.Order;
@@ -53,6 +54,9 @@ namespace QuantConnect.Brokerages.Bitfinex
private readonly object _clientOrderIdLocker = new object();
private long _nextClientOrderId;
// map Bitfinex currency to LEAN currency
private readonly Dictionary<string, string> _currencyMap;
/// <summary>
/// Locking object for the Ticks list in the data queue handler
/// </summary>
@@ -89,6 +93,15 @@ namespace QuantConnect.Brokerages.Bitfinex
_algorithm = algorithm;
_aggregator = aggregator;
// load currency map
using (var wc = new WebClient())
{
var json = wc.DownloadString("https://api-pub.bitfinex.com/v2/conf/pub:map:currency:sym");
var rows = JsonConvert.DeserializeObject<List<List<List<string>>>>(json)[0];
_currencyMap = rows
.ToDictionary(row => row[0], row => row[1].ToUpperInvariant());
}
WebSocket.Open += (sender, args) =>
{
SubscribeAuth();
@@ -384,7 +397,7 @@ namespace QuantConnect.Brokerages.Bitfinex
var fillQuantity = update.ExecAmount;
var direction = fillQuantity < 0 ? OrderDirection.Sell : OrderDirection.Buy;
var updTime = Time.UnixMillisecondTimeStampToDateTime(update.MtsCreate);
var orderFee = new OrderFee(new CashAmount(Math.Abs(update.Fee), update.FeeCurrency));
var orderFee = new OrderFee(new CashAmount(Math.Abs(update.Fee), GetLeanCurrency(update.FeeCurrency)));
var status = OrderStatus.Filled;
if (fillQuantity != order.Quantity)
@@ -440,6 +453,17 @@ namespace QuantConnect.Brokerages.Bitfinex
}
}
private string GetLeanCurrency(string brokerageCurrency)
{
string currency;
if (!_currencyMap.TryGetValue(brokerageCurrency.ToUpperInvariant(), out currency))
{
currency = brokerageCurrency.ToUpperInvariant();
}
return currency;
}
/// <summary>
/// Emit stream tick
/// </summary>

View File

@@ -280,7 +280,7 @@ namespace QuantConnect.Brokerages.Bitfinex
{
if (item.Balance > 0)
{
list.Add(new CashAmount(item.Balance, item.Currency.ToUpperInvariant()));
list.Add(new CashAmount(item.Balance, GetLeanCurrency(item.Currency)));
}
}

View File

@@ -76,6 +76,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
// Notifies the thread reading information from Gateway/TWS whenever there are messages ready to be consumed
private readonly EReaderSignal _signal = new EReaderMonitorSignal();
private readonly ManualResetEvent _connectEvent = new ManualResetEvent(false);
private readonly ManualResetEvent _waitForNextValidId = new ManualResetEvent(false);
private readonly ManualResetEvent _accountHoldingsResetEvent = new ManualResetEvent(false);
private Exception _accountHoldingsLastException;
@@ -97,7 +98,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
private readonly ConcurrentDictionary<string, ContractDetails> _contractDetails = new ConcurrentDictionary<string, ContractDetails>();
private readonly InteractiveBrokersSymbolMapper _symbolMapper = new InteractiveBrokersSymbolMapper();
private readonly InteractiveBrokersSymbolMapper _symbolMapper;
// Prioritized list of exchanges used to find right futures contract
private readonly Dictionary<string, string> _futuresExchanges = new Dictionary<string, string>
@@ -136,18 +137,18 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
public override bool IsConnected => _client != null && _client.Connected && !_stateManager.Disconnected1100Fired;
/// <summary>
/// Returns true if the connected user is a financial advisor or non-disclosed broker
/// Returns true if the connected user is a financial advisor
/// </summary>
public bool IsFinancialAdvisor => IsMasterAccount(_account);
/// <summary>
/// Returns true if the account is a financial advisor or non-disclosed broker master account
/// Returns true if the account is a financial advisor master account
/// </summary>
/// <param name="account">The account code</param>
/// <returns>True if the account is a master account</returns>
public static bool IsMasterAccount(string account)
{
return account.Contains("F") || account.Contains("I");
return account.Contains("F");
}
/// <summary>
@@ -161,12 +162,14 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <param name="orderProvider">An instance of IOrderProvider used to fetch Order objects by brokerage ID</param>
/// <param name="securityProvider">The security provider used to give access to algorithm securities</param>
/// <param name="aggregator">consolidate ticks</param>
public InteractiveBrokersBrokerage(IAlgorithm algorithm, IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator)
/// <param name="mapFileProvider">representing all the map files</param>
public InteractiveBrokersBrokerage(IAlgorithm algorithm, IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator, IMapFileProvider mapFileProvider)
: this(
algorithm,
orderProvider,
securityProvider,
aggregator,
mapFileProvider,
Config.Get("ib-account"),
Config.Get("ib-host", "LOCALHOST"),
Config.GetInt("ib-port", 4001),
@@ -186,13 +189,16 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <param name="algorithm">The algorithm instance</param>
/// <param name="orderProvider">An instance of IOrderProvider used to fetch Order objects by brokerage ID</param>
/// <param name="securityProvider">The security provider used to give access to algorithm securities</param>
/// <param name="aggregator">consolidate ticks</param>
/// <param name="mapFileProvider">representing all the map files</param>
/// <param name="account">The account used to connect to IB</param>
public InteractiveBrokersBrokerage(IAlgorithm algorithm, IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator, string account)
public InteractiveBrokersBrokerage(IAlgorithm algorithm, IOrderProvider orderProvider, ISecurityProvider securityProvider, IDataAggregator aggregator, IMapFileProvider mapFileProvider, string account)
: this(
algorithm,
orderProvider,
securityProvider,
aggregator,
mapFileProvider,
account,
Config.Get("ib-host", "LOCALHOST"),
Config.GetInt("ib-port", 4001),
@@ -213,6 +219,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <param name="orderProvider">An instance of IOrderProvider used to fetch Order objects by brokerage ID</param>
/// <param name="securityProvider">The security provider used to give access to algorithm securities</param>
/// <param name="aggregator">consolidate ticks</param>
/// <param name="mapFileProvider">representing all the map files</param>
/// <param name="account">The Interactive Brokers account name</param>
/// <param name="host">host name or IP address of the machine where TWS is running. Leave blank to connect to the local host.</param>
/// <param name="port">must match the port specified in TWS on the Configure&gt;API&gt;Socket Port field.</param>
@@ -227,6 +234,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
IOrderProvider orderProvider,
ISecurityProvider securityProvider,
IDataAggregator aggregator,
IMapFileProvider mapFileProvider,
string account,
string host,
int port,
@@ -247,6 +255,8 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
_port = port;
_agentDescription = agentDescription;
_symbolMapper = new InteractiveBrokersSymbolMapper(mapFileProvider);
_subscriptionManager = new EventBasedDataQueueHandlerSubscriptionManager();
_subscriptionManager.SubscribeImpl += (s, t) => Subscribe(s);
_subscriptionManager.UnsubscribeImpl += (s, t) => Unsubscribe(s);
@@ -295,12 +305,14 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
_client.ConnectAck += (sender, e) =>
{
Log.Trace("InteractiveBrokersBrokerage.HandleConnectAck(): API client connected.");
Log.Trace($"InteractiveBrokersBrokerage.HandleConnectAck(): API client connected [Server Version: {_client.ClientSocket.ServerVersion}].");
_connectEvent.Set();
};
_client.ConnectionClosed += (sender, e) =>
{
Log.Trace("InteractiveBrokersBrokerage.HandleConnectionClosed(): API client disconnected.");
_connectEvent.Set();
};
}
@@ -676,9 +688,16 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
Thread.Sleep(2500);
}
_connectEvent.Reset();
// we're going to try and connect several times, if successful break
_client.ClientSocket.eConnect(_host, _port, ClientId);
if (!_connectEvent.WaitOne(TimeSpan.FromSeconds(15)))
{
Log.Error("InteractiveBrokersBrokerage.Connect(): timeout waiting for connect callback");
}
// create the message processing thread
var reader = new EReader(_client.ClientSocket, _signal);
reader.Start();
@@ -990,7 +1009,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
return $"{contract.ToString().ToUpperInvariant()} {contract.LastTradeDateOrContractMonth.ToStringInvariant()} {contract.Strike.ToStringInvariant()} {contract.Right}";
}
private static string GetContractDescription(Contract contract)
public static string GetContractDescription(Contract contract)
{
return $"{contract} {contract.PrimaryExch ?? string.Empty} {contract.LastTradeDateOrContractMonth.ToStringInvariant()} {contract.Strike.ToStringInvariant()} {contract.Right}";
}
@@ -1193,6 +1212,9 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// </summary>
private void HandleError(object sender, IB.ErrorEventArgs e)
{
// handles the 'connection refused' connect cases
_connectEvent.Set();
// https://www.interactivebrokers.com/en/software/api/apiguide/tables/api_message_codes.htm
var requestId = e.Id;
@@ -2244,51 +2266,82 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// </summary>
private Symbol MapSymbol(Contract contract)
{
var securityType = ConvertSecurityType(contract);
var ibSymbol = securityType == SecurityType.Forex ? contract.Symbol + contract.Currency : contract.Symbol;
var market = InteractiveBrokersBrokerageModel.DefaultMarketMap[securityType];
var isFutureOption = contract.SecType == IB.SecurityType.FutureOption;
// Handle future options as a Future, up until we actually return the future.
if (isFutureOption || securityType == SecurityType.Future)
try
{
var leanSymbol = _symbolMapper.GetLeanRootSymbol(ibSymbol);
var defaultMarket = market;
if (!_symbolPropertiesDatabase.TryGetMarket(leanSymbol, SecurityType.Future, out market))
var securityType = ConvertSecurityType(contract);
var ibSymbol = securityType == SecurityType.Forex ? contract.Symbol + contract.Currency : contract.Symbol;
var market = InteractiveBrokersBrokerageModel.DefaultMarketMap[securityType];
var isFutureOption = contract.SecType == IB.SecurityType.FutureOption;
if ((isFutureOption || securityType == SecurityType.Option) &&
contract.LastTradeDateOrContractMonth == "0")
{
market = defaultMarket;
// Try our best to recover from a malformed contract.
// You can read more about malformed contracts at the ParseMalformedContract method's documentation.
var exchange = GetSymbolExchange(securityType, market);
contract = InteractiveBrokersSymbolMapper.ParseMalformedContractOptionSymbol(contract, exchange);
ibSymbol = contract.Symbol;
}
else if (securityType == SecurityType.Future && contract.LastTradeDateOrContractMonth == "0")
{
contract = _symbolMapper.ParseMalformedContractFutureSymbol(contract, _symbolPropertiesDatabase);
ibSymbol = contract.Symbol;
}
var contractExpiryDate = DateTime.ParseExact(contract.LastTradeDateOrContractMonth, DateFormat.EightCharacter, CultureInfo.InvariantCulture);
if (!isFutureOption)
// Handle future options as a Future, up until we actually return the future.
if (isFutureOption || securityType == SecurityType.Future)
{
return _symbolMapper.GetLeanSymbol(ibSymbol, SecurityType.Future, market, contractExpiryDate);
var leanSymbol = _symbolMapper.GetLeanRootSymbol(ibSymbol);
var defaultMarket = market;
if (!_symbolPropertiesDatabase.TryGetMarket(leanSymbol, SecurityType.Future, out market))
{
market = defaultMarket;
}
var contractExpiryDate = DateTime.ParseExact(contract.LastTradeDateOrContractMonth, DateFormat.EightCharacter, CultureInfo.InvariantCulture);
if (!isFutureOption)
{
return _symbolMapper.GetLeanSymbol(ibSymbol, SecurityType.Future, market, contractExpiryDate);
}
// Get the *actual* futures contract that this futures options contract has as its underlying.
// Futures options contracts can have a different contract month from their underlying future.
// As such, we resolve the underlying future to the future with the correct contract month.
// There's a chance this can fail, and if it does, we throw because this Symbol can't be
// represented accurately in Lean.
var futureSymbol = FuturesOptionsUnderlyingMapper.GetUnderlyingFutureFromFutureOption(leanSymbol, market, contractExpiryDate, _algorithm.Time);
if (futureSymbol == null)
{
// This is the worst case scenario, because we didn't find a matching futures contract for the FOP.
// Note that this only applies to CBOT symbols for now.
throw new ArgumentException($"The Future Option contract: {GetContractDescription(contract)} with trading class: {contract.TradingClass} has no matching underlying future contract.");
}
var right = contract.Right == IB.RightType.Call ? OptionRight.Call : OptionRight.Put;
var strike = Convert.ToDecimal(contract.Strike);
return Symbol.CreateOption(futureSymbol, market, OptionStyle.American, right, strike, contractExpiryDate);
}
// Create a canonical future Symbol for lookup in the FuturesExpiryFunctions helper class.
// We then get the delta between the futures option's expiry month vs. the future's expiry month.
var canonicalFutureSymbol = _symbolMapper.GetLeanSymbol(ibSymbol, SecurityType.Future, market, SecurityIdentifier.DefaultDate);
var futureExpiryFunction = FuturesExpiryFunctions.FuturesExpiryFunction(canonicalFutureSymbol);
var futureContractExpiryDate = futureExpiryFunction(FuturesOptionsExpiryFunctions.GetFutureContractMonth(canonicalFutureSymbol, contractExpiryDate));
var futureSymbol = Symbol.CreateFuture(canonicalFutureSymbol.ID.Symbol, canonicalFutureSymbol.ID.Market, futureContractExpiryDate);
if (securityType == SecurityType.Option)
{
var expiryDate = DateTime.ParseExact(contract.LastTradeDateOrContractMonth, DateFormat.EightCharacter, CultureInfo.InvariantCulture);
var right = contract.Right == IB.RightType.Call ? OptionRight.Call : OptionRight.Put;
var strike = Convert.ToDecimal(contract.Strike);
var right = contract.Right == IB.RightType.Call ? OptionRight.Call : OptionRight.Put;
var strike = Convert.ToDecimal(contract.Strike);
return _symbolMapper.GetLeanSymbol(ibSymbol, securityType, market, expiryDate, strike, right);
}
return Symbol.CreateOption(futureSymbol, market, OptionStyle.American, right, strike, contractExpiryDate);
return _symbolMapper.GetLeanSymbol(ibSymbol, securityType, market);
}
if (securityType == SecurityType.Option)
catch (Exception error)
{
var expiryDate = DateTime.ParseExact(contract.LastTradeDateOrContractMonth, DateFormat.EightCharacter, CultureInfo.InvariantCulture);
var right = contract.Right == IB.RightType.Call ? OptionRight.Call : OptionRight.Put;
var strike = Convert.ToDecimal(contract.Strike);
return _symbolMapper.GetLeanSymbol(ibSymbol, securityType, market, expiryDate, strike, right);
throw new Exception($"InteractiveBrokersBrokerage.MapSymbol(): Failed to convert contract for {contract.Symbol}; Contract description: {GetContractDescription(contract)}", error);
}
return _symbolMapper.GetLeanSymbol(ibSymbol, securityType, market);
}
private static decimal RoundPrice(decimal input, decimal minTick)
@@ -2374,7 +2427,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
// we ignore futures canonical symbol
if (symbol.ID.SecurityType == SecurityType.Future && symbol.IsCanonical())
{
return false;
continue;
}
var id = GetNextId();
@@ -2401,10 +2454,10 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
_subscribedTickers[id] = new SubscriptionEntry { Symbol = subscribeSymbol };
Log.Trace($"InteractiveBrokersBrokerage.Subscribe(): Subscribe Processed: {symbol.Value} ({GetContractDescription(contract)}) # {id}");
return true;
}
}
}
return true;
}
catch (Exception err)
{
@@ -3087,10 +3140,11 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <summary>
/// Gets the exchange the Symbol should be routed to
/// </summary>
/// <param name="symbol">Symbol to route</param>
private string GetSymbolExchange(Symbol symbol)
/// <param name="securityType">SecurityType of the Symbol</param>
/// <param name="market">Market of the Symbol</param>
private string GetSymbolExchange(SecurityType securityType, string market)
{
switch (symbol.SecurityType)
switch (securityType)
{
case SecurityType.Option:
// Regular equity options uses default, in this case "Smart"
@@ -3099,15 +3153,24 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
// Futures options share the same market as the underlying Symbol
case SecurityType.FutureOption:
case SecurityType.Future:
return _futuresExchanges.ContainsKey(symbol.ID.Market)
? _futuresExchanges[symbol.ID.Market]
: symbol.ID.Market;
return _futuresExchanges.ContainsKey(market)
? _futuresExchanges[market]
: market;
default:
return "Smart";
}
}
/// <summary>
/// Gets the exchange the Symbol should be routed to
/// </summary>
/// <param name="symbol">Symbol to route</param>
private string GetSymbolExchange(Symbol symbol)
{
return GetSymbolExchange(symbol.SecurityType, symbol.ID.Market);
}
/// <summary>
/// Returns whether the brokerage should perform the cash synchronization
/// </summary>
@@ -3220,7 +3283,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
// these are warning messages from IB
private static readonly HashSet<int> WarningCodes = new HashSet<int>
{
102, 104, 105, 106, 107, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 131, 132, 133, 134, 135, 136, 137, 140, 141, 146, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 201, 303,313,314,315,319,325,328,329,334,335,336,337,338,339,340,341,342,343,345,347,348,349,350,352,353,355,356,358,359,360,361,362,363,364,367,368,369,370,371,372,373,374,375,376,377,378,379,380,382,383,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,402,403,404,405,406,407,408,409,410,411,412,413,417,418,419,420,421,422,423,424,425,426,427,428,429,430,433,434,435,436,437,439,440,441,442,443,444,445,446,447,448,449,450,1100,10002,10003,10006,10007,10008,10009,10010,10011,10012,10014,10018,10019,10020,10052,10147,10148,10149,1101,1102,2100,2101,2102,2103,2105,2109,2110,2148
102, 104, 105, 106, 107, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 131, 132, 133, 134, 135, 136, 137, 140, 141, 146, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 201, 303,313,314,315,319,325,328,329,334,335,336,337,338,339,340,341,342,343,345,347,348,349,350,352,353,355,356,358,359,360,361,362,363,364,367,368,369,370,371,372,373,374,375,376,377,378,379,380,382,383,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,402,403,404,405,406,407,408,409,410,411,412,413,417,418,419,420,421,422,423,424,425,426,427,428,429,430,433,434,435,436,437,439,440,441,442,443,444,445,446,447,448,449,450,10002,10003,10006,10007,10008,10009,10010,10011,10012,10014,10018,10019,10020,10052,10147,10148,10149,2100,2101,2102,2109,2148
};
// these require us to issue invalidated order events

View File

@@ -97,6 +97,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
algorithm.Transactions,
algorithm.Portfolio,
Composer.Instance.GetExportedValueByTypeName<IDataAggregator>(Config.Get("data-aggregator", "QuantConnect.Lean.Engine.DataFeeds.AggregationManager")),
Composer.Instance.GetExportedValueByTypeName<IMapFileProvider>(Config.Get("map-file-provider", "QuantConnect.Data.Auxiliary.LocalDiskMapFileProvider")),
account,
host,
port,

View File

@@ -14,12 +14,19 @@
*/
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using QuantConnect.Interfaces;
using QuantConnect.Securities.Future;
using QuantConnect.Securities.FutureOption;
using IB = QuantConnect.Brokerages.InteractiveBrokers.Client;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using IBApi;
using QuantConnect.Logging;
using QuantConnect.Securities;
namespace QuantConnect.Brokerages.InteractiveBrokers
{
@@ -28,6 +35,8 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// </summary>
public class InteractiveBrokersSymbolMapper : ISymbolMapper
{
private readonly IMapFileProvider _mapFileProvider;
// we have a special treatment of futures, because IB renamed several exchange tickers (like GBP instead of 6B). We fix this:
// We map those tickers back to their original names using the map below
private readonly Dictionary<string, string> _ibNameMap = new Dictionary<string, string>();
@@ -35,9 +44,10 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <summary>
/// Constructs InteractiveBrokersSymbolMapper. Default parameters are used.
/// </summary>
public InteractiveBrokersSymbolMapper():
public InteractiveBrokersSymbolMapper(IMapFileProvider mapFileProvider) :
this(Path.Combine("InteractiveBrokers", "IB-symbol-map.json"))
{
_mapFileProvider = mapFileProvider;
}
/// <summary>
@@ -67,9 +77,14 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
/// <returns>The InteractiveBrokers symbol</returns>
public string GetBrokerageSymbol(Symbol symbol)
{
if (symbol == null || string.IsNullOrWhiteSpace(symbol.Value))
if (string.IsNullOrWhiteSpace(symbol?.Value))
throw new ArgumentException("Invalid symbol: " + (symbol == null ? "null" : symbol.ToString()));
var ticker = GetMappedTicker(symbol);
if (string.IsNullOrWhiteSpace(ticker))
throw new ArgumentException("Invalid symbol: " + symbol.ToString());
if (symbol.ID.SecurityType != SecurityType.Forex &&
symbol.ID.SecurityType != SecurityType.Equity &&
symbol.ID.SecurityType != SecurityType.Option &&
@@ -77,7 +92,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
symbol.ID.SecurityType != SecurityType.Future)
throw new ArgumentException("Invalid security type: " + symbol.ID.SecurityType);
if (symbol.ID.SecurityType == SecurityType.Forex && symbol.Value.Length != 6)
if (symbol.ID.SecurityType == SecurityType.Forex && ticker.Length != 6)
throw new ArgumentException("Forex symbol length must be equal to 6: " + symbol.Value);
switch (symbol.ID.SecurityType)
@@ -85,7 +100,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
case SecurityType.Option:
// Final case is for equities. We use the mapped value to select
// the equity we want to trade.
return symbol.Underlying.Value;
return GetMappedTicker(symbol.Underlying);
case SecurityType.FutureOption:
// We use the underlying Future Symbol since IB doesn't use
@@ -97,10 +112,10 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
return GetBrokerageRootSymbol(symbol.ID.Symbol);
case SecurityType.Equity:
return symbol.Value.Replace(".", " ");
return ticker.Replace(".", " ");
}
return symbol.Value;
return ticker;
}
/// <summary>
@@ -136,15 +151,21 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
return Symbol.CreateOption(brokerageSymbol, market, OptionStyle.American, optionRight, strike, expirationDate);
case SecurityType.FutureOption:
var canonicalFutureSymbol = Symbol.Create(GetLeanRootSymbol(brokerageSymbol), SecurityType.Future, market);
var futureContractMonth = FuturesOptionsExpiryFunctions.GetFutureContractMonth(canonicalFutureSymbol, expirationDate);
var futureExpiry = FuturesExpiryFunctions.FuturesExpiryFunction(canonicalFutureSymbol)(futureContractMonth);
var future = FuturesOptionsUnderlyingMapper.GetUnderlyingFutureFromFutureOption(
GetLeanRootSymbol(brokerageSymbol),
market,
expirationDate,
DateTime.Now);
if (future == null)
{
// This is the worst case scenario, because we didn't find a matching futures contract for the FOP.
// Note that this only applies to CBOT symbols for now.
throw new ArgumentException($"The Future Option with expected underlying of {future} with expiry: {expirationDate:yyyy-MM-dd} has no matching underlying future contract.");
}
return Symbol.CreateOption(
Symbol.CreateFuture(
brokerageSymbol,
market,
futureExpiry),
future,
market,
OptionStyle.American,
optionRight,
@@ -173,7 +194,7 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
{
var brokerageSymbol = _ibNameMap.FirstOrDefault(kv => kv.Value == rootSymbol);
return brokerageSymbol.Key??rootSymbol;
return brokerageSymbol.Key ?? rootSymbol;
}
/// <summary>
@@ -186,5 +207,117 @@ namespace QuantConnect.Brokerages.InteractiveBrokers
return _ibNameMap.ContainsKey(brokerageRootSymbol) ? _ibNameMap[brokerageRootSymbol] : brokerageRootSymbol;
}
/// <summary>
/// Parses a contract for future with malformed data.
/// Malformed data usually manifests itself by having "0" assigned to some values
/// we expect, like the contract's expiry date. The contract is returned by IB
/// like this, usually due to a high amount of data subscriptions that are active
/// in an account, surpassing IB's imposed limit. Read more about this here: https://interactivebrokers.github.io/tws-api/rtd_fqa_errors.html#rtd_common_errors_maxmktdata
///
/// We are provided a string in the Symbol in malformed contracts that can be
/// parsed to construct the clean contract, which is done by this method.
/// </summary>
/// <param name="malformedContract">Malformed contract (for futures), i.e. a contract with invalid values ("0") in some of its fields</param>
/// <param name="symbolPropertiesDatabase">The symbol properties database to use</param>
/// <returns>Clean Contract for the future</returns>
/// <remarks>
/// The malformed contract returns data similar to the following when calling <see cref="InteractiveBrokersBrokerage.GetContractDetails"/>: ES MAR2021
/// </remarks>
public Contract ParseMalformedContractFutureSymbol(Contract malformedContract, SymbolPropertiesDatabase symbolPropertiesDatabase)
{
Log.Trace($"InteractiveBrokersSymbolMapper.ParseMalformedContractFutureSymbol(): Parsing malformed contract: {InteractiveBrokersBrokerage.GetContractDescription(malformedContract)} with trading class: \"{malformedContract.TradingClass}\"");
// capture any character except spaces, match spaces, capture any char except digits, capture digits
var matches = Regex.Matches(malformedContract.Symbol, @"^(\S*)\s*(\D*)(\d*)");
var match = matches[0].Groups;
var contractSymbol = match[1].Value;
var contractMonthExpiration = DateTime.ParseExact(match[2].Value, "MMM", CultureInfo.CurrentCulture).Month;
var contractYearExpiration = match[3].Value;
var leanSymbol = GetLeanRootSymbol(contractSymbol);
string market;
if (!symbolPropertiesDatabase.TryGetMarket(leanSymbol, SecurityType.Future, out market))
{
market = InteractiveBrokersBrokerageModel.DefaultMarketMap[SecurityType.Future];
}
var canonicalSymbol = Symbol.Create(leanSymbol, SecurityType.Future, market);
var contractMonthYear = new DateTime(int.Parse(contractYearExpiration, CultureInfo.InvariantCulture), contractMonthExpiration, 1);
// we get the expiration date using the FuturesExpiryFunctions
var contractExpirationDate = FuturesExpiryFunctions.FuturesExpiryFunction(canonicalSymbol)(contractMonthYear);
return new Contract
{
Symbol = contractSymbol,
Multiplier = malformedContract.Multiplier,
LastTradeDateOrContractMonth = $"{contractExpirationDate:yyyyMMdd}",
Exchange = malformedContract.Exchange,
SecType = malformedContract.SecType,
IncludeExpired = false,
Currency = malformedContract.Currency
};
}
private string GetMappedTicker(Symbol symbol)
{
var ticker = symbol.Value;
if (symbol.ID.SecurityType == SecurityType.Equity)
{
var mapFile = _mapFileProvider.Get(symbol.ID.Market).ResolveMapFile(symbol.ID.Symbol, symbol.ID.Date);
ticker = mapFile.GetMappedSymbol(DateTime.UtcNow, symbol.Value);
}
return ticker;
}
/// <summary>
/// Parses a contract for options with malformed data.
/// Malformed data usually manifests itself by having "0" assigned to some values
/// we expect, like the contract's expiry date. The contract is returned by IB
/// like this, usually due to a high amount of data subscriptions that are active
/// in an account, surpassing IB's imposed limit. Read more about this here: https://interactivebrokers.github.io/tws-api/rtd_fqa_errors.html#rtd_common_errors_maxmktdata
///
/// We are provided a string in the Symbol in malformed contracts that can be
/// parsed to construct the clean contract, which is done by this method.
/// </summary>
/// <param name="malformedContract">Malformed contract (for options), i.e. a contract with invalid values ("0") in some of its fields</param>
/// <param name="exchange">Exchange that the contract's asset lives on/where orders will be routed through</param>
/// <returns>Clean Contract for the option</returns>
/// <remarks>
/// The malformed contract returns data similar to the following when calling <see cref="InteractiveBrokersBrokerage.GetContractDetails"/>:
/// OPT SPY JUN2021 350 P [SPY 210618P00350000 100] USD 0 0 0
///
/// ... which the contents inside [] follow the pattern:
///
/// [SYMBOL YY_MM_DD_OPTIONRIGHT_STRIKE(divide by 1000) MULTIPLIER]
/// </remarks>
public static Contract ParseMalformedContractOptionSymbol(Contract malformedContract, string exchange = "Smart")
{
Log.Trace($"InteractiveBrokersSymbolMapper.ParseMalformedContractOptionSymbol(): Parsing malformed contract: {InteractiveBrokersBrokerage.GetContractDescription(malformedContract)} with trading class: \"{malformedContract.TradingClass}\"");
// we search for the '[ ]' pattern, inside of it we: (capture any character except spaces, match spaces) -> 3 times
var matches = Regex.Matches(malformedContract.Symbol, @"^.*[\[](\S*)\s*(\S*)\s*(\S*)[\]]");
var match = matches[0].Groups;
var contractSymbol = match[1].Value;
var contractSpecification = match[2].Value;
var multiplier = match[3].Value;
var expiryDate = "20" + contractSpecification.Substring(0, 6);
var contractRight = contractSpecification[6] == 'C' ? IB.RightType.Call : IB.RightType.Put;
var contractStrike = long.Parse(contractSpecification.Substring(7), CultureInfo.InvariantCulture) / 1000.0;
return new Contract
{
Symbol = contractSymbol,
Multiplier = multiplier,
LastTradeDateOrContractMonth = expiryDate,
Right = contractRight,
Strike = contractStrike,
Exchange = exchange,
SecType = malformedContract.SecType,
IncludeExpired = false,
Currency = malformedContract.Currency
};
}
}
}

View File

@@ -1,696 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2D3E13CF-2D14-4180-A42D-F0A13AF0ADE2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuantConnect.Brokerages</RootNamespace>
<AssemblyName>QuantConnect.Brokerages</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>net462</TargetFramework>
<LangVersion>6</LangVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<DefineConstants>NET45</DefineConstants>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DocumentationFile>bin\$(Configuration)\QuantConnect.Brokerages.xml</DocumentationFile>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>$(SelectedOptimization)</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NET45</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\QuantConnect.Brokerages.xml</DocumentationFile>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NET45</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
<CodeAnalysisRuleSet>..\QuantConnect.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\Release\QuantConnect.Brokerages.xml</DocumentationFile>
</PropertyGroup>
<Target Name="Print" BeforeTargets="Build">
<Message Text="SelectedOptimization $(SelectedOptimization)" Importance="high" />
</Target>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IKVM" Version="8.1.5717.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VersionCheckAnalyzer" Version="2.9.3" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="2.9.3" />
<PackageReference Include="Microsoft.NetFramework.Analyzers" Version="2.9.3" />
<PackageReference Include="NATS.Client" Version="0.8.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="NodaTime" Version="1.3.4" />
<PackageReference Include="QuantConnect.IBAutomater" Version="1.0.43" />
<PackageReference Include="RestSharp" Version="106.6.10" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="CSharpAPI">
<HintPath>InteractiveBrokers\CSharpAPI.dll</HintPath>
</Reference>
<Reference Include="IKVM.AWT.WinForms, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.AWT.WinForms.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Beans, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Beans.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Charsets, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Charsets.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Cldrdata, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Cldrdata.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Corba, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Corba.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Core.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Jdbc, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Jdbc.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Localedata, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Localedata.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Management, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Management.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Media, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Media.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Misc, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Misc.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Naming, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Naming.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Nashorn, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Nashorn.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Remoting, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Remoting.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Security, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Security.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.SwingAWT, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.SwingAWT.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Text, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Text.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Tools, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Tools.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.Util, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.Util.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.API, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.API.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.Bind, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.Bind.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.Crypto, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.Crypto.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.Parse, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.Parse.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.Transform, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.Transform.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.WebServices, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.WebServices.dll</HintPath>
</Reference>
<Reference Include="IKVM.OpenJDK.XML.XPath, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.OpenJDK.XML.XPath.dll</HintPath>
</Reference>
<Reference Include="IKVM.Runtime, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.Runtime.dll</HintPath>
</Reference>
<Reference Include="IKVM.Runtime.JNI, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
<HintPath>..\packages\IKVM.8.1.5717.0\lib\IKVM.Runtime.JNI.dll</HintPath>
</Reference>
<Reference Include="NATS.Client, Version=0.8.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NATS.Client.0.8.1\lib\net45\NATS.Client.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.1.3.4\lib\net35-Client\NodaTime.dll</HintPath>
</Reference>
<Reference Include="QuantConnect.Fxcm, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Fxcm\QuantConnect.Fxcm.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="QuantConnect.IBAutomater, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QuantConnect.IBAutomater.1.0.35\lib\net45\QuantConnect.IBAutomater.exe</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.6.10.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.6.10\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Alpaca\AlpacaBrokerage.cs" />
<Compile Include="Alpaca\AlpacaBrokerage.Utility.cs" />
<Compile Include="Alpaca\AlpacaBrokerageFactory.cs" />
<Compile Include="Alpaca\Markets\AlpacaTradingClient.cs" />
<Compile Include="Alpaca\Markets\AlpacaTradingClient.General.cs" />
<Compile Include="Alpaca\Markets\AlpacaTradingClient.Orders.cs" />
<Compile Include="Alpaca\Markets\Authentication\SecretKey.cs" />
<Compile Include="Alpaca\Markets\Authentication\SecurityKey.cs" />
<Compile Include="Alpaca\Markets\Enums\AccountActivityType.cs" />
<Compile Include="Alpaca\Markets\Enums\AccountStatus.cs" />
<Compile Include="Alpaca\Markets\Enums\AggregationPeriodUnit.cs" />
<Compile Include="Alpaca\Markets\Enums\AggregationType.cs" />
<Compile Include="Alpaca\Markets\Enums\ApiVersion.cs" />
<Compile Include="Alpaca\Markets\Enums\AssetClass.cs" />
<Compile Include="Alpaca\Markets\Enums\AssetStatus.cs" />
<Compile Include="Alpaca\Markets\Enums\AuthStatus.cs" />
<Compile Include="Alpaca\Markets\Enums\ConnectionStatus.cs" />
<Compile Include="Alpaca\Markets\Enums\DayTradeMarginCallProtection.cs" />
<Compile Include="Alpaca\Markets\Enums\Exchange.cs" />
<Compile Include="Alpaca\Markets\Enums\ExchangeType.cs" />
<Compile Include="Alpaca\Markets\Enums\HistoryPeriodUnit.cs" />
<Compile Include="Alpaca\Markets\Enums\JsonAction.cs" />
<Compile Include="Alpaca\Markets\Enums\MarketDataType.cs" />
<Compile Include="Alpaca\Markets\Enums\OrderClass.cs" />
<Compile Include="Alpaca\Markets\Enums\OrderSide.cs" />
<Compile Include="Alpaca\Markets\Enums\OrderStatus.cs" />
<Compile Include="Alpaca\Markets\Enums\OrderStatusFilter.cs" />
<Compile Include="Alpaca\Markets\Enums\OrderType.cs" />
<Compile Include="Alpaca\Markets\Enums\PositionSide.cs" />
<Compile Include="Alpaca\Markets\Enums\SortDirection.cs" />
<Compile Include="Alpaca\Markets\Enums\TickType.cs" />
<Compile Include="Alpaca\Markets\Enums\TimeFrame.cs" />
<Compile Include="Alpaca\Markets\Enums\TimeInForce.cs" />
<Compile Include="Alpaca\Markets\Enums\TradeConfirmEmail.cs" />
<Compile Include="Alpaca\Markets\Enums\TradeEvent.cs" />
<Compile Include="Alpaca\Markets\Environment\Environments.cs" />
<Compile Include="Alpaca\Markets\Environment\IEnvironment.cs" />
<Compile Include="Alpaca\Markets\Environment\LiveEnvironment.cs" />
<Compile Include="Alpaca\Markets\Environment\PaperEnvironment.cs" />
<Compile Include="Alpaca\Markets\Exceptions\RequestValidationException.cs" />
<Compile Include="Alpaca\Markets\Exceptions\RestClientErrorException.cs" />
<Compile Include="Alpaca\Markets\FakeThrottler.cs" />
<Compile Include="Alpaca\Markets\Helpers\ActionExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\CustomTimeZone.cs" />
<Compile Include="Alpaca\Markets\Helpers\DateConverter.cs" />
<Compile Include="Alpaca\Markets\Helpers\DateTimeHelper.cs" />
<Compile Include="Alpaca\Markets\Helpers\EnumExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\ExchangeEnumConverter.cs" />
<Compile Include="Alpaca\Markets\Helpers\HttpClientExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\HttpStatusCodeExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\ListExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\NullableHelper.cs" />
<Compile Include="Alpaca\Markets\Helpers\QueryBuilder.cs" />
<Compile Include="Alpaca\Markets\Helpers\TimeConverter.cs" />
<Compile Include="Alpaca\Markets\Helpers\UriExtensions.cs" />
<Compile Include="Alpaca\Markets\Helpers\Validation.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAccount.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAccountActivity.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAccountBase.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAccountConfiguration.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAccountUpdate.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAgg.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAggBase.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAggHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IAsset.cs" />
<Compile Include="Alpaca\Markets\Interfaces\ICalendar.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IClock.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IDayHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IExchange.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IHistoricalBase.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IHistoricalQuote.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IHistoricalTrade.cs" />
<Compile Include="Alpaca\Markets\Interfaces\ILastQuote.cs" />
<Compile Include="Alpaca\Markets\Interfaces\ILastTrade.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IOrder.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IOrderActionStatus.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IPortfolioHistory.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IPortfolioHistoryItem.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IPosition.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IPositionActionStatus.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IQuoteBase.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IStreamAgg.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IStreamQuote.cs" />
<Compile Include="Alpaca\Markets\Interfaces\IStreamTrade.cs" />
<Compile Include="Alpaca\Markets\Interfaces\ITimestamps.cs" />
<Compile Include="Alpaca\Markets\Interfaces\ITradeUpdate.cs" />
<Compile Include="Alpaca\Markets\IThrottler.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAccount.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAccountActivity.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAccountConfiguration.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAccountUpdate.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAggHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAsset.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAuthRequest.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonAuthResponse.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonBarAgg.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonCalendar.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonChangeOrder.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonClock.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonConnectionStatus.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonDayHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonError.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonExchange.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonHistoricalItems.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonHistoricalQuote.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonHistoricalTrade.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonLastQuote.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonLastTrade.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonListenRequest.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonMinuteAgg.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonNewOrder.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonNewOrderAdvancedAttributes.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonOrder.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonOrderActionStatus.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonPortfolioHistory.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonPosition.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonPositionActionStatus.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonStreamAgg.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonStreamQuote.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonStreamTrade.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonTradeUpdate.cs" />
<Compile Include="Alpaca\Markets\Messages\JsonUnsubscribeRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\AccountActivitiesRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\AggregatesRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\AggregationPeriod.cs" />
<Compile Include="Alpaca\Markets\Parameters\AlpacaTradingClientConfiguration.cs" />
<Compile Include="Alpaca\Markets\Parameters\AssetsRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\CalendarRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\ChangeOrderRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\HistoricalRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\HistoryPeriod.cs" />
<Compile Include="Alpaca\Markets\Parameters\ListOrdersRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\NewOrderRequest.cs" />
<Compile Include="Alpaca\Markets\Parameters\PolygonDataClientConfiguration.cs" />
<Compile Include="Alpaca\Markets\Parameters\PortfolioHistoryRequest.cs" />
<Compile Include="Alpaca\Markets\PolygonDataClient.cs" />
<Compile Include="Alpaca\Markets\RateThrottler.cs" />
<Compile Include="Alpaca\Markets\SockClient.cs" />
<Compile Include="Alpaca\Markets\ThrottleParameters.cs" />
<Compile Include="Backtesting\BacktestingBrokerage.cs" />
<Compile Include="Backtesting\BacktestingBrokerageFactory.cs" />
<Compile Include="Backtesting\BasicOptionAssignmentSimulation.cs" />
<Compile Include="Backtesting\IBacktestingMarketSimulation.cs" />
<Compile Include="BaseWebsocketsBrokerage.cs" />
<Compile Include="Binance\BinanceBrokerage.Utility.cs" />
<Compile Include="Binance\BinanceBrokerage.cs" />
<Compile Include="Binance\BinanceBrokerageFactory.cs" />
<Compile Include="Binance\BinanceOrderSubmitEventArgs.cs" />
<Compile Include="Binance\BinanceRestApiClient.cs" />
<Compile Include="Binance\BinanceWebSocketWrapper.cs" />
<Compile Include="Binance\Messages.cs" />
<Compile Include="Bitfinex\BitfinexBrokerage.Messaging.cs" />
<Compile Include="Bitfinex\BitfinexBrokerage.cs" />
<Compile Include="Bitfinex\BitfinexBrokerageFactory.cs" />
<Compile Include="Bitfinex\BitfinexBrokerage.Utility.cs" />
<Compile Include="Bitfinex\BitfinexSubscriptionManager.cs" />
<Compile Include="Bitfinex\BitfinexWebSocketChannels.cs" />
<Compile Include="Bitfinex\BitfinexWebSocketWrapper.cs" />
<Compile Include="Bitfinex\Messages\Messages.cs" />
<Compile Include="Bitfinex\Messages\Order.cs" />
<Compile Include="Bitfinex\Messages\Position.cs" />
<Compile Include="Bitfinex\Messages\Ticker.cs" />
<Compile Include="Bitfinex\Messages\TradeExecutionUpdate.cs" />
<Compile Include="Bitfinex\Messages\Wallet.cs" />
<Compile Include="Bitfinex\Converters\TradeExecutionUpdateConverter.cs" />
<Compile Include="Bitfinex\Converters\OrderConverter.cs" />
<Compile Include="Bitfinex\Messages\OrderFlags.cs" />
<Compile Include="Bitfinex\Converters\TickerConverter.cs" />
<Compile Include="Bitfinex\Converters\PositionConverter.cs" />
<Compile Include="Bitfinex\Converters\WalletConverter.cs" />
<Compile Include="InteractiveBrokers\Client\FamilyCodesEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\AccountSummaryEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ManagedAccountsEventArgs.cs" />
<Compile Include="InteractiveBrokers\InteractiveBrokersStateManager.cs" />
<Compile Include="IOrderBookUpdater.cs" />
<Compile Include="DefaultOrderBook.cs" />
<Compile Include="Brokerage.cs" />
<Compile Include="BrokerageException.cs" />
<Compile Include="BrokerageFactory.cs" />
<Compile Include="DefaultConnectionHandler.cs" />
<Compile Include="Fxcm\FxcmBrokerage.cs" />
<Compile Include="Fxcm\FxcmBrokerage.DataQueueHandler.cs" />
<Compile Include="Fxcm\FxcmBrokerage.Messaging.cs" />
<Compile Include="Fxcm\FxcmBrokerage.Util.cs" />
<Compile Include="Fxcm\FxcmBrokerageFactory.cs" />
<Compile Include="Fxcm\FxcmSymbolMapper.cs" />
<Compile Include="GDAX\AuthenticationToken.cs" />
<Compile Include="BestBidAskUpdatedEventArgs.cs" />
<Compile Include="GDAX\GDAXBrokerage.Utility.cs" />
<Compile Include="GDAX\GDAXBrokerage.cs" />
<Compile Include="GDAX\GDAXBrokerageFactory.cs" />
<Compile Include="GDAX\GDAXDataQueueHandler.cs" />
<Compile Include="GDAX\GDAXFill.cs" />
<Compile Include="GDAX\GDAXBrokerage.Messaging.cs" />
<Compile Include="IConnectionHandler.cs" />
<Compile Include="IWebSocket.cs" />
<Compile Include="GDAX\Messages.cs" />
<Compile Include="ApiPriceProvider.cs" />
<Compile Include="SymbolPropertiesDatabaseSymbolMapper.cs" />
<Compile Include="WebSocketCloseData.cs" />
<Compile Include="WebSocketError.cs" />
<Compile Include="WebSocketMessage.cs" />
<Compile Include="WebSocketClientWrapper.cs" />
<Compile Include="InteractiveBrokers\Client\AccountDownloadEndEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ActionSide.cs" />
<Compile Include="InteractiveBrokers\Client\AgentDescription.cs" />
<Compile Include="InteractiveBrokers\Client\BarSize.cs" />
<Compile Include="InteractiveBrokers\Client\OrderStatus.cs" />
<Compile Include="InteractiveBrokers\Client\OrderType.cs" />
<Compile Include="InteractiveBrokers\Client\RightType.cs" />
<Compile Include="InteractiveBrokers\Client\SecurityType.cs" />
<Compile Include="InteractiveBrokers\Client\CommissionReportEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ContractDetailsEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\CurrentTimeUtcEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ErrorEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ExecutionDetailsEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\HistoricalDataEndEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\HistoricalDataEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\NextValidIdEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\OpenOrderEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\OrderStatusEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\TimeInForce.cs" />
<Compile Include="InteractiveBrokers\Client\RequestEndEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\ReceiveFaEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\TickEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\TickPriceEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\TickSizeEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\UpdateAccountValueEventArgs.cs" />
<Compile Include="InteractiveBrokers\Client\UpdatePortfolioEventArgs.cs" />
<Compile Include="InteractiveBrokers\FinancialAdvisor\Allocation.cs" />
<Compile Include="InteractiveBrokers\FinancialAdvisor\AllocationProfile.cs" />
<Compile Include="InteractiveBrokers\FinancialAdvisor\Group.cs" />
<Compile Include="InteractiveBrokers\FinancialAdvisor\AccountAlias.cs" />
<Compile Include="InteractiveBrokers\FinancialAdvisor\FinancialAdvisorConfiguration.cs" />
<Compile Include="InteractiveBrokers\HistoricalDataType.cs" />
<Compile Include="InteractiveBrokers\InteractiveBrokersAccountData.cs" />
<Compile Include="InteractiveBrokers\InteractiveBrokersBrokerage.cs" />
<Compile Include="InteractiveBrokers\InteractiveBrokersBrokerageFactory.cs" />
<Compile Include="InteractiveBrokers\Client\InteractiveBrokersClient.cs" />
<Compile Include="InteractiveBrokers\InteractiveBrokersSymbolMapper.cs" />
<Compile Include="ISymbolMapper.cs" />
<Compile Include="Oanda\OandaRestApiBase.cs" />
<Compile Include="Oanda\OandaRestApiV20.cs" />
<Compile Include="Oanda\Environment.cs" />
<Compile Include="Oanda\OandaBrokerage.cs" />
<Compile Include="Oanda\OandaBrokerageFactory.cs" />
<Compile Include="Oanda\OandaSymbolMapper.cs" />
<Compile Include="Oanda\RestV20\Api\DefaultApi.cs" />
<Compile Include="Oanda\RestV20\Client\ApiClient.cs" />
<Compile Include="Oanda\RestV20\Client\ApiException.cs" />
<Compile Include="Oanda\RestV20\Client\ApiResponse.cs" />
<Compile Include="Oanda\RestV20\Client\Configuration.cs" />
<Compile Include="Oanda\RestV20\Client\ExceptionFactory.cs" />
<Compile Include="Oanda\RestV20\Client\IApiAccessor.cs" />
<Compile Include="Oanda\RestV20\DefaultApiExtensions.cs" />
<Compile Include="Oanda\RestV20\Model\AcceptDatetimeFormat.cs" />
<Compile Include="Oanda\RestV20\Model\Account.cs" />
<Compile Include="Oanda\RestV20\Model\AccountChanges.cs" />
<Compile Include="Oanda\RestV20\Model\AccountChangesState.cs" />
<Compile Include="Oanda\RestV20\Model\AccountFinancingMode.cs" />
<Compile Include="Oanda\RestV20\Model\AccountID.cs" />
<Compile Include="Oanda\RestV20\Model\AccountProperties.cs" />
<Compile Include="Oanda\RestV20\Model\AccountSummary.cs" />
<Compile Include="Oanda\RestV20\Model\AccountUnits.cs" />
<Compile Include="Oanda\RestV20\Model\CalculatedPositionState.cs" />
<Compile Include="Oanda\RestV20\Model\CalculatedTradeState.cs" />
<Compile Include="Oanda\RestV20\Model\Candlestick.cs" />
<Compile Include="Oanda\RestV20\Model\CandlestickData.cs" />
<Compile Include="Oanda\RestV20\Model\CandlestickGranularity.cs" />
<Compile Include="Oanda\RestV20\Model\ClientComment.cs" />
<Compile Include="Oanda\RestV20\Model\ClientConfigureRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\ClientConfigureTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\ClientExtensions.cs" />
<Compile Include="Oanda\RestV20\Model\ClientID.cs" />
<Compile Include="Oanda\RestV20\Model\ClientTag.cs" />
<Compile Include="Oanda\RestV20\Model\ClosePositionBody.cs" />
<Compile Include="Oanda\RestV20\Model\CloseTradeBody.cs" />
<Compile Include="Oanda\RestV20\Model\CloseTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\ConfigureAccountBody.cs" />
<Compile Include="Oanda\RestV20\Model\CreateOrderBody.cs" />
<Compile Include="Oanda\RestV20\Model\CreateTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\Currency.cs" />
<Compile Include="Oanda\RestV20\Model\DailyFinancingTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\DateTime.cs" />
<Compile Include="Oanda\RestV20\Model\DecimalNumber.cs" />
<Compile Include="Oanda\RestV20\Model\DelayedTradeClosureTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\DynamicOrderState.cs" />
<Compile Include="Oanda\RestV20\Model\FundingReason.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse200.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2001.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20010.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20011.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20012.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20013.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20014.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20015.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20016.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20017.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20018.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20019.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2002.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20020.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20021.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20022.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20023.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20024.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20025.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20026.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20027.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20028.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse20029.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2003.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2004.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2005.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2006.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2007.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2008.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2009.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse201.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse2011.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse400.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4001.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4002.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4003.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4004.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4005.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4006.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4007.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse401.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse404.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4041.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4042.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4043.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4044.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4045.cs" />
<Compile Include="Oanda\RestV20\Model\InlineResponse4046.cs" />
<Compile Include="Oanda\RestV20\Model\Instrument.cs" />
<Compile Include="Oanda\RestV20\Model\InstrumentName.cs" />
<Compile Include="Oanda\RestV20\Model\InstrumentType.cs" />
<Compile Include="Oanda\RestV20\Model\LimitOrder.cs" />
<Compile Include="Oanda\RestV20\Model\LimitOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\LimitOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\LimitOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\LimitOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\LiquidityRegenerationSchedule.cs" />
<Compile Include="Oanda\RestV20\Model\LiquidityRegenerationScheduleStep.cs" />
<Compile Include="Oanda\RestV20\Model\MarginCallEnterTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarginCallExitTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarginCallExtendTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarketIfTouchedOrder.cs" />
<Compile Include="Oanda\RestV20\Model\MarketIfTouchedOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\MarketIfTouchedOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarketIfTouchedOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\MarketIfTouchedOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrder.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderDelayedTradeClose.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderMarginCloseout.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderMarginCloseoutReason.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderPositionCloseout.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderTradeClose.cs" />
<Compile Include="Oanda\RestV20\Model\MarketOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OpenTradeFinancing.cs" />
<Compile Include="Oanda\RestV20\Model\Order.cs" />
<Compile Include="Oanda\RestV20\Model\OrderCancelReason.cs" />
<Compile Include="Oanda\RestV20\Model\OrderCancelRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OrderCancelTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OrderClientExtensionsModifyRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OrderClientExtensionsModifyTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OrderFillReason.cs" />
<Compile Include="Oanda\RestV20\Model\OrderFillTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\OrderID.cs" />
<Compile Include="Oanda\RestV20\Model\OrderIdentifier.cs" />
<Compile Include="Oanda\RestV20\Model\OrderPositionFill.cs" />
<Compile Include="Oanda\RestV20\Model\OrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\OrderSpecifier.cs" />
<Compile Include="Oanda\RestV20\Model\OrderState.cs" />
<Compile Include="Oanda\RestV20\Model\OrderTriggerCondition.cs" />
<Compile Include="Oanda\RestV20\Model\OrderType.cs" />
<Compile Include="Oanda\RestV20\Model\Position.cs" />
<Compile Include="Oanda\RestV20\Model\PositionAggregationMode.cs" />
<Compile Include="Oanda\RestV20\Model\PositionFinancing.cs" />
<Compile Include="Oanda\RestV20\Model\PositionSide.cs" />
<Compile Include="Oanda\RestV20\Model\Price.cs" />
<Compile Include="Oanda\RestV20\Model\PriceBucket.cs" />
<Compile Include="Oanda\RestV20\Model\PriceStatus.cs" />
<Compile Include="Oanda\RestV20\Model\PriceValue.cs" />
<Compile Include="Oanda\RestV20\Model\PricingHeartbeat.cs" />
<Compile Include="Oanda\RestV20\Model\QuoteHomeConversionFactors.cs" />
<Compile Include="Oanda\RestV20\Model\ReopenTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\ReplaceOrderBody.cs" />
<Compile Include="Oanda\RestV20\Model\RequestID.cs" />
<Compile Include="Oanda\RestV20\Model\ResetResettablePLTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\SetOrderClientExtensionsBody.cs" />
<Compile Include="Oanda\RestV20\Model\SetTradeClientExtensionsBody.cs" />
<Compile Include="Oanda\RestV20\Model\SetTradeDependentOrdersBody.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossDetails.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossOrder.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\StopLossOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\StopOrder.cs" />
<Compile Include="Oanda\RestV20\Model\StopOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\StopOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\StopOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\StopOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitDetails.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitOrder.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\TakeProfitOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TimeInForce.cs" />
<Compile Include="Oanda\RestV20\Model\Trade.cs" />
<Compile Include="Oanda\RestV20\Model\TradeClientExtensionsModifyRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TradeClientExtensionsModifyTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TradeID.cs" />
<Compile Include="Oanda\RestV20\Model\TradeOpen.cs" />
<Compile Include="Oanda\RestV20\Model\TradeReduce.cs" />
<Compile Include="Oanda\RestV20\Model\TradeSpecifier.cs" />
<Compile Include="Oanda\RestV20\Model\TradeState.cs" />
<Compile Include="Oanda\RestV20\Model\TradeSummary.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossDetails.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossOrder.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossOrderReason.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossOrderRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossOrderRequest.cs" />
<Compile Include="Oanda\RestV20\Model\TrailingStopLossOrderTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\Transaction.cs" />
<Compile Include="Oanda\RestV20\Model\TransactionFilter.cs" />
<Compile Include="Oanda\RestV20\Model\TransactionHeartbeat.cs" />
<Compile Include="Oanda\RestV20\Model\TransactionID.cs" />
<Compile Include="Oanda\RestV20\Model\TransactionRejectReason.cs" />
<Compile Include="Oanda\RestV20\Model\TransactionType.cs" />
<Compile Include="Oanda\RestV20\Model\TransferFundsRejectTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\TransferFundsTransaction.cs" />
<Compile Include="Oanda\RestV20\Model\UnitsAvailable.cs" />
<Compile Include="Oanda\RestV20\Model\UnitsAvailableDetails.cs" />
<Compile Include="Oanda\RestV20\Model\UserInfo.cs" />
<Compile Include="Oanda\RestV20\Model\UserInfoExternal.cs" />
<Compile Include="Oanda\RestV20\Model\UserSpecifier.cs" />
<Compile Include="Oanda\RestV20\Model\VWAPReceipt.cs" />
<Compile Include="Oanda\RestV20\Model\WeeklyAlignment.cs" />
<Compile Include="Oanda\RestV20\Session\PricingStreamSession.cs" />
<Compile Include="Oanda\RestV20\Session\StreamSession.cs" />
<Compile Include="Oanda\RestV20\Session\TransactionStreamSession.cs" />
<Compile Include="Oanda\Server.cs" />
<Compile Include="Paper\PaperBrokerage.cs" />
<Compile Include="Paper\PaperBrokerageFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tradier\TradierBrokerage.HistoryProvider.cs" />
<Compile Include="Tradier\TradierBrokerage.DataQueueHandler.cs" />
<Compile Include="Tradier\TradierBrokerage.cs" />
<Compile Include="Tradier\Balances.cs" />
<Compile Include="Tradier\Common.cs" />
<Compile Include="Tradier\Data.cs" />
<Compile Include="Tradier\Fault.cs" />
<Compile Include="Tradier\GainLoss.cs" />
<Compile Include="Tradier\History.cs" />
<Compile Include="Tradier\Orders.cs" />
<Compile Include="Tradier\Positions.cs" />
<Compile Include="Tradier\Tokens.cs" />
<Compile Include="Tradier\TradierBrokerageFactory.cs" />
<Compile Include="Tradier\UserProfile.cs" />
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Binance\BinanceBrokerage.Messaging.cs" />
<None Include="InteractiveBrokers\IB-symbol-map.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Api\QuantConnect.Api.csproj">
<Project>{C5D44209-49A0-4505-A870-043C5EF5FDDF}</Project>
<Name>QuantConnect.Api</Name>
</ProjectReference>
<ProjectReference Include="..\Common\QuantConnect.csproj">
<Project>{2545c0b4-fabb-49c9-8dd1-9ad7ee23f86b}</Project>
<Name>QuantConnect</Name>
</ProjectReference>
<ProjectReference Include="..\Compression\QuantConnect.Compression.csproj">
<Project>{bc3bc77e-0502-43db-a727-b94f9765d74b}</Project>
<Name>QuantConnect.Compression</Name>
</ProjectReference>
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj">
<Project>{0AEB4EA3-28C8-476E-89FD-926F06590B4C}</Project>
<Name>QuantConnect.Configuration</Name>
</ProjectReference>
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj">
<Project>{01911409-86be-4e7d-9947-df714138610d}</Project>
<Name>QuantConnect.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\Api\QuantConnect.Api.csproj" />
<ProjectReference Include="..\Common\QuantConnect.csproj" />
<ProjectReference Include="..\Compression\QuantConnect.Compression.csproj" />
<ProjectReference Include="..\Configuration\QuantConnect.Configuration.csproj" />
<ProjectReference Include="..\Logging\QuantConnect.Logging.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="Fxcm\QuantConnect.Fxcm.dll">
@@ -698,33 +86,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.3\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
<Compile Remove="Alpaca\Markets\AlpacaTradingClient.WatchList.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.2.9.3\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.2.9.3\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.2.9.3\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.2.9.3\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.2.9.3\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
<Error Condition="!Exists('..\packages\QuantConnect.IBAutomater.1.0.35\build\QuantConnect.IBAutomater.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\QuantConnect.IBAutomater.1.0.35\build\QuantConnect.IBAutomater.targets'))" />
</Target>
<Import Project="..\packages\QuantConnect.IBAutomater.1.0.35\build\QuantConnect.IBAutomater.targets" Condition="Exists('..\packages\QuantConnect.IBAutomater.1.0.35\build\QuantConnect.IBAutomater.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Some files were not shown because too many files have changed in this diff Show More