Commit Graph

31 Commits

Author SHA1 Message Date
Martin Molinero d360ec36ac Address reviews 2019-05-31 18:26:18 -03:00
Martin Molinero 57fbf588fe Download RemoteFile once for backtests
- For backtests download RemoteFile just once
- Live subscriptions and history requests will continue to download the
`RemoteFile` on each request.
- Adding unit tests
2019-05-29 18:38:07 -03:00
Martin Molinero bb6671b811 Fix tests after RemoteFileSubscriptionStreamReader changes 2019-05-28 13:24:52 -03:00
Jared Broad 9062357b30 Remote file provider powered by download provider 2019-05-24 17:01:52 -07:00
Martin Molinero d4a4a992a5 Address reviews 2019-05-22 16:31:17 -03:00
Martin Molinero 7becc869af Fix infinite live custom data polling
- Adding `IStreamReader.RateLimit { get; }` specifying if a stream
reader `ReadLine()` calls should be rate limited by the source readers.
- Adding two failling unit tests in `master`
2019-05-21 16:15:38 -03:00
Stefano Raggi 57d50c69c4 Fix XML documentation compiler warnings
- Fixed all warnings except for missing XML comments (CS1591)
2018-11-09 11:44:03 +01:00
Juan José D'Ambrosio 9eaf4cb6b0 Implementing live mode flag into RestSubscriptionStreamReader
Through `SubscriptionDataSource`.
Exceptions, cocumenting, cleaning and testing adjust


make isLiveMode mandatory in the SubscriptionDataSource constructor


Calls to SubscriptionDataSource implements new bool argument


csproj file mistake fixed 


Clean up nullable from prevoius implementation.


Revert "Exceptions, cocumenting, cleaning and testing adjust"

This reverts commit 7da7a9fca195b327a1322c0c7c4a7a088b2f1099.
SubscriptionDataSource back to default.

 Uisng LiveMode flag from  the calling contex
_delivered variabl setting.


Comments fixed


xml doc fix
2018-02-02 19:27:31 -03:00
Michael Handschuh b595005df8 Support headers in SubscriptionDataSource
It is not uncommon that a web service would require some form of
authentication headers to be provided. This change aims to enable
this by adding the header information to the source. This design
allows a user's custom data type to return the source properly
hydrated with the required header values before being sent back
through the rest of the LEAN infrastructure.
2017-11-13 16:53:02 -05:00
Andrew 88e6c1c251 Send remote files to the DataCacheProvider after downloading
The streamReader expects a stream to be provided by the DataCacheProvider. When the file is not available, most dataCacheProviders will look for the file on disc. This works for most Lean data types, but not for remote data. After downloading a remote file, this PR sends the data to the DataCacheProvider via the Store() method. This way, when the streamReader asks for the data from the DataCacheProvider - the remote file will already have been cached.
2017-11-06 12:01:15 -05:00
Stefano Raggi 1ef0d0cfe0 Fix DirectoryNotFoundException when using custom data with FileFormat.Collection 2017-07-26 17:18:33 +02:00
AnshulYADAV, Computer Artist (CoArsey) 350e58567f Fixes 18 warnings with code CS1572 (#908)
* Fixes 5 warnings with code CD1572

* Adds the Xml Comment parameter and implements the missing selector parameter

* Fixes rest of the 13 warnings with code CS1572
2017-05-12 09:28:46 -04:00
Andrew 672e134939 Removed ApiDataProvider
Refactored IHistoryProvider interface order of parameters
2017-02-16 15:47:06 -05:00
Andrew b6171cc9d5 Renamed IDataFileProvider to IDataProvider using resharper
Refactored IDataProvider interface to return stream. The IDataProvider
Fetch method now only takes a key.  The IDataProvider
has been reshuffled to be at the bottom of the LeanDataStack.  It provides
data to the rest of the Lean stack. The default implementation of IDataProvider reads
data from disc.

All IDataCacheProviders now have constructors which take IDataProviders
and use them to find data on disc.

Renamed DataCacheProvider to ZipDataCacheProvider

Added comments to IDataProvider and it's implementations

Added comments to IDataCacheProvider and it's implementations
2017-02-15 12:16:50 -05:00
Andrew ed2107132e IHistoryProvider.Initialize() requires a DataCacheProvider
Fixed bug where DataCacheProvider was returning a stream without closing
the stream.  Also, ZipFiles returned from ZipFileCacheProvider are
effectively disposed.

Removed date field from IDataCacheProvider interface
2017-02-15 12:16:49 -05:00
Andrew 952e1d19e3 Added interface IDataCacheProvider that defines a mechanism for caching data
This interface was built around the existing implementation of the
DataCacheProvider.  It's purpose is to define a method for caching data
files.  Currently, most data files are either read from disc or retrieved
remotely. The IDataChceProvider returns returns a Stream and can handle
many types of data. The IDataFileCacheProvider is needed because keeping data in memory will improve performance and overcome certain File read/write limitations (such as sharing violations) currently experienced by Lean.

There are two implementations of this interface.  The first is the
SingleZipEntryDataCache.  This is the default implementation. It does not
cache and returns the first entry found within a ZipFile.  The second is
the ZipEntryCacheProvider.  This is a rework of the existing
DataCachePrivider.  It caches ZipFiles for up to 10 seconds.  It can
return specific entries for option and future ZipFiles.  Otherwise, it
returns the first entry in a ZipFile.

Added IDataFileCacheProvider as parameter to IHistoryProvider.Initialize()

The IDataFileCacheProvider is very useful for the IHistoryProvider in that it can eliminate the need for history request to touch disc.  This can greatly improve peerformance and eliminate disc bugs associated with disc read/writes. To minimize changes throughtout Lean, the default value for the IDataFileCacheProvider is null in the IHistoryProvider.Initialize method.

IDataCacheProviders are passed down the Lean stack. Each instance of a Subscription Enumerator factory decides what cache it
will use.  In other words, the IDataCacheProvider is not configurable from
config.json.  The IDataCacheProvider is passwed down the stack form the
Enumerator factory to the IStreamReader where it is used to retrieve data.

Added useful helper method to Unizp files into a Stream.
2017-02-15 12:16:49 -05:00
quant1729 4382821ae7 Removed reference to System.IO.Compression zip library in Compression.Unzip() and DataFileCacheProvider.cs, as in mono this namespace is implemented using SharpCompress. Reverted back to Ionic zip library. 2017-01-22 00:20:57 +08:00
quant1729 6ba1ae899a Removed UnzipCached() method and its usages. Updated Zip() method. 2017-01-11 12:57:03 +08:00
quant1729 48721125dc Revert "Fixed bug with static zip archive caching. Added new caching data file provider. Refactored IDataFileProvider interface."
This reverts commit c59743dc42.
2017-01-11 11:27:28 +08:00
quant1729 c59743dc42 Fixed bug with static zip archive caching. Added new caching data file provider. Refactored IDataFileProvider interface. 2017-01-08 09:25:26 +08:00
quant1729 d2aad44272 Updated code as per PR discussion 2017-01-06 22:46:42 +08:00
quant1729 2570f4c99f Optimizing options backtesting (zipper). First cut. 2016-12-19 16:41:42 +01:00
quant1729 391e42de78 Updated IQFeed symbol universe module to minimize memory consumption 2016-11-04 14:00:47 +01:00
quant1729 0396841d82 - Added support for sourcing and caching the full symbol list from IQFeed website.
- Added IQFeed options support to toolbox: option chain universe, option symbol list, subscriptions, live prices
- Added LiveTradingDataFeed to support options live screaming
- Added IB live options trading support: trading orders, holdings, live option exercising
- Modified ISymbolMapper interface to support derivatives (options, futures)
- Fixed minor bugs with (introduced ealier) symbol changes for options
Tested with IQFeed version 5.2.4.2. IB TWS offline version 957.
2016-09-14 21:56:12 +01:00
Michael Handschuh f158e1492f Updates local file reader to check for zip entry name
Includes updates to Tick/TradeBar/QuoteBar GetSource methods to specify zip entry name for options
2016-03-17 10:51:53 -04: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 a17bf88ea7 Make downloaded file names unique 2015-09-15 15:40:06 -04:00
snugs 324c7073f7 Adds ISubscriptionFactory
Includes default impl of BaseDataSubscriptionFactory

This change is to prepare for binary data sources and defines a factory to
handle the reading of a SubscriptionDataSource and the conversion of that data
into BaseData instances
2015-07-02 21:59:01 -04:00
snugs b9a72e62ca Update IDataFeed to use single time slice bridge
DataFeeds now expose a single bridge (BlockingCollection<TimeSlice>)
	- IDataFeed now responsible for all time syncing, DataStream was removed
	- BlockingCollection allows for easy throttling of data feed thread without sleeps (internally using semaphore slim)
	- Slimmed down IDataFeed interface to not include members unused externally

DataFeeds now use raw IEnumerator<BaseData> instead of subscription data readers directly
	- Simplifies fill forward logic (see FillForwardEnumerator.cs and FillForwardEnumeratorTest.cs)
	- Allows for composition (raw reader -> fill forward, user/market filters)
	- SubscriptionDataReader now handles refreshing source (continuous enumeration)

LiveTradingDataFeed cleaned up to work with time slice bridge
	- RealTimeSynchronizedTimer handles pushing time slices into bridge every second, with or without data
	- Subscriptions with tick resolution get their data pushed directly into the bridge immediately

Fill forward changes
	- Implemented as an IEnumerator<BaseData>
	- Fill forward lower res on higher res (daily gets filled forward on second/minute/hour bars)
	- Second/minute/hour will not be filled forward on daily bars (at midnight) in line with current behavior

MISC:
	- Performance boost in backtesting brokerage via not checking _pending.Count, instead use local bool to determine if there's pending orders
	- Added a FakeDataQueue to aid in testing LiveTradingDataFeed
	- FileSystemDataFeed now uses CancellationTokenSource to handle thread exits
	- Added logging
2015-06-30 15:18:34 -04:00
Stefano Raggi 81e3afc31e Added missing Dispose on streaming ZipFile 2015-06-20 23:55:17 +02:00
snugs 6fd357b710 Adds support for dividends and splits
Updates SubscriptionDataReader to use IStreamReader
Adds FactorFile and MapFile helpers
Adds support for Raw, Adjusted, and TotalReturn data normalization and portfolio application
2015-04-23 20:39:59 -04:00