diff --git a/Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs b/Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs index 455d0e1a80e4..07b90eecd0bf 100644 --- a/Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs +++ b/Algorithm.CSharp/FractionalQuantityRegressionAlgorithm.cs @@ -36,7 +36,7 @@ public override void Initialize() SetCash(100000); SetTimeZone(NodaTime.DateTimeZone.Utc); - var security = AddSecurity(SecurityType.Forex, "BTCUSD", Resolution.Daily, Market.GDAX, false, 3.3m, true); + var security = AddSecurity(SecurityType.Crypto, "BTCUSD", Resolution.Daily, Market.GDAX, false, 3.3m, true); var con = new QuoteBarConsolidator(1); SubscriptionManager.AddConsolidator("BTCUSD", con); con.DataConsolidated += con_DataConsolidated; diff --git a/Algorithm/QCAlgorithm.cs b/Algorithm/QCAlgorithm.cs index 8b0896b45c6b..a0c00d6c57f2 100644 --- a/Algorithm/QCAlgorithm.cs +++ b/Algorithm/QCAlgorithm.cs @@ -1255,7 +1255,7 @@ public void SetTradeBuilder(ITradeBuilder tradeBuilder) /// /// Add specified data to our data subscriptions. QuantConnect will funnel this data to the handle data routine. /// - /// MarketType Type: Equity, Commodity, Future or FOREX + /// MarketType Type: Equity, Commodity, Future, FOREX or Crypto /// Symbol Reference for the MarketType /// Resolution of the Data Required /// When no data available on a tradebar, return the last data that was generated @@ -1268,7 +1268,7 @@ public Security AddSecurity(SecurityType securityType, string symbol, Resolution /// /// Add specified data to required list. QC will funnel this data to the handle data routine. /// - /// MarketType Type: Equity, Commodity, Future or FOREX + /// MarketType Type: Equity, Commodity, Future, FOREX or Crypto /// Symbol Reference for the MarketType /// Resolution of the Data Required /// When no data available on a tradebar, return the last data that was generated @@ -1283,7 +1283,7 @@ public Security AddSecurity(SecurityType securityType, string symbol, Resolution /// /// Set a required SecurityType-symbol and resolution for algorithm /// - /// SecurityType Enum: Equity, Commodity, FOREX or Future + /// MarketType Type: Equity, Commodity, Future, FOREX or Crypto /// Symbol Representation of the MarketType, e.g. AAPL /// Resolution of the MarketType required: MarketData, Second or Minute /// The market the requested security belongs to, such as 'usa' or 'fxcm' @@ -1512,6 +1512,15 @@ public Cfd AddCfd(string ticker, Resolution resolution = Resolution.Minute, stri return AddSecurity(SecurityType.Cfd, ticker, resolution, market, fillDataForward, leverage, false); } + /// + /// Creates and adds a new security to the algorithm + /// + /// The currency pair + /// The of market data, Tick, Second, Minute, Hour, or Daily. Default is + /// The cfd trading market, . Default value is null and looked up using BrokerageModel.DefaultMarkets in + /// If true, returns the last available data even if none in that timeslice. Default is true + /// The requested leverage for this equity. Default is set by + /// The new security public Crypto AddCrypto(string ticker, Resolution resolution = Resolution.Minute, string market = null, bool fillDataForward = true, decimal leverage = 0m) { return AddSecurity(SecurityType.Crypto, ticker, resolution, market, fillDataForward, leverage, false); diff --git a/Brokerages/GDAX/GDAXBrokerage.Utility.cs b/Brokerages/GDAX/GDAXBrokerage.Utility.cs index ebc9f0e59f93..6a3269ecb116 100644 --- a/Brokerages/GDAX/GDAXBrokerage.Utility.cs +++ b/Brokerages/GDAX/GDAXBrokerage.Utility.cs @@ -123,7 +123,7 @@ private static string ConvertOrderType(Orders.OrderType orderType) /// Symbol public static Symbol ConvertProductId(string productId) { - return Symbol.Create(productId.Replace("-", ""), SecurityType.Forex, Market.GDAX); + return Symbol.Create(productId.Replace("-", ""), SecurityType.Crypto, Market.GDAX); } /// diff --git a/Brokerages/GDAX/GDAXBrokerage.cs b/Brokerages/GDAX/GDAXBrokerage.cs index 49cae2052f31..7e14688d4e3e 100644 --- a/Brokerages/GDAX/GDAXBrokerage.cs +++ b/Brokerages/GDAX/GDAXBrokerage.cs @@ -246,7 +246,7 @@ public override List GetAccountHoldings() { var baseSymbol = (item.ProductId.Substring(0, 3) + "USD").ToLower(); - var tick = this.GetTick(Symbol.Create(baseSymbol, SecurityType.Forex, Market.GDAX)); + var tick = this.GetTick(Symbol.Create(baseSymbol, SecurityType.Crypto, Market.GDAX)); conversionRate = tick.Price; } else @@ -259,7 +259,7 @@ public override List GetAccountHoldings() { Symbol = ConvertProductId(item.ProductId), Quantity = item.Side == "sell" ? -item.FilledSize : item.FilledSize, - Type = SecurityType.Forex, + Type = SecurityType.Crypto, CurrencySymbol = item.ProductId.Substring(0, 3).ToUpper(), ConversionRate = conversionRate, MarketPrice = item.Price, @@ -294,7 +294,7 @@ public override List GetCashBalance() } else { - var tick = GetTick(Symbol.Create(item.Currency + "USD", SecurityType.Forex, Market.GDAX)); + var tick = GetTick(Symbol.Create(item.Currency + "USD", SecurityType.Crypto, Market.GDAX)); list.Add(new Securities.Cash(item.Currency.ToUpper(), item.Balance, tick.Price)); } diff --git a/Common/Brokerages/GDAXBrokerageModel.cs b/Common/Brokerages/GDAXBrokerageModel.cs index caf57bc2476e..d12916a5a9b4 100644 --- a/Common/Brokerages/GDAXBrokerageModel.cs +++ b/Common/Brokerages/GDAXBrokerageModel.cs @@ -18,8 +18,6 @@ using QuantConnect.Data.Market; using QuantConnect.Orders; using QuantConnect.Securities; -using QuantConnect.Securities.Equity; -using QuantConnect.Securities.Forex; using QuantConnect.Securities.Interfaces; using QuantConnect.Orders.Fills; using QuantConnect.Orders.Fees; diff --git a/Common/Data/SubscriptionManager.cs b/Common/Data/SubscriptionManager.cs index 7a435ef04012..e47e9123d744 100644 --- a/Common/Data/SubscriptionManager.cs +++ b/Common/Data/SubscriptionManager.cs @@ -203,8 +203,7 @@ public Dictionary> DefaultDataTypes() return new Dictionary>() { {SecurityType.Base, new List() { TickType.Trade } }, - //todo: revert trade ticks for forex - {SecurityType.Forex, new List() { TickType.Quote, TickType.Trade } }, + {SecurityType.Forex, new List() { TickType.Quote } }, {SecurityType.Equity, new List() { TickType.Trade } }, {SecurityType.Option, new List() { TickType.Quote, TickType.Trade, TickType.OpenInterest } }, {SecurityType.Cfd, new List() { TickType.Quote } }, diff --git a/Data/forex/gdax/daily/btcusd.zip b/Data/crypto/gdax/daily/btcusd.zip similarity index 100% rename from Data/forex/gdax/daily/btcusd.zip rename to Data/crypto/gdax/daily/btcusd.zip diff --git a/Data/symbol-properties/symbol-properties-database.csv b/Data/symbol-properties/symbol-properties-database.csv index 8d75f01f07dd..b97cc48873fd 100644 --- a/Data/symbol-properties/symbol-properties-database.csv +++ b/Data/symbol-properties/symbol-properties-database.csv @@ -2,7 +2,6 @@ market,symbol,type,description,quote_currency,contract_multiplier,minimum_price_ # # Use # signs for comments -bitfinex,BTCUSD,forex,BTCUSD,USD,1,0.01,0.01 # fxcm,AU200AUD,cfd,S&P/ASX index of Australian listed shares,USD,0.1,0.1,1 @@ -238,14 +237,14 @@ oanda,USDZAR,forex,USD/ZAR,ZAR,1,0.00001,1 oanda,ZARJPY,forex,ZAR/JPY,JPY,1,0.001,1 -gdax,BTCUSD,forex,BTCUSD,USD,1,0.01,0.01 -gdax,LTCUSD,forex,LTCUSD,USD,1,0.01,0.01 -gdax,ETHUSD,forex,ETHUSD,USD,1,0.01,0.01 -gdax,LTCBTC,forex,LTCBTC,BTC,1,0.00001,0.01 -gdax,ETHBTC,forex,ETHBTC,BTC,1,0.00001,0.01 -gdax,BTCGBP,forex,BTCGBP,GBP,1,0.01,0.01 -gdax,LTCGBP,forex,LTCGBP,GBP,1,0.01,0.01 -gdax,ETHGBP,forex,ETHGBP,GBP,1,0.01,0.01 -gdax,BTCEUR,forex,BTCEUR,EUR,1,0.01,0.01 -gdax,LTCEUR,forex,LTCEUR,EUR,1,0.01,0.01 -gdax,ETHEUR,forex,ETHEUR,EUR,1,0.01,0.01 +gdax,BTCUSD,crypto,BTCUSD,USD,1,0.01,0.01 +gdax,LTCUSD,crypto,LTCUSD,USD,1,0.01,0.01 +gdax,ETHUSD,crypto,ETHUSD,USD,1,0.01,0.01 +gdax,LTCBTC,crypto,LTCBTC,BTC,1,0.00001,0.01 +gdax,ETHBTC,crypto,ETHBTC,BTC,1,0.00001,0.01 +gdax,BTCGBP,crypto,BTCGBP,GBP,1,0.01,0.01 +gdax,LTCGBP,crypto,LTCGBP,GBP,1,0.01,0.01 +gdax,ETHGBP,crypto,ETHGBP,GBP,1,0.01,0.01 +gdax,BTCEUR,crypto,BTCEUR,EUR,1,0.01,0.01 +gdax,LTCEUR,crypto,LTCEUR,EUR,1,0.01,0.01 +gdax,ETHEUR,crypto,ETHEUR,EUR,1,0.01,0.01 diff --git a/Tests/Brokerages/GDAX/GDAXBrokerageIntegrationTests.cs b/Tests/Brokerages/GDAX/GDAXBrokerageIntegrationTests.cs index f437093ea8da..299d6efafb65 100644 --- a/Tests/Brokerages/GDAX/GDAXBrokerageIntegrationTests.cs +++ b/Tests/Brokerages/GDAX/GDAXBrokerageIntegrationTests.cs @@ -31,7 +31,7 @@ protected override Symbol Symbol /// protected override SecurityType SecurityType { - get { return SecurityType.Forex; } + get { return SecurityType.Crypto; } } /// diff --git a/Tests/Brokerages/GDAX/GDAXBrokerageTests.cs b/Tests/Brokerages/GDAX/GDAXBrokerageTests.cs index 09cd79f0eb77..f0890902e282 100644 --- a/Tests/Brokerages/GDAX/GDAXBrokerageTests.cs +++ b/Tests/Brokerages/GDAX/GDAXBrokerageTests.cs @@ -63,7 +63,7 @@ public void Setup() _orderByIdData = File.ReadAllText("TestData//gdax_orderById.txt"); _tickerData = File.ReadAllText("TestData//gdax_ticker.txt"); - _symbol = Symbol.Create("BTCUSD", SecurityType.Forex, Market.GDAX); + _symbol = Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX); _rest.Setup(m => m.Execute(It.Is(r => r.Resource.StartsWith("/products/")))).Returns(new RestSharp.RestResponse { @@ -336,8 +336,8 @@ public void SubscribeTest() _unit.Ticks.Clear(); - _unit.Subscribe(Mock.Of(), new[] { Symbol.Create("BTCUSD", SecurityType.Forex, Market.GDAX), Symbol.Create("GBPUSD", SecurityType.Forex, Market.GDAX), - Symbol.Create("BTCETH", SecurityType.Forex, Market.GDAX)}); + _unit.Subscribe(Mock.Of(), new[] { Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX), Symbol.Create("GBPUSD", SecurityType.Crypto, Market.GDAX), + Symbol.Create("BTCETH", SecurityType.Crypto, Market.GDAX)}); StringAssert.Contains(expected, actual); @@ -352,7 +352,7 @@ public void UnsubscribeTest() { string actual = null; _wss.Setup(w => w.Send(It.IsAny())).Callback(c => actual = c); - _unit.Unsubscribe(null, new List { Symbol.Create("BTCUSD", SecurityType.Forex, Market.GDAX) }); + _unit.Unsubscribe(null, new List { Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX) }); StringAssert.Contains("user", actual); StringAssert.Contains("heartbeat", actual); StringAssert.Contains("ticker", actual); diff --git a/Tests/Brokerages/GDAX/GDAXTestHelpers.cs b/Tests/Brokerages/GDAX/GDAXTestHelpers.cs index b0803212d869..dd47449c6274 100644 --- a/Tests/Brokerages/GDAX/GDAXTestHelpers.cs +++ b/Tests/Brokerages/GDAX/GDAXTestHelpers.cs @@ -19,7 +19,7 @@ public static Security GetSecurity(decimal price = 1m) private static SubscriptionDataConfig CreateConfig() { - return new SubscriptionDataConfig(typeof(TradeBar), Symbol.Create("BTCUSD", SecurityType.Forex, Market.GDAX), Resolution.Minute, TimeZones.Utc, TimeZones.Utc, + return new SubscriptionDataConfig(typeof(TradeBar), Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX), Resolution.Minute, TimeZones.Utc, TimeZones.Utc, false, true, false); } diff --git a/Tests/Common/Securities/SecurityManagerTests.cs b/Tests/Common/Securities/SecurityManagerTests.cs index 5cfe7b71b67d..a23e2a67404c 100644 --- a/Tests/Common/Securities/SecurityManagerTests.cs +++ b/Tests/Common/Securities/SecurityManagerTests.cs @@ -121,7 +121,7 @@ public void NotifiesWhenSecurityRemoved() [TestCase("EURUSD", SecurityType.Forex, Market.FXCM)] [TestCase("EURUSD", SecurityType.Forex, Market.Oanda)] - [TestCase("BTCUSD", SecurityType.Crypto, Market.Bitfinex)] + [TestCase("BTCUSD", SecurityType.Crypto, Market.GDAX)] public void SecurityManagerCanCreate_ForexOrCrypto_WithCorrectSubscriptions(string ticker, SecurityType type, string market) { var symbol = Symbol.Create(ticker, type, market); diff --git a/Tests/Symbols.cs b/Tests/Symbols.cs index 1ed567626031..84b0227cf632 100644 --- a/Tests/Symbols.cs +++ b/Tests/Symbols.cs @@ -103,7 +103,7 @@ private static Symbol CreateOptionSymbol(string symbol, OptionRight right, decim private static Symbol CreateCryptoSymbol(string symbol) { - return Symbol.Create(symbol, SecurityType.Crypto, Market.Bitfinex); + return Symbol.Create(symbol, SecurityType.Crypto, Market.GDAX); } } diff --git a/Tests/ToolBox/LeanDataWriterTests.cs b/Tests/ToolBox/LeanDataWriterTests.cs index 28d0ffcce738..80157f58ad26 100644 --- a/Tests/ToolBox/LeanDataWriterTests.cs +++ b/Tests/ToolBox/LeanDataWriterTests.cs @@ -32,7 +32,7 @@ public void Setup() _cfd = Symbol.Create("BCOUSD", SecurityType.Cfd, Market.Oanda); _equity = Symbol.Create("spy", SecurityType.Equity, Market.USA); _date = DateTime.Parse("3/16/2017 12:00:00 PM", CultureInfo.InvariantCulture); - _crypto = Symbol.Create("BTCUSD", SecurityType.Crypto, Market.Bitfinex); + _crypto = Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX); } private List GetTicks(Symbol sym) diff --git a/ToolBox/QuandlBitfinexDownloader/Program.cs b/ToolBox/QuandlBitfinexDownloader/Program.cs index 562a46974e29..db0a1ad9230c 100644 --- a/ToolBox/QuandlBitfinexDownloader/Program.cs +++ b/ToolBox/QuandlBitfinexDownloader/Program.cs @@ -37,7 +37,6 @@ static void Main(string[] args) { // Load settings from config.json var dataDirectory = Config.Get("data-directory", "../../../Data"); - var scaleFactor = Config.GetInt("bitfinex-scale-factor", 100); // Create an instance of the downloader const string market = Market.Bitfinex;