Files
quantconnect--lean/ToolBox/GDAXDownloader/GDAXDownloaderProgram.cs
nazbrok fd138ec397 GDAXDownloader : save data int the right ticker name (#4799)
* Update crypto entries in SPBD

- Update values for GDAX and Bitfinex, with latest values from exchanges
- Update symbols with >3 letters
- [Fix] Remove  same base-quote entries

* Update unit tests

Increment in precision given smaller lot sizes in SPDB crypto entries.

* Add GDAX symbol properties downloader (unit test)

* Update GDAX symbol properties database

* Add BrokerageSymbol to symbol properties database

* Update GDAX symbol properties

* Address review

- Rename BrokerageSymbol to MarketTicker

* Add GDAX symbol mapper

* Update GDAXBrokerage to use symbol mapper

* Fix GDAX brokerage unit tests

* Replace GDAXSymbolMapper with SymbolPropertiesDatabaseSymbolMapper

* Address review

- use Symbol key in dictionaries

* Rename BrokerageSymbol to MarketTicker

* Save GDAX history in the real ticker folder

* rename tickerMapper to symbolMapper

* fix gdaxdownloader help message

* Save GDAX history in the real ticker folder

* rename tickerMapper to symbolMapper

* fix gdaxdownloader help message

* use SymbolPropertiesDatabaseSymbolMapper

* address review

Co-authored-by: JJD <jjdambrosio@gmail.com>
Co-authored-by: Stefano Raggi <stefano.raggi67@gmail.com>
Co-authored-by: Martin-Molinero <martin@quantconnect.com>
2020-11-23 21:35:39 -03:00

76 lines
3.1 KiB
C#

/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using QuantConnect.Configuration;
using QuantConnect.Logging;
using QuantConnect.Util;
namespace QuantConnect.ToolBox.GDAXDownloader
{
public static class GDAXDownloaderProgram
{
/// <summary>
/// GDAX Downloader Toolbox Project For LEAN Algorithmic Trading Engine.
/// </summary>
public static void GDAXDownloader(IList<string> tickers, string resolution, DateTime fromDate, DateTime toDate)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
if (resolution.IsNullOrEmpty() || tickers.IsNullOrEmpty())
{
Console.WriteLine("GDAXDownloader ERROR: '--tickers=' or '--resolution=' parameter is missing");
Console.WriteLine("--tickers=ETHUSD,ETHBTC,BTCUSD,etc.");
Console.WriteLine("--resolution=Second/Minute/Hour/Daily");
Environment.Exit(1);
}
var castResolution = (Resolution) Enum.Parse(typeof(Resolution), resolution);
try
{
// Load settings from config.json
var dataDirectory = Config.Get("data-directory", "../../../Data");
//todo: will download any exchange but always save as gdax
// Create an instance of the downloader
const string market = Market.GDAX;
var downloader = new GDAXDownloader();
foreach (var ticker in tickers)
{
// Download the data
var symbolObject = Symbol.Create(ticker, SecurityType.Crypto, market);
var data = downloader.Get(symbolObject, castResolution, fromDate, toDate);
// Save the data
var writer = new LeanDataWriter(castResolution, symbolObject, dataDirectory, TickType.Trade);
var distinctData = data.GroupBy(i => i.Time, (key, group) => group.First()).ToArray();
writer.Write(distinctData);
}
Log.Trace("Finish data download. Press any key to continue..");
}
catch (Exception err)
{
Log.Error(err);
Log.Trace(err.Message);
Log.Trace(err.StackTrace);
}
Console.ReadLine();
}
}
}