Lean
$LEAN_TAG$
UnlinkedData.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 source that is unlinked (no mapping) and takes any ticker when calling AddData
27
/// </summary>
28
[ProtoContract(SkipConstructor =
true
)]
29
public
class
UnlinkedData
:
BaseData
30
{
31
/// <summary>
32
/// If true, we accept any ticker from the AddData call
33
/// </summary>
34
public
static
bool
AnyTicker
{
get
;
set
; }
35
36
/// <summary>
37
/// Example data
38
/// </summary>
39
[ProtoMember(55)]
40
public
string
Ticker
{
get
;
set
; }
41
42
public
override
SubscriptionDataSource
GetSource
(
SubscriptionDataConfig
config, DateTime date,
bool
isLiveMode)
43
{
44
return
new
SubscriptionDataSource
(
45
Path.Combine(
46
"TestData"
,
47
"unlinked"
,
48
AnyTicker
?
"data.csv"
: $
"{config.Symbol.Value.ToLowerInvariant()}.csv"
49
),
50
SubscriptionTransportMedium
.LocalFile,
51
FileFormat
.Csv);
52
}
53
54
public
override
BaseData
Reader
(
SubscriptionDataConfig
config,
string
line, DateTime date,
bool
isLiveMode)
55
{
56
return
new
UnlinkedData
57
{
58
Ticker
=
AnyTicker
?
"ANY"
: $
"{config.Symbol.Value}"
,
59
Symbol
= config.
Symbol
,
60
EndTime
= date
61
};
62
}
63
64
/// <summary>
65
/// Indicates whether the data source is sparse.
66
/// If false, it will disable missing file logging.
67
/// </summary>
68
/// <returns>true</returns>
69
public
override
bool
IsSparseData
()
70
{
71
return
true
;
72
}
73
74
/// <summary>
75
/// Indicates whether the data source can undergo
76
/// rename events/is tied to equities.
77
/// </summary>
78
/// <returns>true</returns>
79
public
override
bool
RequiresMapping
()
80
{
81
return
false
;
82
}
83
84
/// <summary>
85
/// Set the data time zone to UTC
86
/// </summary>
87
/// <returns>Time zone as UTC</returns>
88
public
override
DateTimeZone
DataTimeZone
()
89
{
90
return
TimeZones
.
Utc
;
91
}
92
93
/// <summary>
94
/// Sets the default resolution to Second
95
/// </summary>
96
/// <returns>Resolution.Second</returns>
97
public
override
Resolution
DefaultResolution
()
98
{
99
return
Resolution
.Daily;
100
}
101
102
/// <summary>
103
/// Gets a list of all the supported Resolutions
104
/// </summary>
105
/// <returns>All resolutions</returns>
106
public
override
List<Resolution>
SupportedResolutions
()
107
{
108
return
DailyResolution
;
109
}
110
}
111
}
Common
Data
Custom
IconicTypes
UnlinkedData.cs
Generated by
1.8.17