Commit Graph

51 Commits

Author SHA1 Message Date
Oleg Sheyner 06a8d22f23 #3386 Trade Builder creates incorrect trades: finalize fixes + add regression tests 2019-07-11 12:52:02 -04:00
Oleg Sheyner bb020fc5ff Fix #3386 2019-07-11 12:52:02 -04:00
Martin Molinero 78a9d2566f Address review 2019-06-06 20:28:54 -03:00
Martin Molinero 168fb98e20 Fix Turnover Ratio for Futures/CFDs
- `Futures` and `CFDs` sales value will use `ContractMultiplier` as the
rest of the securities.
- `FitnessScore` values will be truncated, not rounded, to 3 decimal places.
- Reducing code duplication for calculating the
`CompoundingAnnualPerformance`
2019-06-06 20:06:54 -03:00
Martin Molinero e7641edf25 Shift Sigmoidal Scale 2019-06-04 18:18:43 -03:00
Martin Molinero 877f59285b Update Portfolio Turnover to be average daily 2019-06-04 11:58:37 -03:00
Martin Molinero 050bbcaba1 Fix Sortino Ratio 2019-06-03 21:42:45 -03:00
Martin Molinero 9e493f16a4 Annualize downside returns 2019-06-03 19:49:23 -03:00
Martin Molinero 761974ab5a PortfolioTurnover will use whole backtest (not last rolling year) 2019-06-03 15:15:50 -03:00
Martin Molinero 61db544817 Address reviews 2019-06-03 15:10:19 -03:00
Martin Molinero 61bab7439b Address reviews 2019-06-03 15:10:18 -03:00
Martin Molinero c015d4ca1f Add Fitness Score
- Adding new `FitnessScore`, score of the strategys performance, and
suitability for the Alpha Stream Market
2019-06-03 15:10:18 -03:00
Douglas Stridsberg 921ae391ad Merge branch 'master' into feature-3146-median-trade-durations 2019-04-30 20:34:30 +01:00
Martin Molinero 412eccebc9 Address reviews
- Revert charting rouding
- Add statistics rouding
- Json converter will ignore null order values
- Remove `type` field in `Symbol` json
- Add default type value for the `TimeInForceJsonConverter`
2019-04-30 11:45:07 -03:00
Douglas Stridsberg 05d206ee0d Calculating medians on longs is ~20% faster 2019-04-30 10:10:55 +01:00
Douglas Stridsberg 37cbfd1270 Median trading durations (all/winning/losing) added to TradeStatistics 2019-04-29 17:50:02 +01:00
Martin Molinero b7930aff67 Performance improvements
- Using `Aggregate(lambda)` vs `Sum(lambda)` since the later is slower
due to performing an extra `Select`
- For `QCAlgorithm.Framework.OnFrameworkData()` will avoid calling
`ToArray()` on empty `Enumerables` due to its cost * the number of
calls. If the `Enumerable` is the empty instance, which is static,
will create a new empty array and return it instead.
- Replacing `SecurityIdentifier` `SecurityType` and `GetHashCode`
implementations for `Lazy` versions, that are performed just once, since
these values do not change and are used multiple times.
- For the different `DataDictionary<T>` implementations adding `this[
Symbol] get; set` since existing overload `this [string]` produces an
extra round operations `Symbol->string->Symbol` with a significant
impact.
- Adding `PortfolioTargetCollection.AddRange()` overload using an array
to avoid unnecessary convertions.
2019-04-11 19:01:27 -03:00
Martin Molinero 0af7ba14f5 Address reviews
- `CashBook[NullCurrency] { get; }` will throw an exception
- Revert `Currencies.USD` changes in user facing algorithms
- Improve some documentation
- Revert some format changes
- Adding more asserts for regression test
- Adding new regression tests using a custom fee model which returns
`OrderFee.Zero`
- Adding a non-usd account currency test to the cash book tests
- Adding some unit tests for `NullCurrency` and `OrderFee.Zero`
2018-12-14 12:38:55 -03:00
Martin Molinero 0933da9303 Refactor previous commits
- Removing `AccountCurrency` from `Cash` and `Brokerage` classes.
`ICurrencyConverter` will now provide the `AccountCurrency`
- Adding new static `OrderFee.Zero` which will return a 0 order fee in
`NullCurrency`
- Adding static `Currencies.USD` value, replacing all "USD".
- Addin new static `Currencies.NullCurrency`
- Updating Bitfinex `FeeModel` so it return fees in quote currency.
Adding unit tests
2018-12-13 11:30:40 -03:00
Martin Molinero b7bcdbef04 Adding OrderFee to OrderEvent
- Replacing `decimal` for `OrderFee` at the `OrderEvent`.
- Adding `FeeModelNotUsingAccountCurrency` regression test
- Adding unit tests for `CashBuyingPowerModel` and `SecurityMarginModel`
with non account currency fees
2018-12-10 13:18:41 -03:00
Martin Molinero 75ffa300f1 Adding new IAlgorithm.AccountCurrency
- Adding new `IAlgorithm.AccountCurrency { get; }` that will point to the
`Portfolio.CashBook.AccountCurrency`. Setter will be added in a
following PR.
- Base `Brokerage` class will now have a `AccountCurrency { get }`
pointing to the `IAccountCurrencyProvider`. Will be used by the different
brokerages implementations.
2018-12-10 11:59:02 -03:00
Michael Handschuh 94bfaf115b Compute net profit even if no trades
In live mode it is very possible for a deployment to not have any closed
trades but still experience a profit (or loss) due to pre-existig holdings.

Additionally, this changes backtesting statistics for all backtests that did
not close a single position.
2017-11-07 15:13:20 -05:00
Stefano Raggi 84555a80ad Fix AlgorithmPerformance property setters for JSON deserialization
AlgorithmPerformance, PortfolioStatistics and TradeStatistics had private setters, so JSON deserialization could not populate their properties.
2017-06-26 17:21:48 +02:00
Jared 24fcd239a7 Merge pull request #982 from QuantConnect/issue-330/decimal-quantity
Order and Holding Decimalization Support
2017-06-26 09:51:51 -04:00
Stefano Raggi 8c248a1165 Fix formatting bug in StatisticsBuilder.GetSummary
This bug was causing regression tests to fail on a machine with non-US regional settings.
2017-06-20 22:10:49 +02:00
Stefano Raggi 9139ca7c40 Merge master into issue-330/decimal-quantity 2017-06-19 23:50:26 +02:00
Stefano Raggi fd5f4bc64f Add ITradeBuilder interface 2017-03-21 19:57:21 +01:00
Stefano Raggi e052afebba In StatisticsBuilder ensure daily performance has same dates as benchmark performance 2017-02-14 14:34:22 +01:00
quant1729 8af29aca3c Updated trade builder to support derivatives (multiplier > 1). Tests. 2016-11-28 15:16:15 +01:00
jameschch@outlook.com 7763efdc83 Changes related to #330 order quantity decimalized 2016-06-24 11:28:21 +01:00
AlexCatarino 4158a11367 Fixes Beta (PortfolioStatistics) calculation
In CreateBenchmarkDifference method, a list of values of banchmark daily performance were not created properly. It added an extra zero entry in the beggining of the list and did not include the last day. That caused an one-day lag between the algorithm and benchmark performances.
Reference: [Strange backtester beta results](https://www.quantconnect.com/forum/discussion/1118)

Changes RegressionTests to reflect this correction.
2016-04-22 22:18:11 -03:00
Michael Handschuh e9e6472dd0 Fixes number overflow in statistics generation 2016-03-31 20:00:45 -04:00
Stefano Raggi 96930a1c26 Fixes speed bug in StatisticsBuilder.CreateBenchmarkDifferences 2016-01-27 15:25:57 -05:00
snugs be950e756a Log full errors/stack traces
Many places in the code used Log.Error(err.Message) or equivalent which
strips out all the really useful information, such as the stack trace
and inner exceptions. Using Log.Error(exception) is the correct way to
log an error as it will correctly write all the message details, also,
by passing the full Exception object we can improve the logging in this
one place and all call sites will automatically benefit from the improvements
2015-12-02 12:35:33 -05:00
snugs e29236cc2d Remove reliance on Symbol implcits from core libraries 2015-11-12 13:55:39 -05:00
Stefano Raggi 11c6753297 Changed Padded Performance log Error to Trace 2015-10-24 18:49:51 -04:00
Stefano Raggi dfcdcf58cc Added check for division by zero in CompoundingAnnualPerformance 2015-10-24 23:41:24 +02:00
Stefano Raggi fac6f46a9a New Statistics implementation
Added Trade and TradeBuilder classes
Added UtcTime and OrderFee property to OrderEvent class
Added AlgorithmPerformance class with a few metrics + tests
Added portfolio statistics + rolling statistics

Closes #30 via PR #164

Thanks @SteffanoRaggi!
2015-09-16 20:48:02 -04:00
snugs e16c82a856 Adds IAlgorithm.PostInitialize
Resolve benchmark in PostInitialize method
2015-08-06 13:05:05 -04:00
Michael 184f573b7b Improved comment on padded benchmark 2015-08-05 16:17:11 -04:00
Ray Bohac 1b9c1b7921 Initial implementation of custom benchmarks 2015-08-05 15:30:34 -04:00
snugs 4957b2ba42 Fix total trades to be orders with fills 2015-07-31 17:16:11 -04:00
QuantConnect 7024d654f5 Modified statistics to count orders not completed trades 2015-07-15 12:47:45 -04:00
QuantConnect fde0cbed3a Strip out block quote section header comments 2015-06-13 16:04:27 -04:00
snugs 89b6e98af8 Fixes warnings mostly relating to xml comments
Also cleans up some block comments

Via PR#72 - thanks @ammachado!
2015-05-13 10:56:47 -04:00
snugs 6698942b3f Move Total Fees to end of statistics 2015-05-12 22:25:30 -04:00
snugs f65ed9ba59 Adds Total Fees to backtesting statistics 2015-05-12 18:16:23 -04:00
Adriano Marcondes Machado b2229e8968 Fixed a few compilation warnings 2015-03-09 16:28:17 -03:00
QuantConnect 2309a111fc Bug fix drawdown reporting max drawdown value-percentage instead of max-percentage-drawdown, thanks @xenu256 2015-02-23 14:47:36 -03:00
Jared Broad c845e21feb Added culture invariant info to all convert to decimal references, close #25 2015-02-17 22:50:33 -03:00