Lean
$LEAN_TAG$
IndexedLinkedData2.cs
1
/*
2
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
using
NodaTime;
17
using
QuantConnect
.
Data
;
18
using
System;
19
using
System.Collections.Generic;
20
using
System.IO;
21
using
ProtoBuf;
22
23
namespace
QuantConnect.Data.Custom.IconicTypes
24
{
25
/// <summary>
26
/// Data type that is indexed, i.e. a file that points to another file containing the contents
27
/// we're looking for in a Symbol.
28
/// </summary>
29
[ProtoContract(SkipConstructor =
true
)]
30
public
class
IndexedLinkedData2
:
IndexedBaseData
31
{
32
/// <summary>
33
/// Example data property
34
/// </summary>
35
[ProtoMember(55)]
36
public
int
Count
{
get
;
set
; }
37
38
/// <summary>
39
/// Determines the actual source from an index contained within a ticker folder
40
/// </summary>
41
/// <param name="config">Subscription configuration</param>
42
/// <param name="date">Date</param>
43
/// <param name="index">File to load data from</param>
44
/// <param name="isLiveMode">Is live mode</param>
45
/// <returns>SubscriptionDataSource pointing to the article</returns>
46
public
override
SubscriptionDataSource
GetSourceForAnIndex
(
SubscriptionDataConfig
config, DateTime date,
string
index,
bool
isLiveMode)
47
{
48
return
new
SubscriptionDataSource
(
49
Path.Combine(
"TestData"
,
50
"indexlinked2"
,
51
"content"
,
52
$
"{date.ToStringInvariant(DateFormat.EightCharacter)}.zip#{index}"
53
),
54
SubscriptionTransportMedium
.LocalFile,
55
FileFormat
.Csv
56
);
57
}
58
59
/// <summary>
60
/// Gets the source of the index file
61
/// </summary>
62
/// <param name="config">Configuration object</param>
63
/// <param name="date">Date of this source file</param>
64
/// <param name="isLiveMode">Is live mode</param>
65
/// <returns>SubscriptionDataSource indicating where data is located and how it's stored</returns>
66
public
override
SubscriptionDataSource
GetSource
(
SubscriptionDataConfig
config, DateTime date,
bool
isLiveMode)
67
{
68
if
(isLiveMode)
69
{
70
throw
new
NotImplementedException(
"Live mode not supported"
);
71
}
72
73
return
new
SubscriptionDataSource
(
74
Path.Combine(
75
"TestData"
,
76
"indexlinked2"
,
77
config.
Symbol
.
Value
.ToLowerInvariant(),
78
$
"{date.ToStringInvariant(DateFormat.EightCharacter)}.csv"
79
),
80
SubscriptionTransportMedium
.LocalFile,
81
FileFormat
.Index
82
);
83
}
84
85
/// <summary>
86
/// Creates an instance from a line of JSON containing article information read from the `content` directory
87
/// </summary>
88
/// <param name="config">Subscription configuration</param>
89
/// <param name="line">Line of data</param>
90
/// <param name="date">Date</param>
91
/// <param name="isLiveMode">Is live mode</param>
92
public
override
BaseData
Reader
(
SubscriptionDataConfig
config,
string
line, DateTime date,
bool
isLiveMode)
93
{
94
return
new
IndexedLinkedData2
95
{
96
Count
= 10,
97
Symbol
= config.
Symbol
,
98
EndTime
= date
99
};
100
}
101
102
/// <summary>
103
/// Indicates whether the data source is sparse.
104
/// If false, it will disable missing file logging.
105
/// </summary>
106
/// <returns>true</returns>
107
public
override
bool
IsSparseData
()
108
{
109
return
true
;
110
}
111
112
/// <summary>
113
/// Indicates whether the data source can undergo
114
/// rename events/is tied to equities.
115
/// </summary>
116
/// <returns>true</returns>
117
public
override
bool
RequiresMapping
()
118
{
119
return
true
;
120
}
121
122
/// <summary>
123
/// Set the data time zone to UTC
124
/// </summary>
125
/// <returns>Time zone as UTC</returns>
126
public
override
DateTimeZone
DataTimeZone
()
127
{
128
return
TimeZones
.
Utc
;
129
}
130
131
/// <summary>
132
/// Sets the default resolution to Second
133
/// </summary>
134
/// <returns>Resolution.Second</returns>
135
public
override
Resolution
DefaultResolution
()
136
{
137
return
Resolution
.Daily;
138
}
139
140
/// <summary>
141
/// Gets a list of all the supported Resolutions
142
/// </summary>
143
/// <returns>All resolutions</returns>
144
public
override
List<Resolution>
SupportedResolutions
()
145
{
146
return
DailyResolution
;
147
}
148
}
149
}
Common
Data
Custom
IconicTypes
IndexedLinkedData2.cs
Generated by
1.8.17