17 using System.Globalization;
38 private enum FxcmSymbolId
59 private readonly
string _baseUrl =
" http://marketsummary2.fxcorporate.com/ssisa/servlet?RT=SSI";
64 private readonly
string _sid =
"quantconnect";
69 private readonly
long[] _transactionsIdx = { 27, 29, 31, 33 };
74 private readonly
int _ver = 1;
79 private readonly
int[] _volumeIdx = { 26, 28, 30, 32 };
108 var interval = GetIntervalFromResolution(config.
Resolution);
109 var symbolId = GetFxcmIDFromSymbol(config.
Symbol.
Value.Split(
'_').First());
113 var source = Invariant($
"{_baseUrl}&ver={_ver}&sid={_sid}&interval={interval}&offerID={symbolId}");
118 var source = GenerateZipFilePath(config, date);
142 var obs = line.Split(
'\n')[2].Split(
';');
143 var stringDate = obs[0].Substring(startIndex: 3);
144 fxcmVolume.Time = DateTime.ParseExact(stringDate,
"yyyyMMddHHmm", DateTimeFormatInfo.InvariantInfo);
145 fxcmVolume.Volume = _volumeIdx.Select(x =>
Parse.
Long(obs[x])).Sum();
146 fxcmVolume.Transactions = _transactionsIdx.Select(x =>
Parse.
Int(obs[x])).Sum();
147 fxcmVolume.
Value = fxcmVolume.Volume;
149 catch (Exception exception)
151 Logging.Log.Error($
"Invalid data. Line: {line}. Exception: {exception.Message}");
157 var obs = line.Split(
',');
160 fxcmVolume.Time = date.Date.AddMilliseconds(
Parse.
Int(obs[0]));
164 fxcmVolume.Time = DateTime.ParseExact(obs[0],
"yyyyMMdd HH:mm", CultureInfo.InvariantCulture);
167 fxcmVolume.Transactions = obs[2].ConvertInvariant<
int>();
168 fxcmVolume.Value = fxcmVolume.Volume;
178 var symbol = config.
Symbol.
Value.Split(
'_').First().ToLowerInvariant();
181 filename = Invariant($
"{date:yyyyMMdd}_volume.zip");
182 source = Path.Combine(source, symbol, filename);
186 filename = $
"{symbol}_volume.zip";
187 source = Path.Combine(source, filename);
198 private int GetFxcmIDFromSymbol(
string ticker)
203 symbolId = (int)Enum.Parse(typeof(FxcmSymbolId), ticker);
205 catch (ArgumentException)
207 throw new ArgumentOutOfRangeException(nameof(ticker), ticker,
208 "Volume data is not available for the selected ticker.");
222 private string GetIntervalFromResolution(
Resolution resolution)
240 throw new ArgumentOutOfRangeException(nameof(resolution), resolution,
241 "Tick or second resolution are not supported for Forex Volume. Available resolutions are Minute, Hour and Daily.");