signal-forge 0.8
Get stock indicators via the SignalForge.io API
License: BSD 3-clause "New" or "Revised" license
Keywords: trading,finance,stocks,indicators

<p align="center">
    <img src="https://raw.githubusercontent.com/Dvrki/signal-forge-api-python/master/docs/signal_forge.png">
</p>



**Website**: <a href="https://signalforge.io">signalforge.io </a>

**Documentation**: <a href="https://signalforge.io/api_docs">signalforge.io/api_docs</a>

**Quick Tutorial**: <a href="https://signalforge.io/quick_tutorial">signalforge.io/quick_tutorial </a>



## Table of Contents

- [1. Overview](#1.-overview)

- [2. Setup](#2.-setup)
  
  * [2.1. Requirements](#2.1.-requirements)
  * [2.2. Installation](#2.2.-installation)
  
- [3. Examples](#3.-examples)
  
  * [3.1. Getting stock data](#3.1.-getting-stock-data)
  * [3.2. Getting stock data with indicators](#3.2.-getting-stock-data-with-indicators)
  * [3.3. Getting indicator names](#3.3.-getting-indicator-names)
  * [3.4. Getting normalized data](#3.4.-getting-normalized-data)
  * [3.5. Additional arguments](#3.5.-additional-arguments)
  
- [4. License](#4.-license)

- [5. Contact](#5.-contact)

  

## 1. Overview

SignalForge.io provides access to over 50 stock indicators, along with stock price and volume data, via a convenient, easy-to-use REST API. Using the SignalForge.io API requires an API key, which can be obtained for free by signing up on <a href="https://www.signalforge.io">SignalForge.io</a>. 



## 2. Setup

### 2.1. Requirements

Python 3.6+

- [Requests](https://requests.readthedocs.io/en/master/) - The elegant and simple HTTP library for Python, built for human beings.
- [Pandas](https://pandas.pydata.org/docs/)  - An open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language.

### 2.2. Installation

```bash
pip install signal-forge
```



## 3. Examples

### 3.1. Getting stock data

```python
from signal_forge import SignalForge

sf = SignalForge(api_key="<your_api_key>")

df = sf.data(stock_symbols=["AAPL", "FB", "GOOG"])
print(df)
```

output:

```bash
           stock_symbol    open    high     low   close       vwap     volume
date                                                                         
2021-11-04         AAPL  151.58  152.43  150.64  150.96  151.34333   60281337
2021-11-03         AAPL  150.39  151.97  149.82  151.49  151.09334   54511500
2021-11-02         AAPL  148.66  151.57  148.65  150.02  150.08000   69122000
2021-11-01         AAPL  148.99  149.70  147.80  148.96  148.82000   74942363
2021-10-29         AAPL  147.22  149.94  146.41  149.80  148.71667  125381484
...                 ...     ...     ...     ...     ...        ...        ...
2016-10-26         GOOG  806.34  806.98  796.32  799.07  800.79000    1647700
2016-10-25         GOOG  816.68  816.68  805.14  807.67  809.83000    1576400
2016-10-24         GOOG  804.90  815.18  804.82  813.11  811.03667    1697500
2016-10-21         GOOG  795.00  799.50  794.00  799.37  797.62333    1266200
2016-10-20         GOOG  803.30  803.97  796.03  796.97  798.99000    1757500
```

### 3.2 Getting stock data with indicators

```python
from signal_forge import SignalForge

sf = SignalForge(api_key="<your_api_key>")

indicator_names = [
    "insider_activity_sold_shares",
    "real_gdp",
    "social_sentiment_stocks_score"
]

df = sf.data(stock_symbols="AAPL", indicator_names=indicator_names)
print(df)
```

output:

```bash
           stock_symbol    open  ...  real_gdp  social_sentiment_stocks_score
date                             ...                                         
2021-11-04         AAPL  151.58  ...  4877.408                            0.0
2021-11-03         AAPL  150.39  ...  4877.408                            1.0
2021-11-02         AAPL  148.66  ...  4877.408                            1.0
2021-11-01         AAPL  148.99  ...  4877.408                           44.0
2021-10-29         AAPL  147.22  ...  4877.408                           63.0
```

### 3.3. Getting indicator names

```python
from signal_forge import SignalForge

sf = SignalForge(api_key="<your_api_key>")

indicator_names = sf.indicator_names()
print(indicator_names[:5])
```

output:

```bash
['insider_activity_bought_shares', 'insider_activity_sold_shares', 'real_gdp', 'real_gdp_per_capita', 'treasury_yield_3month']
```

### 3.4. Getting normalized data

```python
from signal_forge import SignalForge

sf = SignalForge(api_key="<your_api_key>")

indicator_names = [
    "insider_activity_sold_shares",
    "real_gdp",
    "social_sentiment_stocks_score"
]

# Setting the 'normalized' argument to True will return normalized data. The 'normalization_method' argument
# determines what normalization method is used - it can either be "z-score" (default) or "min-max".
df = sf.data(stock_symbols="AAPL",
             indicator_names=indicator_names,
             normalized=True, 
             normalization_method="min-max")
print(df.head())
```

output:

```bash
           stock_symbol      open  ...  real_gdp  social_sentiment_stocks_score
date                               ...                                         
2021-11-04         AAPL  0.959051  ...  0.985676                       0.502890
2021-11-03         AAPL  0.950027  ...  0.985676                       0.508671
2021-11-02         AAPL  0.936908  ...  0.985676                       0.508671
2021-11-01         AAPL  0.939410  ...  0.985676                       0.757225
2021-10-29         AAPL  0.925988  ...  0.985676                       0.867052
```

### 3.5. Additional arguments

```python
from signal_forge import SignalForge

sf = SignalForge(api_key="<your_api_key>")

# The 'start_date' and 'end_date' arguments can be specified to get data within a certain date range.
# Setting the 'logging' parameter to True will print informative statements about the progress in 
# retrieving data - this can be useful when trying to retrieve a lot of data with a single call.
df = sf.data(stock_symbols=["AAPL", "FB", "GOOG"],
             indicator_names=sf.indicator_names()[:7],
             start_date="2019-07-28",
             end_date="2021-02-16",
             logging=True)
print(df.head())
```

output (**Note:** the amount of API calls required will vary based on your API subscription type):

```bash
Retrieving data from SignalForge.io will require 3 API call(s)
Beginning to retrieve data...
[1/3]    Retrieved indicator(s): ['insider_activity_bought_shares', 'insider_activity_sold_shares', 'real_gdp', 'real_gdp_per_capita', 'treasury_yield_3month', 'treasury_yield_5year', 'treasury_yield_10year'] for stock symbol(s): ['AAPL']
[2/3]    Retrieved indicator(s): ['insider_activity_bought_shares', 'insider_activity_sold_shares', 'real_gdp', 'real_gdp_per_capita', 'treasury_yield_3month', 'treasury_yield_5year', 'treasury_yield_10year'] for stock symbol(s): ['FB']
[3/3]    Retrieved indicator(s): ['insider_activity_bought_shares', 'insider_activity_sold_shares', 'real_gdp', 'real_gdp_per_capita', 'treasury_yield_3month', 'treasury_yield_5year', 'treasury_yield_10year'] for stock symbol(s): ['GOOG']
All requested data has been retrieved.
           stock_symbol    open  ...  treasury_yield_5year  treasury_yield_10year
date                             ...                                             
2021-02-16         AAPL  135.06  ...                  0.57                   1.30
2021-02-12         AAPL  133.92  ...                  0.50                   1.20
2021-02-11         AAPL  135.47  ...                  0.46                   1.16
2021-02-10         AAPL  136.04  ...                  0.46                   1.15
2021-02-09         AAPL  136.18  ...                  0.48                   1.18
```

## 4. License

This project is under the <a href="https://github.com/Dvrki/signal-forge-api-python/blob/master/LICENSE">BSD 3</a> License.



## 5. Contact

If you have any questions, please reach out to support@signalforge.io.