Commit Graph

315 Commits

Author SHA1 Message Date
Stefano Raggi 43a16c3580 Add retry logic to LiveOptionChainProvider.GetOptionContractList 2019-07-03 18:31:42 +02:00
Jared 9ee7075034 Merge pull request #3275 from QuantConnect/performance-smart-totalportfoliovalue-calculation
Smart TotalPortfolioValue Calculation
2019-06-07 14:08:14 -07:00
Jared ac9e3dd432 Merge pull request #3282 from Martin-Molinero/feature-3281-add-cash-cashbook-updated-event
Adding Updated event for Cash and CashBook
2019-06-07 12:34:35 -07:00
Martin Molinero 084353f182 Smart TotalPortfolioValue Calculation
- `SecurityPortfolioManager` will keep track of the current
`TotalPortfolioValue` and only re calculated when flagged as invalid.
2019-06-07 16:13:57 -03:00
Martin Molinero 90a8f23d98 Address reviews 2019-06-07 16:02:53 -03:00
Martin Molinero f5a28ff829 Adding Updated event Cash and CashBook
- Adding new `Updated` event for `Cash` and `CashBook`. Adding unit
tests.
- `CashBook.Update` event will also be called for updates in the `Cash`
instances he holds.
2019-06-07 13:43:41 -03:00
Gerardo Salazar b0406ba9eb Adds the following symbols to futures database: EI, EMD, ...
EN, EPN, ESK, EVC, EWG, EWN, EXR, F1U, FO, FRC, FSS, GCU, GD, GDK,
GNF, HCL, HG, HH, HP, HRC, HTT, IBV, J7

Add new utility functions in FuturesExpiryUtillityFunctions
2019-06-07 08:49:56 -07: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
Adalyat Nazirov 66a027c24f requested changes: change exception message 2019-06-01 20:27:30 +03:00
Adalyat Nazirov 4f1491b57e requested changes: test other base currencies 2019-06-01 20:27:29 +03:00
Adalyat Nazirov 14c62ac14a test missed CSV entry for Crypto 2019-06-01 20:27:29 +03:00
Adalyat Nazirov bce2465f5c add CryptoTests to check base and quote 2019-06-01 20:27:29 +03:00
Adalyat Nazirov caa61a8b31 update tests 2019-06-01 20:27:29 +03:00
Jared 2f46e708a1 Merge pull request #3184 from Martin-Molinero/refactor-3183-remove-backtestingtransactionhandler-thread
Removing BacktestingTransactionHandler thread
2019-05-17 07:22:24 -07:00
Jared 87f03e68ca Merge pull request #3185 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-4
Add Various Symbols to Futures Database (Part 4 / 11)
2019-05-17 07:16:54 -07:00
Gerardo Salazar 44a4451ea3 Adds the following futures to futures database: BTC, ...
BWF, BZ, CB, CJY, CNH, CRB, CSC, CSW, CSX, CU, D1N, DC,
DCB, DY, E6, E7, EAD, ECD, EDP, EH
2019-05-10 17:39:51 -05:00
Martin Molinero f976ffa099 Removing BacktestingTransactionHandler thread
- For backtesting the algorithm thread will sequentially process pending
order requests
   - Adding new non blocking `BusyCollection`
- Updating `UpdateOrderRegressionAlgorithm` that suffered of a race
condition: it supposed `OnOrderEvent` would be called after the call to
`Transactions.AddOrder()` was finished
2019-05-10 16:15:24 -03:00
Jared 806fd1ed4e Merge pull request #3094 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-3
Add Various Symbols To Futures Database (Part 3 / 11)
2019-04-23 17:34:05 -07:00
Stefano Raggi e5028e087f Remove usage of DateTime.UtcNow in buying power models (#3115)
Remove usage of DateTime.UtcNow in buying power models

In PR#3013 we added support for fee models with history, so the new changes to the GDAXFeeModel exposed this bug, breaking a couple of regression tests (issue #3044)

Update regression stats for EmitInsightCryptoCashAccountType

* Fix typos

Add missing time keeper in CashBuyingPowerModelTests
2019-04-23 07:38:39 -07:00
Gerardo Salazar 35b0d84247 Add the following futures to futures database: AGA, AJL, AJS, ...
AJY, AKL, AKZ, ANE, APS, AR0, ARE, AUP, AVZ, AW, AYV, AYX, AZ1, B0, B7H, BCF, BIO, BK, BOO, BR7

Correct wrong entry for symbol ZT in symbol-properties-database

Add missing holidays or early closes for energies and fx in mhdb
2019-04-22 17:16:47 -05:00
Gerardo Salazar 26c2f2e36a Adds The Following Symbols To Futures Database: 6Z, A0D, A0F, A1L, ...
A1M, A1R, A32, A3G, A7E, A7I, A7Q, A8J, A8K, A8O, A91,
A9N, AA6, AA8, ABS, ABT, AC0, ACD, AD0, ADB, AE5
2019-04-04 17:03:57 -07:00
Jared 890ed36d0c Merge pull request #3014 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-1
Add 1S, 22, 6L, 6R, 6M to Futures Database
2019-03-27 17:07:02 -07:00
Stefano Raggi 1bb1601e62 Update CashBuyingPowerModelTests for new GDAX fees 2019-03-25 14:33:23 +01:00
Gerardo Salazar ea6d8ee088 Merge branch 'master' into feature-2991-add-expirations-to-futures-database-part-1 2019-03-18 19:52:47 -07:00
Gerardo Salazar 4d4f27f027 Add 1S, 22, 6L, 6M, 6R to futures database 2019-03-18 17:06:35 -07:00
AlexCatarino f4d5f0e458 Adds RTY, NKD, and YO to Future's Database
Adds Russell 2000 E-Mini (RTY), Nikkei 225 Dollar (NKD) and Sugar 11 CME Globex (YO) to future data: entails update entries in market hours and symbol properties databases.
Updates `FutureExpiryFunction` to handle these contracts expiration date.
2019-03-15 17:22:10 +00:00
Jared 7cdad4b8a5 Merge pull request #2956 from StefanoRaggi/bug-2955-cfd-cashbook-settlement
Fix Cashbook Settlement for Oanda/FXCM CFD Trades
2019-03-01 16:02:51 -08:00
Martin Molinero 8f6ad4e3c8 Cache raw data points
- `TextSubscriptionDataSourceReader` will now cache raw price mode data
points for each requested local source file, per data type.
Caching will be handled by the `MemoryCache` class.
- `GetLastKnownPrice()` will not `RoundDown` end time. This was causing
it to fail to fetch a data point in some cases.
2019-02-28 16:56:35 -03:00
Stefano Raggi d790830e78 Fix cashbook settlement for Oanda/FXCM CFD trades 2019-02-26 16:30:20 +01:00
Stefano Raggi 0def8040bb Add SecurityPortfolioManager unit tests for CFD 2019-02-22 11:56:57 +01:00
Adalyat Nazirov f641e469f9 add missing crypto currency pairs 2019-02-13 20:59:36 +03:00
Martin Molinero 1b0bdd9b0b Adding SetAccountCurrency for backtesting
- Adding new `SetAccountCurrency()` for backtesting. Has to be called
before adding any `Security` or calling `SetCash()`, else will throw.
- Adding new Non account currency unit tests for `CashBuyingPower`,
`SecurityPortfolioModel`, `SecurityMarginModel`,
`SecurityPortfolioManager`, `Future/OptionMarginBuyingPowerModels`
- Adding new C# regression test using `SetAccountCurrency()`, one for
`CashBuyingPowerModel` and one for `SecurityMarginModel`
- Adding new Py and C# basic regression algorithms using
`SetAccountCurrency()`
- `Options` and `Futures` will use not use `AccountCurrency` as quote
Cash.
- `SecurityBenchmark` value will be in account currency
2019-01-25 14:54:43 -03:00
Martin Molinero c9e6268cbd Remove OrderFeeParameters.AccountCurrency
- Removing OrderFeeParameters.AccountCurrency. Where required replacing
for constructor parameter defaulting to USD.
- Updating IB fee model to use to correct fee currency
2018-12-28 15:57:53 -03:00
Martin Molinero 8e41371e19 Non-Usd brokerage support
- `GetCashBalance()` will return a `List<CashAmount>`, will not need to
set conversion rates, which requires knowing what the account currency is.
- Removing `Global.Holding` conversion rate field. It wasn't being used
and required knowing what the account currency is.
- Adding equality operators for `CashAmount`. Adding unit tests.
2018-12-27 12:13:43 -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 e85942f4f0 GDAX FeeModel will use QuoteCurrency
- GDAX FeeModel will now use QuoteCurrency as fee currency. Adding unit
test.
2018-12-10 14:59:55 -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
Martin-Molinero 79d35333de Merge pull request #2720 from Martin-Molinero/refactor-2717-ifeelmodels
Refactor IFeeModel
2018-12-06 18:09:34 -03:00
Martin Molinero c5daf9ac9a Refactor IFeeModel
- Refactoring `IFeeModel`. *This is a breaking change* for implementations
inheriting directly from the interface. Deleting old and adding a new method
`OrderFee GetOrderFee(OrderFeeParameters parameters)` that will use a parameter
and a result object.
- Refactoring `CashAmount` so it does not embed a `ICurrencyConverter`
instance.
- Updating unit tests
- The `Security.QuoteCurrency`, a `Cash` instance, will provide access
to the `AccountCurrency` as a property.
- Will maintain backwards compatibility with old python custom
FeeModels, Adding unit test.

> Note that for now, consumers will ignore the currency, as before, and
directly consume the amount
2018-12-06 16:20:36 -03:00
Jared 1761e308a7 Merge pull request #2737 from Martin-Molinero/bug-2734-non-account-currency-future-profit
Fix Future non account currency last profit
2018-12-06 09:45:00 -08:00
Jared 5ac39719b5 Merge pull request #2736 from Martin-Molinero/bug-2735-non-account-currency-option-settlement
Fix non account currency Option settlement
2018-12-06 09:42:55 -08:00
Martin Molinero dccd770635 Fix Future non account currency last profit
- Removing conversion rate when applying last trade profit for non
account currency Future. Adding unit test.
2018-12-06 10:59:03 -03:00
Martin Molinero c40415401d Fix non account currency Option settlement
- Option settlement for non account currency will not apply conversion
rate. Adding unit test.
2018-12-06 10:45:33 -03:00
Martin Molinero 8d5745319e Obsoleting Securities configurations properties
> This PR is a mechanical refactor, no behaviour changed

- Obsoleting `DataNormalizationMode`. Replacing the usaged by requesting
the `SubscriptionDataConfigs` to the new `SubscriptionDataConfigService`
> Note we still need to refresh the Security.DataNormalizationMode
property.
2018-12-05 10:41:21 -03:00
Jared 299b467062 Merge pull request #2733 from Martin-Molinero/refactor-2728-buyingpowermodel-getinitialmarginrequiredfororder
BuyingPowerModel.GetInitialMarginRequiredForOrder will receive a Parameters object
2018-12-04 14:50:58 -08:00
Martin Molinero 6bbc8a304e BuyingPowerModel.GetInitialMarginRequiredForOrder
- `BuyingPowerModel.GetInitialMarginRequiredForOrder` will now receive
the new `InitialMarginRequiredForOrderParameters` object containing an
`ICurrencyConverter` instance.
2018-12-04 17:50:00 -03:00
Martin Molinero 95af5f8877 SecurityHolding has a ref to an ICurrencyConverter
- `SecurityHolding` will now have a reference to a `ICurrencyConverter`
instance, provided as a constructor argument, called by the owning `Security`.
2018-12-04 17:06:56 -03:00
Martin Molinero 46baedf858 Refactor FillModels
- Modifying `IFillModel` interface removing old methods and adding new
method `Fill Fill(FillModelParameters)`. This is a breaking change.
- Adding new `PythonWrapper` property for the `FillModel` base class.
This is required due to a limitation in PythonNet:
   - Given C# class T has `virtual` methods A and B. Where method A
   calls method B. And given custom python class L inherits class T.
   And overrides method B. When class L calls
   base method A (of class T). And when method A internally calls method B.
   It will call C# implementation, not the python override. This issue
   is solved going back to the `PythonWrapper`. Adding unit tests.
- Adding new `Parameters` property for the `FillModel` base class that will
be set by the call to `Fill()`. The `Parameters` property will be used by
the modified `XxxxFill()` implementations
- Adding new `Fill` result object for the `Fill(FillModelParameters)`
method
- Adding new check before removing a `SubscriptionDataConfig` due to the FillModels consuming the configuration collection when determining which Price to use. WIll now only remove the `SDC` if the symbol was removed from the selecting `universe`, this will avoid the case where the symbol is never deselected and the subscription ends, which happens at the end of all executions.
- Adding unit tests showcasing retro compatibility.
- Enabling C# `CustomModelsAlgorithm` as a regression test. Python
version returns a different result due to random number generation.
2018-11-29 15:38:46 -03:00