assetHistory(string Name, int Mode): int

Loads price history of an asset from online price sources or from a broker's price server at the begin of the simulation.

Parameters:

Name

Asset symbol or code used by the price source, or 0 for the current asset.

Mode

1 - download one-minute (M1) price data from the currently selected broker.
0 - download tick (T1) data from the currently selected broker (Zorro S required).
FROM_GOOGLE
- download daily (D1) data from Google™ Finance.
FROM_QUANDL - download daily (D1) data from Quandl™ (Zorro S required).
FROM_AV - download daily (D1) data from AlphaVantage™.
FROM_STOOQ - download daily (D1) data from Stooq™.
FROM_YAHOO - download daily (D1) data from Yahoo™ Finance ('backdoor' method).
FROM_BITTREX - download M1, H1, or D1 cryptocurrency data from Bittrex™ (Zorro S required).
FROM_CRYPTOC - download M1, H1, or D1 cryptocurrency data from CryptoCompare™ (Zorro S required).
+1 - download M1 data (Bittrex/CryptoCompare only).
+2 - download H1 data (Bittrex/CryptoCompare only).
+3 - download D1 data (IB only).
+UNADJUSTED - download unadjusted prices (some sources only).
+OVERRIDE - download price data even when history is up to date (price sources only).
+VOLATILE - store the data not in a file, but in a dataset whose handle is returned (price sources only).

Returns:

0 when nothing was downloaded due to an error or because the data was up to date, otherwise nonzero.

Remarks:

Example:

// Update M1 price history of all assets
function run()
{
  NumYears = 2;
  while(loop(Assets))
    assetHistory(Loop1,1);
  quit();
}

// Download D1 prices from Quandl
function run()
{
  ...
  string Name;
  while(Name = loop("AAPL","MSFT","GOOGL")) {
    assetHistory(strf("WIKI/%s",Name),FROM_QUANDL);
    asset(Name);
    ...
  }
  ...
}

// Download and plot Bitcoin prices from Bitfinex
function run()
{
  BarPeriod = 1440;
  assetHistory("BITFINEX/BTCUSD",FROM_QUANDL);
  assetAdd("BTCUSD");
  asset("BTCUSD");
  set(PLOTNOW);
}

See also:

price, asset, UpdateDays, loadStatus, Price History, dataDownload

► latest version online