Skip to content

Commit 469af87

Browse files
committed
Add donwload function docs
1 parent f8cfbfd commit 469af87

File tree

3 files changed

+168
-32
lines changed

3 files changed

+168
-32
lines changed

docusaurus/docs/Data/download.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
id: download
3+
title: Download Market Data
4+
sidebar_label: Download Market Data
5+
---
6+
7+
## Overview
8+
9+
The `download` function is a utility provided by the **Investing Algorithm Framework** that allows you to retrieve historical market data for specific symbols (assets), including OHLCV data (Open, High, Low, Close, Volume), ticker data, and more. This function is particularly useful for:
10+
11+
- Backtesting trading strategies
12+
- Performing exploratory data analysis
13+
- Preprocessing input data for machine learning models
14+
15+
---
16+
17+
## Function Signature
18+
19+
```python
20+
def download(
21+
symbol: str,
22+
market=None,
23+
date=None,
24+
time_frame: str = None,
25+
data_type: str = "ohlcv",
26+
start_date: str = None,
27+
end_date: str = None,
28+
window_size: int = 200,
29+
pandas: bool = True,
30+
save: bool = True,
31+
storage_path: str = None,
32+
) -> Union[pandas.DataFrame, polars.DataFrame]
33+
```
34+
35+
| Parameter | Type | Description |
36+
| -------------- | ------ | -------------------------------------------------------------------------------- |
37+
| `symbol` | `str` | The symbol (e.g., `"BTC/USDT"`) for which data is downloaded. |
38+
| `market` | `str` | (Optional) The market to download data from (e.g., `"binance"`). |
39+
| `date` | `str` | (Optional) Specific date to retrieve data for. |
40+
| `time_frame` | `str` | The time frame for data (e.g., `"1d"`, `"1h"`). |
41+
| `data_type` | `str` | Type of data to retrieve: `"ohlcv"` (default) or `"ticker"`. |
42+
| `start_date` | `str` | (Optional) Start of the date range to retrieve data. |
43+
| `end_date` | `str` | (Optional) End of the date range. |
44+
| `window_size` | `int` | Number of records to retrieve (default: 200). |
45+
| `pandas` | `bool` | If `True`, returns a `pandas.DataFrame`; otherwise returns a `polars.DataFrame`. |
46+
| `save` | `bool` | If `True`, saves the downloaded data to disk. |
47+
| `storage_path` | `str` | (Optional) Path to store the data when `save=True`. |
48+
49+
50+
## Returns
51+
The function returns a DataFrame (pandas or polars) containing the requested market data, ready for analysis, visualization, or model training.
52+
53+
## Why It's Useful?
54+
This function streamlines the process of acquiring market data by:
55+
* Automatically selecting the correct data provider
56+
* Supporting multiple formats (pandas or polars)
57+
* Handling flexible input dates and ranges
58+
* Offering a simple way to persist downloaded data to disk
59+
60+
## Example Use Cases
61+
📈 Backtesting a Strategy
62+
63+
```python
64+
df = download("BTC/USDT", market="binance", time_frame="1d", start_date="2021-01-01", end_date="2022-01-01")
65+
```
66+
Use the returned df to simulate your strategy’s performance over historical data.
67+
68+
## 🧠 Preparing Data for Machine Learning
69+
```python
70+
df = download("ETH/USDT", market="binance", time_frame="1h", window_size=500, pandas=True)
71+
features = df[["close", "volume"]]
72+
```
73+
74+
This enables quick preparation of time-series datasets for supervised learning tasks.
75+
76+
## 💾 Saving Data for Offline Analysis
77+
78+
```python
79+
download("SOL/USDT", market="binance", time_frame="1d", save=True, storage_path="./data/")
80+
```
81+
82+
## Internals
83+
The function relies on:
84+
* ConfigurationService and MarketCredentialService to determine available providers and credentials.
85+
* DataProviderService to abstract away direct API calls.
86+
* dateutil.parser for robust datetime parsing.
87+
* Default providers registered via get_default_data_providers() and get_default_ohlcv_data_providers().

docusaurus/sidebar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const sidebars = {
1919
id: 'Getting Started/portfolio-configuration',
2020
},
2121
{
22-
type: 'doc',
23-
id: 'Getting Started/strategies',
24-
},
22+
type: 'doc',
23+
id: 'Getting Started/strategies',
24+
}
2525
{
2626
type: 'doc',
2727
id: 'Getting Started/orders',

docusaurus/sidebars.js

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,82 @@
1-
/**
2-
* Creating a sidebar enables you to:
3-
- create an ordered group of docs
4-
- render a sidebar for each doc of that group
5-
- provide next/previous navigation
6-
7-
The sidebars can be generated from the filesystem, or explicitly defined here.
8-
9-
Create as many sidebars as you want.
10-
*/
11-
12-
// @ts-check
13-
14-
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
151
const sidebars = {
16-
// By default, Docusaurus generates a sidebar from the docs folder structure
17-
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
18-
19-
// But you can create a sidebar manually
20-
/*
21-
tutorialSidebar: [
22-
'intro',
23-
'hello',
24-
{
25-
type: 'category',
26-
label: 'Tutorial',
27-
items: ['tutorial-Getting Started/create-a-document'],
28-
},
29-
],
30-
*/
2+
defaultSideBar: [
3+
"introduction",
4+
"contributing",
5+
{
6+
type: 'category',
7+
label: 'Getting Started',
8+
items: [
9+
{
10+
type: 'doc',
11+
id: 'Getting Started/installation',
12+
},
13+
{
14+
type: 'doc',
15+
id: 'Getting Started/application-setup',
16+
},
17+
{
18+
type: 'doc',
19+
id: 'Getting Started/portfolio-configuration',
20+
},
21+
{
22+
type: 'doc',
23+
id: 'Getting Started/strategies',
24+
}
25+
{
26+
type: 'doc',
27+
id: 'Getting Started/orders',
28+
},
29+
{
30+
type: 'doc',
31+
id: 'Getting Started/positions',
32+
},
33+
{
34+
type: 'doc',
35+
id: 'Getting Started/trades',
36+
},
37+
{
38+
type: 'doc',
39+
id: 'Getting Started/tasks',
40+
},
41+
{
42+
type: 'doc',
43+
id: 'Getting Started/backtesting',
44+
},
45+
{
46+
type: 'doc',
47+
id: 'Getting Started/deployment',
48+
},
49+
],
50+
},
51+
{
52+
type: 'category',
53+
label: 'Data',
54+
items: [
55+
{
56+
type: 'doc',
57+
id: 'Data/download',
58+
}
59+
{
60+
type: 'doc',
61+
id: 'Data/market-data-sources',
62+
},
63+
{
64+
type: 'doc',
65+
id: 'Data/multiple-market-data-sources',
66+
},
67+
],
68+
},
69+
{
70+
type: 'category',
71+
label: 'Advanced Concepts',
72+
items: [
73+
{
74+
type: 'doc',
75+
id: 'Advanced Concepts/logging-configuration',
76+
},
77+
],
78+
},
79+
],
3180
};
3281

3382
module.exports = sidebars;

0 commit comments

Comments
 (0)