Commit Graph

41 Commits

Author SHA1 Message Date
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 08b72c5907 Overall performance improvements v2
- Adding `LazyToUpper()` implementation, that will avoid the call to
`ToUpper` if the string is already upper.
- Reduce the timezone conversions at `Time.EachTradeableDayInTimeZone`
- `TotalPortfolioValue` will iterate over all securities once
- Adding new `SecurityIdentifier` cache, significant impact for
algorithms using coarse/fine data
2019-06-05 17:06:59 -03: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 074dbbfe2f Add dairy publication dates dating back to contract month 2012-03-01 2019-05-15 08:48:17 -07:00
Gerardo Salazar 298ee1e504 Replace invalid characters 2019-05-14 16:37:41 -07:00
Gerardo Salazar ce9664a2dd Add comment explaining use of two holiday lists for calculating nth business day 2019-05-14 10:52:15 -07:00
Gerardo Salazar fbc725d8dc Remove TODOs on completed futures expiry functions 2019-05-14 10:14:22 -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
Stefano Raggi f7e06510d4 Fix missing front month contract in energy futures backtesting
Energy futures (CL, HO, RB, NG) expire in the month before the contract month.

To handle these properly, the following changes have been implemented:
- the AlgoSeekFuturesReader has been updated to create the future symbol with the correct expiry date
- the zip entry names in futures data files now contain the full expiry date (in addition to the contract month)
- the sample data files have been updated to use the new zip entry names
- new unit tests have been added and existing ones updated
2019-04-29 09:40:59 +02:00
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
Gerardo Salazar 5e562c07c0 Use market hours database instead of custom FuturesExpiryCalendar
Added additional test cases for symbols 6L and 6M
2019-03-20 13:45:29 -07: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
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 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 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 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
Michael Handschuh 20133d40d1 Add ICurrencyConverter to Security constructors
Security instances will require private access to this value in order to
compute close profit.

NOTE: The extent of these changes for simply adding a constructor argument
insinuates that we're missing an abstraction to manage the construction of
these objects, such as a factor object for Security. This will need some
careful TLC in the near future.
2018-10-10 11:17:12 -04:00
Martin Molinero 78742e5df6 Adding cash buffer for IB Cash Accounts 2018-08-10 17:21:50 -03:00
Juan José D'Ambrosio 1552819ee1 Implement VIX futures expiry function
Test case and data added
Tests expected vs. actual fix.
2018-07-20 17:08:27 -03:00
Michael Handschuh 1c2fd66027 Add OnlyApplyFilterAtMarketOpen to option/future filters
Sometimes we want to make decisions based on strike prices but still only
want the filter to be executed at market open and run once per day. Without
this change there was no way to force this behavior. Also, using this
method can greatly improve system performance by not running the contract
filter on every time step.
2018-05-07 15:52:31 -04:00
Michael Handschuh 47dd6fae1e Add OptionFilterUniverse.SetFilter overload for only expirations
Without this helpers users would need to call .
We provide a helper for strikes only but not expirations only. This change adds the
missing helper. A similar method is also available for futures.
2018-05-07 15:52:30 -04:00
Michael Handschuh ede93b60de Add Contracts function to FutureFilterUniverse
FutureFilterUniverse was lacking a means of explicitly setting the set of
contract symbols to be selected, which means algorithms had to use the
vairous helper methods but wereunable to define their own selection function
for the ontract universe. This change adds two methods, one to explicitly
set the contracts to be selected and another that mirrors the way universe
selection works, by providing a function that accept sthe full set of contract
symbols and returns the filtered set of contract symbols. This enables LINQ
filtering of the contract universe.
2018-05-07 15:52:30 -04:00
Michael Handschuh 8843961282 Add Future.IsFutureChain and Future.IsFutureContract flags
These flags allow algorithms to test a future security object to see if it
represents an actual futures contract or the entire futures chain.
2018-05-07 15:52:30 -04:00
Michael Handschuh 1c9671f495 Add IDerivativeSecurity and implement in Option/Future
Provides an abstraction for securities w/ an underlying security.
This is intended to pair with IDerivativeSecurityFilter.

This enables othe code to not need to bind and look for specific
security types in order to access the Underlying property.
2018-03-19 12:40:54 -04:00
Michael Handschuh f08184c0ae Revert class name changes from #1506
This caused several user algorithms to break. Also, its still correct to
call these margin models.
2018-02-04 14:20:38 -05:00
Stefano Raggi 5b5a56102b Remove IBuyingPowerModel.GetMarginRemaining, add GetBuyingPower
The GetMarginRemaining method in SecurityMarginBuyingPowerModel class is made protected as it can still be overridden in derived classes.
2018-01-31 11:47:35 +01:00
Stefano Raggi c6fd9bb904 Remove IBuyingPowerModel.GetMaintenanceMargin, add GetReservedBuyingPowerForPosition
The GetMaintenanceMargin method in SecurityMarginBuyingPowerModel class is made protected as it can still be overridden in derived classes.
2018-01-31 11:47:35 +01:00
Stefano Raggi baced83ac4 Rename interface ISecurityMarginModel to IBuyingPowerModel
Also renamed all existing margin models to buying power models:
- SecurityMarginModel -> SecurityMarginBuyingPowerModel
- FutureMarginModel -> FutureMarginBuyingPowerModel
- OptionMarginModel -> OptionMarginBuyingPowerModel
2018-01-31 11:47:34 +01:00
Stefano Raggi 2952e30f15 Remove GetInitialMarginRequiredForOrder and GetInitialMarginRequirement from ISecurityMarginModel interface
GetInitialMarginRequiredForOrder and GetInitialMarginRequirement methods in the SecurityMarginModel class are made protected as they can still be overridden in derived classes.
2018-01-31 11:47:33 +01:00
Stefano Raggi e01d0ff670 Derive all margin models from SecurityMarginModel
This is a preliminary step before adding new methods to the ISecurityMarginModel interface and the SecurityMarginModel class.
2018-01-31 11:47:32 +01:00
AlexCatarino dfffbd6953 Adds IFutureChainProvider interface with base implementations
- Move BacktestingFutureChainProvider provider to Lean.Engine.DataFeeds along with its options equivalent.

- EmptyFutureChainProvider: provider that returns an empty list of symbols
- CachingFutureChainProvider: implements caching by date
- BacktestingFutureChainProvider: provider that gets chain from local files
- LiveFutureChainProvider: provider that gets chain from external source (empty list of symbols for now)
2017-12-04 14:16:59 +00:00
Stefano Raggi cb5f1cb00b Fix decimal precision issue in FutureMarginModel.GetMaintenanceMargin
This issue was causing an OverflowException in SecurityPortfolioManager.ScanForMarginCall due to a precision error in the margin calculation that was returning a value for TotalMarginUsed = 0.0000000000000000000000061M.
This solution simplifies the calculation of maintenance margin, removing the unnecessary division and multiplication by the same value.
2017-11-10 00:31:15 +01:00
Stefano Raggi a533a019cb Fix symbol mapping with futures expiring before contract month
Some Futures (CL, HO, RB, NG) expire during the month before the contract month. Incorrect symbol mapping was causing two issues:
- IB requests were returning an "Ambiguous contract" error
- The ticker generated by SymbolRepresentation was referring to the previous contract month
2017-11-02 17:48:44 +01:00
AlexCatarino b1eb184be5 Extends Future.SetFilter with an overload that accepts PyObject
This feature enables users to write complex filters for future universes.
2017-10-24 21:41:07 +01:00
Anshul 1cd565374e Renames the folder Futures to Future 2017-05-18 14:19:56 -04:00