Hello all,
I've been tryin to read text from a csv file I uploaded to dropbox
the code i have so far is attached below.
I dont know how to use the vatinant "file" - it seems to be in html data format.
can someone tell me how to read text from variant "file" or attach a working example of suce code?
thanks!
using System;
using System.Collections.Concurrent;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Indicators;
using System.Collections.Generic;
namespace QuantConnect.Algorithm.CSharp
{
public class EmaCrossUniverseSelectionAlgorithm : QCAlgorithm
{
// tolerance to prevent bouncing
const decimal Tolerance = 0.1m;
private const int Count = 100000;
// use Buffer+Count to leave a little in cash
private const decimal TargetPercent = 0.1m;
private SecurityChanges _changes = SecurityChanges.None;
TradeBar open;
// we'll set the close at the end of each day
TradeBar spyVal;
Dictionary<string, decimal> DayOpenValues = new Dictionary<string, decimal>();
Dictionary<string, decimal> ValuesAtNoon = new Dictionary<string, decimal>();
// class used to improve readability of the coarse selection function
OrderTicket _limitTicket;
OrderTicket _TakeProfit;
OrderTicket _liquidateTicket1;
public override void Initialize()
{
//UniverseSettings.Leverage = 2.0m;
UniverseSettings.Resolution = Resolution.Daily;
SetStartDate(2020, 04, 01);
SetEndDate(2021, 01, 01);
SetCash(6000);
AddEquity("SPY", Resolution.Minute);
}
public void OnData(TradeBars data)
{
var file = Download("https://www.dropbox.com/preview/Programming/nasdaq_screener_1611568528773.csv?role=personal&dl=1");
}
}
}
Shile Wen
Hi Maoz,
I've created an example of converting data from Download to a 2D array in C# in the attached backtest.
Best,
Shile Wen
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!