# Mutual Fund Candles

Get historical price candles for a mutual fund.

> [!WARNING]
> This endpoint will be live on May 1, 2024. Before May 1, use the stocks/candles endpoint to query mutual fund candles.

## Endpoint
```
https://api.marketdata.app/v1/funds/candles/{resolution}/{symbol}/
```
### Method
```
GET
```
## Request Example

### HTTP

**GET** [https://api.marketdata.app/v1/funds/candles/D/VFINX/?from=2024-01-01&to=2024-01-31](https://api.marketdata.app/v1/funds/candles/D/VFINX/?from=2024-01-01&to=2024-01-31)

### JavaScript

```js title="fundCandles.js"
import { MarketDataClient } from "@marketdata/sdk";

const client = new MarketDataClient();

try {
  // VFINX is available without authentication (free test symbol).
  const candles = await client.funds.candles("VFINX", {
    resolution: "D",
    from: "2024-01-01",
    to: "2024-01-31",
  });
  for (const c of candles) {
    console.log(`t=${c.t} o=${c.o} h=${c.h} l=${c.l} c=${c.c}`);
  }
} catch (error) {
  console.error(error);
}
```

### TypeScript

```typescript title="fundCandles.ts"
import { MarketDataClient } from "@marketdata/sdk";
import type { FundsCandle } from "@marketdata/sdk";

const client = new MarketDataClient();

try {
  // VFINX is available without authentication (free test symbol).
  const candles: FundsCandle[] = await client.funds.candles("VFINX", {
    resolution: "D",
    from: "2024-01-01",
    to: "2024-01-31",
  });
  for (const c of candles) {
    console.log(`t=${c.t} o=${c.o} h=${c.h} l=${c.l} c=${c.c}`);
  }
} catch (error) {
  console.error(error);
}
```

### Python

```python title="fundCandles.py"
from marketdata import MarketDataClient

client = MarketDataClient()
candles = client.funds.candles("VFINX", resolution="D", from_date="2024-01-01", to_date="2024-01-31")
print(candles)
```

### Go

```go title="fundCandles.go"

import (
  "fmt"

  api "github.com/MarketDataApp/sdk-go"
)

func ExampleFundCandlesRequest() {
  fcr, err := FundCandles().Resolution("D").Symbol("VFINX").From("2024-01-01").To("2024-01-31").Get()
  if err != nil {
    fmt.Print(err)
    return
  }

  for _, candle := range fcr {
    fmt.Println(candle)
  }
}

```

### PHP

```php title="fundCandles.php"
use MarketDataApp\Client;

$client = new Client();
$candles = $client->mutual_funds->candles(
    symbol: "VFINX",
    from: "2024-01-01",
    to: "2024-01-31",
    resolution: "D"
);

// Display formatted candles summary
echo $candles;
```

### Java

```java title="FundCandles.java"
import com.marketdata.sdk.MarketDataClient;
import com.marketdata.sdk.funds.FundCandlesRequest;
import com.marketdata.sdk.funds.FundResolution;
import java.time.LocalDate;

public class FundCandles {
  public static void main(String[] args) {
    try (MarketDataClient client = new MarketDataClient()) {
      // VFINX is available without authentication (free test symbol).
      client.funds()
          .candles(FundCandlesRequest.builder(FundResolution.DAILY, "VFINX")
              .from(LocalDate.parse("2024-01-01"))
              .to(LocalDate.parse("2024-01-31"))
              .build())
          .values()
          .forEach(System.out::println);
    }
  }
}
```

### Kotlin

```kotlin title="FundCandles.kt"
import com.marketdata.sdk.MarketDataClient
import com.marketdata.sdk.funds.FundCandlesRequest
import com.marketdata.sdk.funds.FundResolution
import java.time.LocalDate

fun main() {
    MarketDataClient().use { client ->
        // VFINX is available without authentication (free test symbol).
        client.funds()
            .candles(
                FundCandlesRequest.builder(FundResolution.DAILY, "VFINX")
                    .from(LocalDate.parse("2024-01-01"))
                    .to(LocalDate.parse("2024-01-31"))
                    .build()
            )
            .values()
            .forEach(::println)
    }
}
```

### C#

```csharp title="FundCandles.cs"
using MarketDataApp;
using MarketDataApp.Funds;

using var client = await MarketDataClient.CreateAsync();

// VFINX is available without authentication (free test symbol).
var candles = await client.Funds.GetCandlesAsync(
    FundResolution.Daily, "VFINX",
    from: DateOnly.Parse("2024-01-01"), to: DateOnly.Parse("2024-01-31"));
foreach (var candle in candles.Values)
{
    Console.WriteLine(candle);
}
```

## Response Example

```json
{
  "s":"ok",
  "t":[1577941200,1578027600,1578286800,1578373200,1578459600,1578546000,1578632400],
  "o":[300.69,298.6,299.65,298.84,300.32,302.39,301.53],
  "h":[300.69,298.6,299.65,298.84,300.32,302.39,301.53],
  "l":[300.69,298.6,299.65,298.84,300.32,302.39,301.53],
  "c":[300.69,298.6,299.65,298.84,300.32,302.39,301.53]
}
```

## Request Parameters

### Required

- **resolution** `string`

  The duration of each candle. Intraday resolutions are not supported for funds. *Case-insensitive*.

  - Daily Resolutions: (`daily`, `D`, `1D`, `2D`, ...)
  - Weekly Resolutions: (`weekly`, `W`, `1W`, `2W`, ...)
  - Monthly Resolutions: (`monthly`, `M`, `1M`, `2M`, ...)
  - Yearly Resolutions: (`yearly`, `Y`, `1Y`, `2Y`, ...)

- **symbol** `string`

  The mutual fund's ticker symbol.

- **from** `date`

  The leftmost candle on a chart (inclusive). If you use `countback`, `to` is not required. Accepted timestamp inputs: ISO 8601, unix, spreadsheet.

- **to** `date`

  The rightmost candle on a chart (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet.

- **countback** `number`

  Will fetch a number of candles before (to the left of) `to`. If you use `from`, `countback` is not required.

## Response Attributes

### Success

- **s** `string`

  ll always be `ok` when there is data for the candles requested.

- **o** `array[number]`

  Open price.

- **h** `array[number]`

  High price.

- **l** `array[number]`

  Low price.

- **c** `array[number]`

  Close price.

- **t** `array[number]`

  Candle time. This is midnight US Eastern Time on the session date. All timestamps use US Eastern Time (America/New_York). See [Response Timezone](https://www.marketdata.app/docs/docs/api/dates-and-times#response-timezone) for details.

### No Data

- **s** `string`

  Status will be `no_data` if no candles are found for the request.

- **nextTime** `number` optional

  Unix time of the next quote if there is no data in the requested period, but there is data in a subsequent period.

### Error

- **s** `string`

  Status will be `error` if the request produces an error response.

- **errmsg** `string`
  An error message.
