# Create Chart

This guide explains how to create the chart. In this guide, you can check out how to import, analyze, and visualize data as a chart.

## Contents

* [Select Mode](/analytics/create-chart/select-mode)
* [Function mode](/analytics/create-chart/function)
* [Python mode](/analytics/create-chart/python)


# Select Mode

Before creating chart, you can select either Function mode or Python mode.

## Function mode

Function mode is useful for non-tech users. You can simply analyze data with Excel-like functions. Please check out the guide below:

* [Function mode](/analytics/create-chart/function)
* [Function Library](/library/function-library)

## Python mode

Python mode is scalable solution for those who can code. You can analyze data in more customizable way.

* [Python mode](/analytics/create-chart/python)
* [Python Library](/library/python-library)

## Switch mode

{% hint style="info" %}
If you switch the chart mode, code written in current mode will be deleted.&#x20;
{% endhint %}

You can switch chart creation mode by pressing the button on top-right of the page.


# Function mode

This guide explains how to create chart in function mode. In this guide, you can check out how to import, analyze, and visualize data in using Excel-like functions.

The function mode is focused on making it **easy**, **fast** and **intuitive** to create the indices which give insights of the market, by combining **time-series data** and **functions** that execute mathematical calculations.

Compared to the **python mode**, function mode can calculate time-series data and get the technical indicators from the market data **easily** without any coding technics such as handling loop. However, if you want to apply some complex calculations based on probabilistic or numerical methods, you are advised to use python mode.

## Contents

* [1. How to import data](/analytics/create-chart/function/1.-how-to-import-data)
* [2. How to analyze data](/analytics/create-chart/function/2.-how-to-analyze-data)
* [3. How to visualize data](/analytics/create-chart/function/3.-how-to-visualize-data)


# 1. How to import data

This guide explains how to import data and select time range of the data

In Function mode, you should follow the two steps below to import data completely. You must select and import all the datas all data directly on the Create Chart page to call and analyze.&#x20;

## Contents

1. [Select Data](/analytics/create-chart/function/1.-how-to-import-data/select-data)\
   How to select the data to preview
2. [Select Time Range](/analytics/create-chart/function/1.-how-to-import-data/select-time-range)\
   How to select time range of the data
3. [Data Setting](/analytics/create-chart/function/1.-how-to-import-data/data-setting)\
   How to change time range and delete the imported data


# Select Data

Data are the time-series tables, which has one time column and the other

First you need to do is importing data to analyze. Select the data to import following the guide below.

1. Click <img src="/files/uJUaoXlIuoW0HA1FsvHo" alt="" data-size="line"> button on the left bar
2. Select the Type, Exchange, Metric, Symbol sequently (Currently only CEX data supported)

<figure><img src="/files/N9wpytlqtncZKpwMAI0W" alt=""><figcaption></figcaption></figure>

3. Once you selected the data, [Select Time Range](/analytics/create-chart/function/1.-how-to-import-data/select-time-range) will be automatically set as next step


# Select Time Range

This guide explains how to select the time range for data

## Select Time Range

<figure><img src="/files/wNTf0j9A7lc7owBRIZpO" alt=""><figcaption><p>Select Time Range Modal</p></figcaption></figure>

1. After selecting the data, you should select the time range of the data
2. You could choose either type of the time range: **Historical** or **Live**
3. Selected time range should be wider than the imported data
4. After selecting time range, press Apply button to completely import data

## Historical Range

Historical time is a fixed date and time.

1. **Click**  ![](/files/okah4VBWCTKcmJP3KJeu) on the header
2. Select Date on the calendar.&#x20;
3. After selecting date, you can select hour and minute of the date. 00:00 is set as a default.

## Live Range

Live time is a variable date and time, based on real-time. For example, if you want to make update data automatically over time, you should select live time.

1. **Click** ![](/files/MxBbppuiUl3DBGtDxB4z) chip on the header
2. You can select the Live time range as below:

{% tabs %}
{% tab title="Start Time" %}

* Last 1 hour
* Last 4 hours
* Last 8 hours
* Last 12 hours
* Last 1 day
* Last 3 days
* Last 5 days
* Last 7 days
* Last 14 days
* Last 21 days
* Last 30 days (Selected as default)
* Last 60 days
* Last 90 days
* Last 180 days
  {% endtab %}

{% tab title="End Time" %}

* Set to current (Selected as default)
* Last 1 hour
* Last 4 hours
* Last 8 hours
* Last 12 hours
* Last 1 day
* Last 3 days
* Last 5 days
* Last 7 days
* Last 14 days
* Last 21 days
* Last 60 days
* Last 90 days
* Last 180 days
  {% endtab %}
  {% endtabs %}

## Combination Range

1. You can select Historical for Start time, and Live for End time as below:

* Set time range as 2020-01-01 00:00\~Current
* Set time range as 2021-03-02 23:59\~Last 1 hour

2. However, you cannot select Live for Start time, and Historical for End time. End time should always be further than Start time.

##


# Data Setting

This guide explains how to change time range of data or delete the data

## Delete Data

![](/files/PST7zCVyWIVs29rZYQ5V)

You can delete the imported data as follows:

1. On the left-hand bar, you can find the list of imported data.
2. Select the data you want to delete.
3. Click the **DELETE** button at the bottom right.

{% hint style="danger" %}
Please be aware that once you delete the data, it might affect the result. So please check the code written after deleting data.
{% endhint %}

***

## Change Time Range

![](/files/RabioL0dJA1m5Dzi6mKo)

You can change the time range of data as follows:

1. On the left-hand bar, you can find the list of imported data.
2. Select the data you want to change the time range for.
3. Click the **Change time range** button at the bottom right.

{% hint style="danger" %}
Please be aware that once you change the time range of the data, it might affect the result. So please check the code written after changing time range.
{% endhint %}


# 2. How to analyze data

This guide explains how to write, add, and run Functions.

## Contents

* [Data Details](/analytics/create-chart/function/2.-how-to-analyze-data/data-details)
* [Function Setting](/analytics/create-chart/function/2.-how-to-analyze-data/function-setting)
* [How to write functions](/analytics/create-chart/function/2.-how-to-analyze-data/how-to-write-functions): How to write functions with imported data
* [Function Library](/library/function-library): The list of formulas supported
* [Broken mention](broken://pages/HcS8mh5LlZnPca47EbRV): The examples of charts made in Function mode


# Data Details

<figure><img src="/files/yZJYDENqc6ehLCp07Lcw" alt=""><figcaption></figcaption></figure>

As you imported the data, you can find out that data are the time-series tables, which has one **time** column and the others as the **indices** at the time.&#x20;

| Item                                          | Description                                                                                                                                                                      |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Raw data alias<br>(e.g. R1, R2, R3...)</p> | <ul><li>After the data is imported, you can get the unique alias.</li><li>These are used as the variables in code area to call them, working as a prefix of the column</li></ul> |
| <p>Column name<br>(e.g. R1\_base\_volume)</p> | <ul><li>At the side bar, if you select a datum, you can see which indices does it has.</li></ul>                                                                                 |

You can preview actual values of the data as a table. It helps you get the context of the data you are using for the code. Follow these steps as below:

1. Select data you want to preview at the left side bar or right next to the side bar.
2. Click the column name you want to copy.
3. Once you copied the column, paste it on the function editor.


# Function Setting

## Function Editor

The function editor is an area where you can write, run, add, delete, and name functions. Each function has its own code area and code output, and its code does not affect the other functions.&#x20;

### Code area

<figure><img src="/files/M0Dsi1KXmF6FXXewy9uy" alt=""><figcaption></figcaption></figure>

The code area is where you are going to write down your function code. When you type **spacebar**, the auto complete dropdown is given. The Auto complete dropdown suggests functions by using the keyword you write after typing spacebar. Use **up/down arrow** keys to get to the item you want to add and press **enter** to add the function into the code area.

You can run and get the result of the functions as follows:

1. Select a function tab you want to code.
2. After code is completely written, click **Run** button.
3. At the **Code Output** area below the code editor, you'll find out the result.
4. You can visualize the result in chart at **Visualization Setting** tab.

### Code Output

<figure><img src="/files/cky7zjkjfxT0iLqJd8f5" alt=""><figcaption></figcaption></figure>

When you click a **run** button after filling out the functions, you can get the result of every function you made. And the table filled with the result can be seen at the code output.&#x20;

If the result is not shown or the error comes out, then it means that your function may has an error somewhere. Fix your function code and run again to get the right result.

***

## Add Function

<figure><img src="/files/SBmXqicWcns6V8Qgh75v" alt=""><figcaption></figcaption></figure>

You can add the Function as follows:

1. Click the ADD button at the right side.
2. You can add up to 5.

***

## Delete Function

<figure><img src="/files/ZEUBXr3o0Uk52mOVemSt" alt=""><figcaption></figcaption></figure>

<img src="/files/wIG5i5yXIVib8yKb2iON" alt="" data-size="original">

You can delete the Function as follows:

1. Select the Function on the code editor you want to delete.
2. Click the **DELETE** button at the right side.
3. The message will pop up to ask you confirm deletion. Click **DELETE**

***

## Name Function

<figure><img src="/files/AF5lj3yIXBES9aURfzmw" alt=""><figcaption></figcaption></figure>

You can name the function. It'll be displayed when the function is visualized as chart.

1. Select the Function on the code editor you want to rename.
2. Press the input right below the function tab
3. Name changes will be automatically saved and applied to chart.


# How to write functions

This guide explains how to get help writing functions.

## Rules

1. There are **three** data types mainly concerned.
   1. **Type1 : Number.** Represents a numeric value. In calculation it is handled as a **decimal type**, so that it has a precision up to 12th decimal place.
   2. **Type2 : Time-series** combined by **time and value only.** The array that has only time and value columns. The type of elements in value is number.&#x20;
   3. **Type3 : Time-series** with **more columns** than 2. The array that has multiple columns as number type. Usually, the imported data itself belong to it.&#x20;
2. As a **result** of function, type **2** and **3** are allowed. However, considering the compatibility for visualizing multiple functions in a chart, **2** is advised as a result.
3. Sometimes, time-series data could have **null** as a column's value, which represents **unknown** or **not existing**. If a arithmetics are applied between null and number, it would return null except for + and -.

***

## Arithmetics

You can apply arithmetics such as +(add), -(subtract), \*(multiply), /(divide), %(remainder) and etc, not only with the numbers but **also with the time-series**.

* An arithmetic with a **number** and **the time-series** is applied to every number values in the time-series with the number.
* An arithmetic between two time-series executes calculation with the **values** **at the same time**. Handling on not-matched time is different by the arithmetics.

{% hint style="info" %}
When applying arithmetic between two time-series, **only type 2** time-series are allowed to prevent ambiguity.
{% endhint %}

Arithmetic by **function** is also possible. For example, `R1 + 3` is same as `add(R1+3)`. Moreover, some functions such as `divide` has more option when using function. `divide(R2,5,4)` will perform division on the number values in `R2` by 5 and round it up to the 4th decimal place.

***

## Functions

We support a variety of functions that can be useful to handle the time-series data. Not only the functions derived from the other programming languages like `max`, `exp`, `ifThen`, and `compare`, but also some useful **utility functions** such as `filter`, and `convert` and the **technical indicators** calculated from the market data such as `rsi(relative strength index)`, `mfi(money flow index)`.

See function library for the full list of the functions.

### Utility functions

Unlike numbers time-series could return unexpected result unless the data is well-controlled. To prevent such case, we supports utility functions to refine the data before applying to the other functions.

The followings are **the most used** utils.

#### **filter**

Filter extracts a specific columns **from the type 3** time-series and returns the extracted one as a **type 2** time-series. You can also apply filter by **\_ convention**.&#x20;

<pre><code># 1. It returns type 2 time-series with time, and quote_volume columns from R1.
<strong>filter(R1, quote_volume)
</strong>
# 2. It works same as filter(R1, quote_volume)
<strong>R1_quote_volume
</strong>
# 3. _ convention only works on a data alias
<strong>slide(R1, -2)_quote_volume # ERROR
</strong><strong>filter(slide(R1, -2), quote_volume) # correct
</strong><strong>slide(R1_qoute_volume, -2) # correct
</strong></code></pre>

#### **convert**

Convert manipulates the **interval** of the time-series. Most of the time-series data have their own interval. Candlesticks would have 1 day, 1 hour or 5 minutes interval, and funding histories usually have about 8 hours interval. However, many functions assumes that the data have the same intervals. To meet that requirement, convert has come out.&#x20;

When converting, the values of newly added time are same as the most recent value at that time.

Allowed intervals are **d(day)**, **h(hour)**, and **min(minute).**

It also has a third argument as a **true** or **false**. If true, the filling and removing performs to the current time. Or if false, it performs only to the last time of the original data.

<pre><code># 1. convert R2's interval into 10 minutes
# to the current time.
<strong>convert(R2, 10min, true)
</strong>
# 2. convert R3's interval into 3 days
# and fill/remove the data only to the last time of R3
<strong>convert(R3, 3d, false)
</strong></code></pre>

#### fillInterval

Even if you import a 5 minutes candlestick data, it doesn't mean that the data always has a row for each 5 minutes. It varies by the exchange's policy. For example, there are exchanges that do not create a row at a time when the trade didn't happen. However, some functions might not work in that case. This is when the **fillInterval** is needed.

fillInterval evaluates the interval of the given data, and then fills the omitted time as the **previous values**. If you want to fill the values with **null**, not the previous ones, then you can use **fillIntervalWithNull**.

<pre><code># 1. fill intervals of R2_close.
# In fact, It's recommended to use `convert` if you know the interval.
<strong>fillInterval(R2_close)
</strong>
# 2. fill interval with null of R3, then get the high value of it.
# This could be a good function for visualization.
<strong>filter(fillIntervalWithNull(R3),high)
</strong></code></pre>

#### slide

You may want to calculate the values between the ones of the current and the past. For example, to get the amount of **daily change** of the close price, `(close price of (time A)) - (close price of (time A - 1 day))` is needed. **Slide** came out to resolve such case with the interval data.

Slide function shifts the **time** of the interval data. The first argument of the slide is the **data to shift**, and the second one is a number, the **amount of shifted interval**. If it is positive, then the time  moves to the **future**. On the other hand, it moves to the past if it is negative.

<pre><code># 1. Get the daily change of the close price of R1
# Assume that R1 is a daily candlestick data
<strong>R1_close - slide(R1_close, 1)
</strong><strong>R1_close - (slide(R1_close, 1) * ((R1_close * 0) + 1)) # removing invalid tail value
</strong></code></pre>

### Technical indicators

There are functions that helps you get the **technical indicators** such as `rsi(relative strength index)`, `mfi(money-flow index)`, `trix(triple exponential smoothed moving average)`, and etc, by using the market data easily. For convenience, most of them automatically filter columns even if you insert type 3 data as the argument.&#x20;

On the other hands, some functions like `stochastic(stochastic oscillator)` requires type 3 candlestick data, not a type 2 filtered one.

And if the function uses **volume** data, we recommend you to insert filtered volume data in it. It's because the candlestick data have a lot of volume columns(quote\_volume, buy\_quote\_volume, base\_volume, etc), and this fact causes inconsistent choice of volume at the function's logic.

<pre><code># 1. Those two functions return the same RSI result.
<strong>rsi(R1)
</strong><strong>rsi(R1_close)
</strong>
# 2. It calculates RSI by the high price of R1
<strong>rsi(R1_high)
</strong>
# 3. It returns TRIX of R2
<strong>trix(R2)
</strong>
# 4. However, it returns error, since R2_close does not have `high` and `low` columns.
<strong>trix(R2_close)
</strong></code></pre>

***

## Function failed

Sometimes, the function could fail. If it fails, you would see the error messages of the result of the data becomes empty. Then you have to fix the code and try again.


# Function Library


# Function Chart Examples


# 3. How to visualize data

This guide explains how to visualize data in function mode. In this guide, you can check out how to manage and apply various chart types

## Contents

* [Line & Bar Chart](/analytics/create-chart/function/3.-how-to-visualize-data/line-and-bar-chart)
* [Doughnut Chart](/analytics/create-chart/function/3.-how-to-visualize-data/doughnut-chart)
* [Number Chart](/analytics/create-chart/function/3.-how-to-visualize-data/number-chart)
* [Table Chart](/analytics/create-chart/function/3.-how-to-visualize-data/table-chart)
* [Color Setting](/analytics/create-chart/function/3.-how-to-visualize-data/color-setting)


# Line & Bar Chart

Once you get to the visualization tab with the function code results, you can see the line & bar is activated by default.&#x20;

Each **series** corresponds to a function. For example, if you set 5 functions, then you will see 5 series of lines constitute a chart. The `X-axis` of the chart is **time** and the `Y-axis` is **value**(or any other column of which the values are the numbers).

{% hint style="warning" %}
Line & bar type assumes that every function result is a time-series with **time** and **value** columns only. If your function result has columns other than time and value, we advise you to use **table** type instead.&#x20;
{% endhint %}

***

## Series options

Series options are the configures applied to each function.

### Line or Bar

![](/files/D67Tl1B8MRTwkVGA3MLH)

You can choose to display each function as a chart, and you can choose the chart type (**line** or **bar**).

### Z-index

![](/files/715GY0R96GDRevhcJR2q)

You can choose the order of the chart displayed. The larger the z-index, the more forward the chart is displayed.

### Y-index

![](/files/30A9XRcnahe4o62MJwf1)

You can choose which Y-axis the function belongs to. The functions with the same Y-index will share the same Y-axis. This option is available only when [multiple Y-axis](#multiple-y-axis) option is activated. It can be chosen from 1 to 3.

***

## Common options

Common options are the options that affects the chart and every series.

### Line Stack

![](/files/5F5GQV7bgiu3lEwyOnSx)

Line stack is a chart setting that stacks multiple lines on top of each other. When line stack is turned on, all lines are stacked.

### Bar Stack

![](/files/0TnvXCKHFiQ8eiM7QIcJ)

Bar stack is a chart setting that allows you to stack multiple bars on top of each other. When bar stack is turned on, all bars are stacked.

### Multiple Y-axis

![](/files/wsDOYLFtdamZJYNcXpD0)

Multiple Y-axis is a chart setting that allows you to plot multiple Y-axes on the same chart. This is useful for comparing the values of different variables on the same scale.

### Hide Y-axis

![](/files/LesEbOeJWtGCfZAcROi4)

Hide Y-axis is a chart setting that allows you to hide one or more Y-axes on a chart. This is useful for when you only want to focus on a specific variable, or when you want to simplify the chart.

### Line Width

![](/files/xf9DdYH5URkNlJMYZASa)

You can adjust the width of the line chart.

### Bar Width

![](/files/tEzDTZV3s1UJa7xiblel)

You can adjust the width of the bar chart.


# Doughnut Chart

![](/files/uCmtqvx8RkOdxsR5hpxz)

You can choose to display each function as a stacked doughnut. The filters for **average, minimal, maximum, amount, and first** will be applied at once. On the detail page, you can select the category to display.


# Number Chart

![](/files/8ZoSNBvt01TzFl7dNR7d)

You can choose to display each function as a number chart. The filters for **average, minimal, maximum, amount, and first** will be applied at once. On the detail page, you can select the category to display.


# Table Chart

![](/files/UATgKycHH09AHpcm7aOK)

You can choose to display each function as a table.


# Color Setting

![](/files/NH0R8gGkMRryL1ceZdbO)

You can choose color of each function. The color will be applied to line, bar, and doughnut chart at once.


# Python mode

This guide explains how to create chart in Python mode. In this guide, you can check out how to import, analyze, and visualize data in Python language.

## Contents

* [1. How to preview data](/analytics/create-chart/python/1.-how-to-preview-data)
* [2. How to analyze data](/analytics/create-chart/python/2.-how-to-analyze-data)
* [3. How to visualize data](/analytics/create-chart/python/3.-how-to-visualize-data)


# 1. How to preview data

![](/files/5bMVJAfPNbuU3sd5TCQj)

To get the context of the data, you can import the data to preview. Selecting data preview is same as [Select Data](/analytics/create-chart/function/1.-how-to-import-data/select-data) in Function mode.

{% hint style="info" %}
Please notice that in Python mode, the data and the time range you selected to preview will not affect the actual Python code written.
{% endhint %}


# 2. How to analyze data

This guide explains how to analyze data in Python mode.

## Contents

* [How to write Python](/analytics/create-chart/python/2.-how-to-analyze-data/how-to-write-python): How to call and analyze data in Python
* [Python Library](/library/python-library): The list of Python methods supported
* [Broken mention](broken://pages/HcS8mh5LlZnPca47EbRV): The examples of charts made in Python mode


# Python Setting

## Python Editor

The python editor is an area where you can write, run, debug your own python code to analyze, and get the result of the code.

### Code Area

<figure><img src="/files/5wFkMxlll7LHvLrflBAE" alt=""><figcaption></figcaption></figure>

Code area is an area to write your python code. Unlike the [function mode](/analytics/create-chart/function), the python mode does not have multiple tabs, but has only one code area. You can get the market data by using functions in [Python Library](broken://pages/NJYXike2frU5BSOf9OUk), and analyze them with the popular libraries of python, such as [numpy](https://numpy.org/), [pandas](https://pandas.pydata.org/), and etc.

### Code Output

<figure><img src="/files/i7Ap65dISEdlc42KbIpG" alt=""><figcaption><p>The data in result variable is shown in a table format.</p></figcaption></figure>

After selecting Run button, the code's result can be seen at the code output. A `pandas.DataFrame` object you've set to `result` variable is returned as a result of the code run.&#x20;

### Console Log

## Run


# How to write Python

## Python code

The main goal is to put the code result you want to get into the `result` as a `pandas.DataFrame` object.

Your code will be wrapped by the following codes and be executed in this form. Be aware that `import` is **not allowed** in your code.

```python
import math
import numpy as np
import pandas as pd
import time
import datetime
import decimal
import get_raw_data, get_raw_data_in_df # functions to get the time-series data

# The object you have to put your code's result into
result : pd.DataFrame


'''
You code runs here
'''


# Convert result into JSON array.
# The structure should be the table with the columns.

return result
        .where(pd.notnull(code_dict["result"]), None)
        .replace({np.nan: None})
        .to_dict(orient="records")


```

***

## How to get market data

Unlike the [function mode](/analytics/create-chart/function), you will import the data you need in the **python code**. We provide some functions to import the them.

### 1. get\_raw\_data

`get_raw_data` is a function to get the data you can find in [data preview](/terminal/create-bot-strategy/1.-how-to-preview-data). It returns the data as an array of dictionaries. It requires four arguments; `table_name`, `symbol`, `start_time`, and `end_time`.

Check [**here**](https://docs.unblinked.com/analytics/create-chart/python/2.-how-to-analyze-data/pages/kZ8hy0a23Eo4qUWgraCg#1.-get-the-time-series-data) for more detail.

***

### 2. get\_raw\_data\_in\_df

`get_raw_data_in_df` is same as `get_raw_data`, but it refines the result into `pandas.DataFrame` type, and converts `decimal.Decimal` type values in it into `float`.

It is useful to apply methods from pandas such as `ewm` to the data.

Check [**here**](https://docs.unblinked.com/analytics/create-chart/python/2.-how-to-analyze-data/pages/kZ8hy0a23Eo4qUWgraCg#2.-get-the-time-series-data-in-dataframe) for more detail.

***

## Information&#x20;

Python version : 3.11.1

pandas : 2.0.0

numpy : 1.24.2


# Python Chart Examples


# 3. How to visualize data

This guide explains how to visualize data in Python mode. In this guide, you can check out how to manage and apply various chart types

## Contents

* [Line & Bar Chart](/analytics/create-chart/python/3.-how-to-visualize-data/line-and-bar-chart)
* [Table Chart](/analytics/create-chart/python/3.-how-to-visualize-data/table-chart)


# Line & Bar Chart

For your chart looks pretty and informative, setting appropriate visualization option is mandatory. In Python mode, we support various options optimized to the **time-series results** from the function codes to help visualizing the charts.

Currently there are two types available for charts in python mode; **line & bar**, **table** You can activate/deactivate each type by using the toggles at the side bar.&#x20;

***

![](/files/MaF47MyNO9o8Xd3z7CTG)

Once you get to the visualization tab with the python code results, you can see the line & bar is activated by default.&#x20;

***

## X-axis

![](/files/XEFF2Mk1dF89kSOJWxzG)

### Value

You can select which column to apply as the X-axis

### Type

You can select the type of X-axis. The options are:

* Time: The X-axis will be a timeline, with each point representing a specific point in time.
* Category: The X-axis will be a list of categories, with each point representing a member of a category.
* Value: The X-axis will be a list of values, with each point representing a specific value.

***

## Series Setting

### Add Series

![](/files/t99GrYu2wsOuA4665Fa7)

Series options are the options that can be set for each series one by one. By adding the series, you can select which column(value) to be visualized.

### Line / Bar select

![](/files/W4z7fdhZHpvCYUj2TqBH)

Line / Bar select button is used to change the **chart type** of the series. If you select `Line`, then the series becomes a line chart. Or if you select `Button`, then the series is shown as a bar chart. Default is `Line`.

### Color

![](/files/KrSDbCmOF41Prez5n3Rk)

After adding series, you can set the color of series

### Value

![](/files/yys68NEDN4F4Cu6YBPbX)

You can select Y-axis value of each series.

### Z-index

![](/files/715GY0R96GDRevhcJR2q)

**Z-index** is used to determine which series is shown over/under another one. The series with the larger z-index will be overlapped over the others with the smaller z-index.

### Y-index

![](/files/30A9XRcnahe4o62MJwf1)

You can choose which Y-axis the series belongs to. The series with the same Y-index will share the same Y-axis. This option is available only when [multiple Y-axis](#multiple-y-axis) option is activated. It can be chosen from 1 to 3.

***

## Common options

Common options are the options that affects the chart and every series.

### Stack

![](/files/dVJPCyPl7ZH9QgCUYJBK)

In Python mode, you can choose whether to stack series with same value.

### Multiple Y-axis

![](/files/wsDOYLFtdamZJYNcXpD0)

Multiple Y-axis is a chart setting that allows you to plot multiple Y-axes on the same chart. This is useful for comparing the values of different variables on the same scale.

### Hide Y-axis

![](/files/LesEbOeJWtGCfZAcROi4)

Hide Y-axis is a chart setting that allows you to hide one or more Y-axes on a chart. This is useful for when you only want to focus on a specific variable, or when you want to simplify the chart.

### Line Width

![](/files/xf9DdYH5URkNlJMYZASa)

You can adjust the width of the line chart.

### Bar Width

![](/files/tEzDTZV3s1UJa7xiblel)

You can adjust the width of the bar chart.

***

<figure><img src="/files/ZBKfpCPBPcJsQZw2cMhF" alt=""><figcaption></figcaption></figure>


# Table Chart

![](/files/pOAdgRkfIL8cYjg8evxx)

The entire code output in Python is displayed as a table by default. You cannot select whether to display the table or not.

<figure><img src="/files/gZgYXLKWqjUig3F5FKtX" alt=""><figcaption></figcaption></figure>


# Publish Chart

{% hint style="info" %}
Once you published the chart, you'll be unable to edit the published one. Rather, you should [Fork Chart](/analytics/fork-chart) and edit the newly created chart.&#x20;
{% endhint %}

## ![](/files/1Ea4HRBQDlMEl5PCPmqF)

## Chart Title

Chart title field is required to publish the chart. You can add or edit title after publishing the chart

## Chart Description

Chart description field is optional to publish the chart. Shortly describe your chart. You can add or edit description after publishing the chart.


# Chart Examples

Here're the list of chart examples made in each mode.

## Function mode charts

* [RSI Threshold](https://data.unblinked.com/analytics/chart/885104864992231434?type=lineBar)
* [OPEN CLOSE GAP](https://data.unblinked.com/analytics/chart/885109223289290764?type=lineBar)
* [Funding fee annaul return conversion](https://data.unblinked.com/analytics/chart/885113137161928716?type=lineBar)
* [Vortext Indicator](https://data.unblinked.com/analytics/chart/885107727929671690?type=lineBar)
* [Binance spot MFI](https://data.unblinked.com/analytics/chart/881432721620959242?type=number)

## Python mode charts

* [Binance spot top 10 volume ratio ](https://data.unblinked.com/analytics/chart/884309550013939723?type=lineBar)

You can check out how the charts are made by clicking **Fork** button on the top right.


# Fork Chart

You can fork chart if you want to edit already published chart or duplicate the chart. You can fork the chart samples displayed on the main page or the charts made by yourself.


# Create Bot Strategy

## What is Bot?

The **UnBlinked bot** is a process that performs trading user's asset automatically based on a strategy written in **python** language. Basically, it is a pair of **code** and **scheduler**. Once you set a code and scheduler, and run a bot, then the bot will execute the code on schedules set by the scheduler.

As the main logic of bots are written in **python code**, there's no blackbox on bot's order decisions. Also, you can fix/improve/drop your trading strategies in detail by the code.&#x20;

Even if you don't know much about the python, you can still run your own bot by [forking](/terminal/fork-strategy) codes from [examples](/terminal/strategy-examples), or the ones of the others, and optimize them with just a little bit of code change.

<img src="/files/I9gPhkF97l5T0iJWLw7n" alt="Concept of bots running in user&#x27;s account for now. Bots are the (code, scheduler) pairs." class="gitbook-drawing">

Updates such as **socket** and **variables** will be added sooner or later.

***

## Scheduler

***

## code

Check [How to write code](/terminal/create-bot-strategy/0.-how-to-write-code).


# 0. How to write code

## Code area

After setting the scheduler type, you will see an empty code area. You can write your own code in this area, and once the bot runs, it will execute the code for each time scheduled by the scheduler type.

When the code is actually executed, it will be wrapped like below, so that the methods and functions called in the code work properly.

Be aware that `import` is **not allowed** in your code.

{% hint style="warning" %}
After running your code, the variables will **not be preserved** in the memory. In other words, the variables saved at the end of the previous schedule are not accessible at the beginning of the next schedule.
{% endhint %}

{% code overflow="wrap" %}

```python
# Available libraries
import math
import numpy as np
import pandas as pd
import time
import datetime
import decimal

import get_raw_data, get_raw_data_in_df # functions to get the time-series data

import PublicAPI # A class to send public API requests  
import PrivateAPI # A class to send private API requests

# publicAPI is automatically initiated.
# privateAPI is automatically initiated by your API keys.
publicAPI = PublicAPI()
privateAPI = PrivateAPI(*api_keys)

# --------------------------------------------------------

'''
You code runs here
'''

```

{% endcode %}


# 1. How to preview data

![](/files/5bMVJAfPNbuU3sd5TCQj)

To get the context of the data, you can import the data to preview. Selecting data preview is same as [Select Data](/analytics/create-chart/function/1.-how-to-import-data/select-data) in Function mode.

{% hint style="info" %}
Please notice that in Python mode, the data and the time range you selected to preview will not affect the actual Python code written.
{% endhint %}


# Fork Strategy


# Strategy Examples

* [RSI Trading Strategy](https://data.unblinked.com/terminal/sample/1?view=scheduler)
* [Bollinger Bands Breakout Trading Strategy](https://data.unblinked.com/terminal/sample/2?view=scheduler)
* [3 Consecutive Declines and Rises Trading Strategy](https://data.unblinked.com/terminal/sample/3?view=scheduler)
* [Daily RSI detector](https://data.unblinked.com/terminal/sample/4?view=scheduler)
* [Vortex Indicator Strategy](https://data.unblinked.com/terminal/sample/5?view=scheduler)
* [Daily MFI detector](https://data.unblinked.com/terminal/sample/6?view=scheduler)

You can check out how the strategies are made by clicking **Fork** button on the top right.


# Deploy Bot

This feature and guide will be updated later


# Manage Strategy


# Strategy Published

## Deploy (Coming soon)

After published, you can deploy strategy as an automated bot.

## View strategy detail

When you click the whole area of the strategy block, the detail page will appear.

### Strategy

#### Scheduler

#### Socket

#### Variable

## View backtest result

## View Version History

## Fork

## Rename

## Delete


# Strategy saved as draft

## Fork

## Rename

## Delete


# Manage Bot

This feature and guide will be updated later


# Change Password


# Register Exchange Account

This feature and guide will be updated later


# Register OTP

This feature and guide will be updated later


# Register Payment

This feature and guide will be updated later


# Function Library


# Python Library

## Functions

They are the functions available in both [**analytic/python mode**](/analytics/create-chart/python), and [**terminal**](/terminal/create-bot-strategy/0.-how-to-write-code).

### 1. Get the Time-series Data

{% code overflow="wrap" %}

```python
get_raw_data(table_name: str, symbol: str, start_time: str, end_time: str) -> list
```

{% endcode %}

`get_raw_data` is a function to get the data you can find in the [data preview](/terminal/create-bot-strategy/1.-how-to-preview-data). It returns the data as a list of dictionaries.

#### Arguments

* `table_name` : (string) The name of the table you want to get. It can be seen right next to the data alias at data preview. Check the [**data list**](/faq/data/dataset/data-list) to see the list of available `table_name`.

<figure><img src="/files/HC2RvJz5fivksJbdccDz" alt="" width="310"><figcaption><p>R1's table_name is binance_um_futures_candlestick_1d.</p></figcaption></figure>

* `symbol` : (string) A category in the table\_name. For instance, if the `table_name = binance_candlestick_1h` and the `symbol = BTCUSDT`, then it would return 1 hour interval candlestick data of **BTCUSDT** in the **Binance spot**  market.
* `start_time` : (string)
* `end_time` : (string) The `start_time` and `end_time` are the time range of the data to get. They are strings of time in `yyyy-MM-dd HH:mm:ss` format. You can set them by  `strftime('%Y-%m-%d %H:%M:%S')` method of `datetime.datetime`.

#### Returns

It returns the data in a **list of the dictionaries**. In the dictionary, every numeric value is `decimal.Decimal` type, and time value is `datetime.datetime`.

{% code overflow="wrap" %}

```python
# Basic ways to get the data
btc_price = get_raw_data("binance_candlestick_1d", 
    "BTCUSDT", 
    "2022-01-01 00:00:00",
    "2022-01-08 00:00:00")
    
# Using datetime.strftime. 2hours ago ~ now.
# Format %F %T can do the same as %Y-%m-%d %H:%M:%S
xrp_price = get_raw_data("binance_um_futures_candlestick_5min", 
    "XPRBUSDT", 
    (datetime.datetime.now() - datetime.timedelta(hours=2)).strftime('%F %T'),
    datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

# The example of the result
'''
[
    {
        "time" : `object of datetime.datetime type`,
        "close" : `object of decimal.Decimal type`,
        "high" : `object of decimal.Decimal type`,
        "low" : `object of decimal.Decimal type`,
        "close" : `object of decimal.Decimal type`,
        ...
    },
    
    ...
]
'''
```

{% endcode %}

***

### 2. Get the Time-series Data in DataFrame

{% code overflow="wrap" %}

```python
get_raw_data_in_df(table_name: str, symbol: str, start_time: str, end_time: str) -> pandas.DataFrame
```

{% endcode %}

`get_raw_data_in_df` is a function that works same as `get_raw_data`, but it refines the result into `pandas.DataFrame` type, and converts `decimal.Decimal` type values in it into `float`.

It is useful to apply methods from pandas such as `ewm` to the data.

#### Arguments

* `table_name` : (string)
* `symbol` : (string)
* `start_time` : (string)
* `end_time` : (string)

#### Returns

It returns the data in `pandas.DataFrame` object. In each entry, every numeric value is `float`, and the time value is `datetime.datetime`.

```python
# The list of the arguments is same as of get_raw_data.
btc_price = get_raw_data_in_df("binance_candlestick_1d", 
    "BTCUSDT", 
    "2022-01-01 00:00:00", 
    "2022-01-08 00:00:00")
```

***

## Terminal-only Functions

Terminal-only function can be used only in the [**terminal**](/terminal/create-bot-strategy/0.-how-to-write-code), which means that they are not available in the analytics.

### 1. Stop Bot

{% code overflow="wrap" %}

```python
shutdown(message: str|None = None) -> None
```

{% endcode %}

It stops the bot that the code is being run. You can call this function when you want to stop your bot in a certain condition.

{% hint style="danger" %}
Do **not** wrap this function by `try ... except`, as it is implemented by raising `ShutdownException`.
{% endhint %}

#### Arguments

* `message` : (string) The message to record to the log when the function is called

#### Returns

None

{% code overflow="wrap" %}

```python
# abstract on how the shutdown() is defined.
def shutdown(message:str=None):
    print(f"Bot shutdown. {message}")
    raise ShutdownException

# Example of using `shutdown()` function

# 1. stop the bot when USDT in the balance is more than 50 or less then 30.
balance = privateAPI.get_balance('binance')
usdt_val = balance['USDT']['amount'] if 'USDT' in balance else 0

if usdt_val > 50 or usdt_val < 30:
    shutdown()
...

# 2. You shouldn't wrap it by try ... except.
try:
    shutdown() # shutdown() doesn't work in this way!
except:
    ...
```

{% endcode %}

***


# Private API

A python class for sending API requests that require authorization.

The **private API** is a class to send API requests that requires authorization, e.g. get my balance in Binance spot wallet, create a buy order of BTCUSDT, cancel an order, and etc.

It is initialized prior to your code as a variable named `privateAPI`. When initializing, it automatically gathers the API keys that you have registered.

{% hint style="info" %}
The private API class can only be used in **terminal**. In other words, it does not work in analytics.
{% endhint %}

{% hint style="warning" %}
If you didn't register the API key of some exchanges, then the functions which send  API requests to them will throw exceptions.
{% endhint %}

```python
...

import PrivateAPI

# `privateAPI` object is automatically initialized
# before running your code.
privateAPI = PrivateAPI()

# your python code is placed here
# In your code, you can send private API requests like below:
## privateAPI.buy('binance', 'BTCUSDT', 0.02, 28000)
```

***

## Common Functions

The **common functions** are the methods of the private API, available for (almost) any exchanges we support. By using these functions, you can easily switch the exchanges you want to send API request to.

Every common function has its first argument as an **exchange**. It specifies which exchange should the request be sent to. For example, you can get the balance in your Binance spot wallet by `privateAPI.get_balance('binance')`, while `privateAPI.get_balance('binance_um_futures')` returns the balance in your Binance USDⓈ-M futures wallet in a same response structure.

For now, the available exchanges are,

* `binance` : Binance Spot
* `binance_um_futures` : Binance USDⓈ-M Futures
* `binance_cm_futures` : Binance COIN-M Futures

### 1. Get Balance

{% code overflow="wrap" %}

```python
privateAPI.get_balance(exchange: str) -> dict
```

{% endcode %}

It is a function to get the asset information in the exchange's wallet.&#x20;

#### Arguments

* `exchange` : (string) The name of the exchange.

#### Returns

It returns the dictionary object with its **key** as a name of the **asset** in string, and **value** as the **information** on the asset. The information has three key:

* `amount` : (float) Current actual amount of the asset. `unrealized_pnl` is not included.
* `available` : (float) The amount of the asset available for trading.
* `unrealized_pnl` : (float) The unrealized PnL(profit & loss) of the asset by the derivatives such as futures position. If the exchange is spot-only, then it is always 0.

Usually, `amount = available + (locked amount because of open orders, maintenance margin, etc.)` holds.

```python
# returning object example
{
    'BTC':{
        'amount':0.122503,
        'available':0.122503,
        'unrealized_pnl':0
    },
    'USDT':{
        'amount':160.32,
        'available':131.681,
        'unrealized_pnl':-3.1252
    }
}
```

***

### 2. Get Positions

{% code overflow="wrap" %}

```python
privateAPI.get_positions(exchange: str) -> dict
```

{% endcode %}

It is a function to get the position information in the exchange's account.

{% hint style="info" %}
This function merges all open positions by the **symbol**. For example, if you have both **0.1 BTCUSDT long** and **-0.2 BTCUSDT short** position, then this method will return **BTCUSDT short** position with the amount = **-0.1**.
{% endhint %}

{% hint style="warning" %}
Only the exchanges which have **futures** are available. c.f. `binance`(= Binance spot) **cannot** be the value of the exchange argument for this function.
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.

#### Returns

It returns the dictionary object with its **key** as a name of the **symbol** in string, and **value** as the **information** on the position. The information has three key:

* `side` : (string) `'long'` for long, or `'short'` for short.
* `amount` : (float) The amount of the position currently holding. Positive for long, negative for short.
* `unrealized_pnl` : (float) The unrealized PnL of the position.

```python
# returning object example
{
    'BTCUSDT':{
        'side':'short',
        'amount':-0.1125,
        'unrealized_pnl':21.3225
    },
    'BTCUSDT_220930':{
        'side':'long',
        'amount':0.351,
        'unrealized_pnl':-1.7862
    }
}
```

***

### 3. Buy

{% code overflow="wrap" %}

```python
privateAPI.buy(exchange: str, symbol: str, amount: float, price: float = None, order_type: str = 'limit', reduce_only: bool = False) -> None
```

{% endcode %}

Create a buy/long order.

#### Arguments

* `exchange` : (string) The name of the exchange.
* `symbol` : (string) The name of the symbol.
* `amount` : (float) The amount of the order. It must be positive.
* `price` : (float) The price of the order to be trade. Default value is `None`. It should be `None` when the `order_type == 'market'`.
* `order_type` : (string) The type of the order. `'limit'` for limit order, `'market'` for market order. Default value is `'limit'`.
* `reduce_only` : (boolean) **Futures** **only** arguments. Enable reduce only option. If it's true, then the order works only to close the current position. Default value is `False`.

#### Returns

None

***

### 4. Sell

{% code overflow="wrap" %}

```python
privateAPI.sell(exchange: str, symbol: str, amount: float=None, price: float = None, order_type: str = 'limit', reduce_only: bool = False, **kwargs) -> None
```

{% endcode %}

Create a sell/short order.

#### Arguments

* `exchange` : (string) The name of the exchange.
* `symbol` : (string) The name of the symbol.
* `amount` : (float) The amount of the order. It must be positive.
* `price` : (float) The price of the order to be trade. Default value is `None`. It should be `None` when the `order_type == 'market'`.
* `order_type` : (string) The type of the order. `'limit'` for limit order, `'market'` for market order. Default value is `'limit'`.
* `reduce_only` : (boolean) **Futures** **only** arguments. Enable reduce only option. If it's true, then the order works only to close the current position. Default value is `False`.

#### Returns

None

***

### 5. Get Open Orders

{% code overflow="wrap" %}

```python
privateAPI.get_open_orders(exchange: str, **kwargs) -> list
```

{% endcode %}

Get the list of the open orders' symbol and order ID.

{% hint style="warning" %}
Some exchanges may require additional arguments.
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.
* `**kwargs` : Additional arguments.
  * `symbol` : (string) The symbol of the orders. `binance`, `binance_um_futures`, and `binance_cm_futures` require symbol argument.&#x20;

#### Returns

It returns a **list** of the **order element**. The **order element** is a dictionary of `symbol` and `order_id`.

* `symbol` : (string) The symbol of the order.
* `order_id` : (string) The order ID of the order.

{% code overflow="wrap" %}

```python
# function example that requires additional `symbol` argument.
# Without symbol='BTCUSDT' in the argument, it would raise an exception.
orders = privateAPI.get_open_orders('binance', symbol='BTCUSDT')

# returning object example
[
    {
        'symbol':'BTCUSDT',
        'order_id':'123612397'
    },
    ...
]
```

{% endcode %}

***

### 6. Cancel an Order

{% code overflow="wrap" %}

```python
privateAPI.cancel_order(exchange: str, order_id, **kwargs) -> None
```

{% endcode %}

Cancel an open order by its order ID.

{% hint style="warning" %}
Some exchanges may require additional arguments.
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.
* `order_id` : An ID of the order to cancel.
* `**kwargs` : Additional arguments.
  * `symbol` : (string) The symbol of the orders. `binance`, `binance_um_futures`, and `binance_cm_futures` require symbol argument.&#x20;

#### Returns

None

{% code overflow="wrap" %}

```python
# function example that requires additional `symbol` argument.
# Without symbol='ETHUSDT' in the argument, it would raise an exception.
privateAPI.cancel_order('binance', '12312722', symbol='ETHUSDT')
```

{% endcode %}

***

### 7. Cancel All Orders

{% code overflow="wrap" %}

```python
privateAPI.cancel_all_orders(exchange: str, **kwargs) -> None
```

{% endcode %}

Cancel all the open orders.

{% hint style="warning" %}
Some exchanges may require additional arguments.
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.
* `**kwargs` : Additional arguments.
  * `symbol` : (string) The symbol of the orders. `binance`, `binance_um_futures`, and `binance_cm_futures` require symbol argument.&#x20;

#### Returns

None

{% code overflow="wrap" %}

```python
# function example that requires additional `symbol` argument.
# Without symbol='BTCUSD' in the argument, it would raise an exception.
privateAPI.cancel_all_orders('binance_cm_futures', symbol='BTCUSD')
```

{% endcode %}

***

### 8. Set Leverage

{% code overflow="wrap" %}

```python
privateAPI.set_leverage(exchange: str, leverage:int, **kwargs) -> None
```

{% endcode %}

Set leverage value.

{% hint style="warning" %}
Some exchanges may require additional arguments.
{% endhint %}

{% hint style="warning" %}
Only the exchanges which have **futures** are available. c.f. `binance`(= Binance spot) **cannot** be the value of the exchange argument for this function.
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.
* `leverage` : The leverage value to set. It is usually a positive integer value.
* `**kwargs` : Additional arguments.
  * `symbol` : (string) The symbol of the orders. `binance_um_futures`, and `binance_cm_futures` require symbol argument.&#x20;

#### Returns

None

{% code overflow="wrap" %}

```python
# function example that requires additional `symbol` argument.
# Without symbol='BTCUSDT' in the argument, it would raise an exception.
privateAPI.set_leverage('binance_um_futures', 5, symbol='BTCUSDT')
```

{% endcode %}

***

### 9. Get API request result

{% code overflow="wrap" %}

```python
privateAPI._get(exchange: str, api_url:str, **kwargs) -> Any
```

{% endcode %}

This is a special function that can call any API requests that read/get the information.

{% hint style="info" %}
If you are about the get **public** API requests such as getting orderbook, getting exchange info, and etc, then user `publicAPI._get()`
{% endhint %}

#### Arguments

* `exchange` : (string) The name of the exchange.
* `api_url` : (string) Endpoint of the request, such as `'/api/v1/exchangeIfo'`.
* `**kwargs` : Additional arguments. They will be used as the parameters of the request.

#### Returns

None

{% code overflow="wrap" %}

```python
# This code will returns the leverage bracket information of 'BTCUSDT'.
# Link : https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data
result = privateAPI._get(
    exchange = 'binance_um_futures', 
    api_url = '/fapi/v1/leverageBracket',
    symbol='BTCUSDT'
)
```

{% endcode %}

***

## Exchange-Only Functions

While common functions make it easy to switch exchanges, there are API requests which are specialized for the specific exchanges. Or, you may want to handle detailed options or values that the common functions cannot cover. In that case, the exchange-only functions can help you with that.

Most of the exchange-only functions have `**kwargs` to support **all the parameters** that the API can have.

The returns are the object obtained by parsing the API response(Usually in JSON format). Therefore, the type of them are **dict**, **list** or **None**.

### Binance

[Binance](/library/python-library/private-api/binance)


# Binance

Binance-only functions

## Binance Spot

The names of the functions related to the Binance spot start with `privateAPI.binance_`.

***

### 1. Get Account Information

{% code overflow="wrap" %}

```python
privateAPI.binance_account_info() -> dict
```

{% endcode %}

Get an account information, including the balance, fee rate, and etc.

[API Documentation](https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 2. Get Asset Balance

{% code overflow="wrap" %}

```python
privateAPI.binance_asset_balance(asset: str) -> dict
```

{% endcode %}

Get the tradable amount(`free`) and locked amount(`locked`) of the asset in the Binance spot account.

This function filters the elements of the `balance` value in the response of the [binance\_account\_info()](#1.-get-account-information).&#x20;

#### Arguments

* `asset` : (string) The name of the asset to get the balance.

#### Response

* `asset` : (string) The name of the asset.
* `free` : (string) The tradable amount of the asset.
* `locked` : (string) The amount of locked asset.

```python
# response example
{ 
    "asset": "BTC",
    "free": "4723846.89208129",
    "locked": "0.00000000"
}
```

***

### 3. Market Order by Amount

{% code overflow="wrap" %}

```python
privateAPI.binance_market_order_by_amount(amount: float, symbol: str, orderside: str) -> dict
```

{% endcode %}

Create a new market order. In this function, the currency of the amount is a **base asset**. For example, If the `symbol = 'BTCUSDT'`(base asset = BTC, quote asset = USDT) and `amount=0.15`, then it creates an order of size **0.15 BTC**.

[API Documentation](https://binance-docs.github.io/apidocs/spot/en/#new-order-trade)

#### Arguments

* `amount` : (float) The amount of the order.
* `symbol` : (string) The name of the symbol to trade.
* `orderside` : (string) To buy, set it as `'buy'`, or `'sell'` to sell.

#### Response

Same as the response in the API documentation.

***

### 4. Market Order by Quote Asset Quantity

{% code overflow="wrap" %}

```python
privateAPI.binance_market_order_by_quote_qty(quoteqty: float, symbol: str, orderside: str) -> dict
```

{% endcode %}

Create a new market order by the amount of the order in the quote asset. In this function, the currency of the amount is a **quote asset**. For example, If the `symbol = 'BTCUSDT'`(base asset = BTC, quote asset = USDT) and `quoteqty=120`, then it creates an order of size **120 USDT**.

[API Documentation](https://binance-docs.github.io/apidocs/spot/en/#new-order-trade)

#### Arguments

* `quoteqty` : (float) The amount of the order in quote asset.
* `symbol` : (string) The name of the symbol to trade.
* `orderside` : (string) To buy, set it as `'buy'`, or `'sell'` to sell.

#### Response

Same as the response in the API documentation.

***

### 5. Limit Order by Amount

{% code overflow="wrap" %}

```python
privateAPI.binance_limit_order_by_amount(amount: float, price: float, symbol: str, orderside: str) -> dict
```

{% endcode %}

Create a new limit order. In this function, the currency of the amount is a **base asset**.

[API Documentation](https://binance-docs.github.io/apidocs/spot/en/#new-order-trade)

#### Arguments

* `amount` : (float) The amount of the order.
* `price` : (float) The price for the order to be filled.
* `symbol` : (string) The name of the symbol to trade.
* `orderside` : (string) To buy, set it as `'buy'`, or `'sell'` to sell.

#### Response

Same as the response in the API documentation.

***

### 6. Cancel Orders on Symbol

{% code overflow="wrap" %}

```python
privateAPI.binance_cancel_orders_on_symbol(symbol: str) -> any
```

{% endcode %}

Cancel all open orders of the symbol.

[API Documentation](https://binance-docs.github.io/apidocs/spot/en/#cancel-all-open-orders-on-a-symbol-trade)

#### Arguments

* `symbol` : (string) The name of the symbol to cancel.

#### Response

Same as the response in the API documentation.

***

## Binance USDⓈ-M Futures

The names of the functions related to the Binance USDⓈ-M futures start with `privateAPI.binance_futures_`.

### 1. Get Account Balance

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_account_balance() -> list
```

{% endcode %}

Get the balance of the assets in the Binance USD-M futures account.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v2-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 2. Get Account Information

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_account_info() -> dict
```

{% endcode %}

Get the account information of the Binance USDⓈ-M futures account.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 3. Get Position Information

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_position_info() -> list
```

{% endcode %}

Get the open position information of the Binance USDⓈ-M futures account.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 4. Market Order

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_market_order(leverage: int, symbol: str, side: str, qty: float) -> dict
```

{% endcode %}

Set the leverage of the symbol and create a market order.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#new-order-trade)

#### Arguments

* `leverage` : (int) The leverage value to set.
* `symbol` : (string) The name of the symbol.
* `side` : (string) `'BUY'` to open long & close short position, or `'SELL'` to open short & close long position.
* `qty` : (float) The contract size to set order. In most case, it is the amount in **base asset**. For instance, `symbol=ETHUSDT`, and `qty=0.12` will create an order of contract size **0.12 ETH**.

#### Response

Same as the response in the API documentation.

***

### 5. Limit Order

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_limit_order(leverage: int, symbol: str, side: str, qty: float, price: float) -> dict
```

{% endcode %}

Set the leverage of the symbol and create a limit order.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#new-order-trade)

#### Arguments

* `leverage` : (int) The leverage value to set.
* `symbol` : (string) The name of the symbol.
* `side` : (string) `'BUY'` to open long & close short position, or `'SELL'` to open short & close long position.
* `qty` : (float) The contract size to set order. In most case, it is the amount in **base asset**. For instance, `symbol=ETHUSDT` and `qty=0.12` will create an order of contract size **0.12 ETH**.
* `price` : (float) The price for the order to be filled.

#### Response

Same as the response in the API documentation.

***

### 6. Cancel Orders on Symbol

{% code overflow="wrap" %}

```python
privateAPI.binance_futures_cancel_orders_on_symbol(symbol: str) -> any
```

{% endcode %}

Cancel all open orders of the symbol.

[API Documentation](https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-orders-trade)

#### Arguments

* `symbol` : (string) The name of the symbol to cancel.

#### Response

Same as the response in the API documentation.

***

## Binance COIN-M Futures

The names of the functions related to the Binance COIN-M futures start with `privateAPI.binance_cm_futures_`.

### 1. Get Account Information

{% code overflow="wrap" %}

```python
privateAPI.binance_cm_futures_account_info() -> dict
```

{% endcode %}

Get the account information in the Binance COIN-M Futures account.

[API Documentation](https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 2. Get Position Information

{% code overflow="wrap" %}

```python
privateAPI.binance_cm_futures_position_info() -> list
```

{% endcode %}

Get the open position information in the Binance COIN-M Futures account.

[API Documentation](https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data)

#### Arguments

None

#### Response

Same as the response in the API documentation.

***

### 3. Market Order

{% code overflow="wrap" %}

```python
privateAPI.binance_cm_futures_market_order(leverage: int, symbol: str, side: str, qty: float) -> dict
```

{% endcode %}

Set the leverage of the symbol and create a market order.

[API Documentation](https://binance-docs.github.io/apidocs/delivery/en/#new-order-trade)

#### Arguments

* `leverage` : (int) The leverage value to set.
* `symbol` : (string) The name of the symbol.
* `side` : (string) `'BUY'` to open long & close short position, or `'SELL'` to open short & close long position.
* `qty` : (float) The size of the contract(=**CONT**) to set order. In most case, **1 CONT** is a size of  **10 USD**, while some symbols such as **BTCUSD** have 1 CONT as **100 USD**. For instance, `symbol=ETHUSD` and `qty=20` will create an order of ETHUSD with the contract size **200 USD**, but `symbol=BTCUSD` and `qty=20` will create an order of BTCUSD with the contract size **2000 USD**.

#### Response

Same as the response in the API documentation.

***

### 4. Limit Order

{% code overflow="wrap" %}

```python
privateAPI.binance_cm_futures_limit_order(leverage: int, symbol: str, side: str, qty: float, price: float) -> dict
```

{% endcode %}

Set the leverage of the symbol and create a limit order.

[API Documentation](https://binance-docs.github.io/apidocs/delivery/en/#new-order-trade)

#### Arguments

* `leverage` : (int) The leverage value to set.
* `symbol` : (string) The name of the symbol.
* `side` : (string) `'BUY'` to open long & close short position, or `'SELL'` to open short & close long position.
* `qty` : (float) The size of the contract(=**CONT**) to set order. In most case, **1 CONT** is a size of  **10 USD**, while some symbols such as **BTCUSD** have 1 CONT as **100 USD**. For instance, `symbol=ETHUSD` and `qty=20` will create an order of ETHUSD with the contract size **200 USD**, but `symbol=BTCUSD` and `qty=20` will create an order of BTCUSD with the contract size **2000 USD**.
* `price` : (float) The price for the order to be filled.

#### Response

Same as the response in the API documentation.

***

### 5. Cancel Orders on Symbol

{% code overflow="wrap" %}

```python
privateAPI.binance_cm_futures_cancel_orders_on_symbol(symbol: str) -> any
```

{% endcode %}

Cancel all open orders of the symbol.

[API Documentation](https://binance-docs.github.io/apidocs/delivery/en/#cancel-all-open-orders-trade)

#### Arguments

* `symbol` : (string) The name of the symbol to cancel.

#### Response

Same as the response in the API documentation.


# Public API

A python class to send the public APIs.

The **private API** is a class to send API requests without authorization, e.g. get the price of some symbol in Binance spot market and etc.

It is initialized prior to your code as a variable named `publicAPI`.

{% hint style="info" %}
&#x20;Currently, the public API is available for **terminal only** for now. We will support this in **analytics/python** mode too in the future.&#x20;
{% endhint %}

```python
...

import PublicAPI

# `publicAPI` object is automatically initialized
# before running your code.
publicAPI = PublicAPI()

# your python code is placed here
# In your code, you can send public API requests like below:
## publicAPI.recent_price('binance', 'ETHUSDT')
```

***

## Common Functions

The **common functions** are the methods of the public API, available for (almost) any exchanges we support. By using these functions, you can easily switch the exchanges you want to send API request to.

Every common function has its first argument as an **exchange**. It specifies which exchange should the request be sent to. For example, you can get the up-to-date price of BTCUSDT in Binance spot by `publicAPI.recent_price('binance', 'BTCUSDT')`, while `publicAPI.recent_price('binance_um_futures', 'BTCUSDT')` returns the price of BTCUSDT perpetual in Binance USDⓈ-M futures.

For now, the available exchanges are,

* `binance` : Binance Spot
* `binance_um_futures` : Binance USDⓈ-M Futures
* `binance_cm_futures` : Binance COIN-M Futures

### 1. Get Current Price

{% code overflow="wrap" %}

```python
publicAPI.recent_price(exchange :str, symbol: str) -> float
```

{% endcode %}

It is a function to get to the up-to-date price of a symbol in the selected exchange.

#### Arguments

* `exchange` : (string). The name of the exchange
* `symbol` : (string) The name of the symbol.

#### Returns

float

***


# Data

Here's the list of FAQ about data


# Dataset

Check [data list](/faq/data/dataset/data-list) to see the list of all data names.

## Interval data

Interval data are the collections of the data with the regular interval. Whole data here can be accessed by [**importing data**](/analytics/create-chart/function/1.-how-to-import-data) at the [analytics function mode](/analytics/create-chart/function/1.-how-to-import-data) or by using methods such as **get\_raw\_data** at the [analytics python mode](/analytics/create-chart/python/2.-how-to-analyze-data/how-to-write-python#how-to-get-market-data) and [terminal](/terminal/create-bot-strategy).

## 1. CEX data

CEX data is a collection of dataset from the **centralized exchanges** such [Binance](https://binance.com) and [OKX](https://okx.com). Most of it are the market data of each exchange. For example, **candlestick** data, which have open, high, low, close price, and volume could be one of the data you will be accessing most. Or you could require **funding\_history** to track the history of the funding rates of a symbol in the perpetual swap.

Whenever you try to access the data, there are four arguments required: **data\_name**, **symbol**, **start\_time**, and **end\_time**.

* **data\_name**

The name of the dataset. Usually, it contains the information of the exchange or market, dataset type, and interval. For example, **binance\_um\_futures\_mark\_candlestick\_1h** means 1 hour-interval candlestick data of the mark price in the Binance USD-M futures market.

* **symbol**

symbol is a sub-category in the dataset. Usually it corresponds to the symbol in the market or the asset name in the dataset. For example, to get the daily BTC/USDT price in the Binance spot market, then you have to set the symbol as **BTCUSDT** with the data\_name as binance\_candlestick\_1d.&#x20;

Beware that the rules of the symbol argument can be varied by the exchanges. For instance, if you want to require BTC/USDT data in OKX, you may have to write symbol as **BTC-USDT**.

In the function mode, you will set data\_name and symbol at the [select data](/analytics/create-chart/function/1.-how-to-import-data/select-data) step

* **start\_time** & **end\_time**

start\_time and end\_time is a time range of the data you require. Both of them should not be empty.

&#x20;In the function mode, you'll be setting them at the [select time range](/analytics/create-chart/function/1.-how-to-import-data/select-time-range) step. On the other hand, you'll be setting them as the **strings** in `yyyy-MM-dd HH:mm:ss` format. You can easily set them by using `strftime` in `datetime` library.

```python
# string representing now in yyyy-MM-dd HH:mm:ss format
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

# 60 day ago from now. using '%F %T' returns same as above.
(datetime.datetime.now() - datetime.timedelta(days=60)).strftime('%F %T')
```

### 1-1. Binance spot

#### - Binance spot candlestick

Candlestick data of the Binance spot market.

data\_name:

binance\_candlestick\_1d, binance\_candlestick\_1h and binance\_candlestick\_5min

**symbol:**

BTCUSDT, ETHUSDT, XRPBUSD, 1INCHBTC and etc.

<table><thead><tr><th width="253">values</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong> - Candlestick prices.</td></tr><tr><td><strong>base_volume</strong></td><td>Volume in base asset. In BTCUSDT, it is the sum of trades in BTC.</td></tr><tr><td><strong>quote_volume</strong></td><td>Volume in quote asset. In BTCUSDT, it is the sum of the trades in USDT. - The sum of buys in base asset.</td></tr><tr><td><strong>buy_base_volume</strong></td><td>The sum of buys in base asset.</td></tr><tr><td><strong>buy_quote_volume</strong></td><td>The sum of buys in quote asset.</td></tr><tr><td><strong>trade_count</strong></td><td>The number of the trades.</td></tr></tbody></table>

### 1-2. Binance USD-M futures

#### - Binance USD-M futures candlestick

Candlestick data of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_candlestick\_1d, binance\_um\_futures\_candlestick\_1h and binance\_um\_futures\_candlestick\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>Candlestick prices.</td></tr><tr><td><strong>base_volume</strong></td><td>Volume in base asset. In BTCUSDT, it is the sum of trades in BTC.</td></tr><tr><td><strong>quote_volume</strong></td><td>Volume in quote asset. In BTCUSDT, it is the sum of the trades in USDT.</td></tr><tr><td><strong>buy_base_volume</strong></td><td>The sum of buys in base asset.</td></tr><tr><td><strong>buy_quote_volume</strong></td><td>The sum of buys in quote asset.</td></tr><tr><td><strong>trade_count</strong></td><td>The number of the trades.</td></tr></tbody></table>

#### - Binance USD-M futures index price

Index price data of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_index\_price\_1d, binance\_um\_futures\_index\_price\_1h and binance\_um\_futures\_index\_price\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the index prices.</td></tr></tbody></table>

####

#### - Binance USD-M futures mark price

Mark price data of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_mark\_candlestick\_1d, binance\_um\_futures\_mark\_candlestick\_1h and binance\_um\_futures\_mark\_candlestick\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the mark prices.</td></tr></tbody></table>

####

#### - Binance USD-M futures funding rate history

Funding history data of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_funding\_history

**symbol:**

BTCUSDT, 1000LUNCUSDT, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>funding_rate</strong></td><td>The rate of the funding fee. If it is positive, then it means that the long positions pay fee to the short positions.</td></tr></tbody></table>

#### - Binance USD-M futures open interest

Open interest data of Binance USD-M futures market

**data\_name:**

binance\_um\_futures\_open\_interest\_1d, binance\_um\_futures\_open\_interest\_1h, and binance\_um\_futures\_open\_interest\_5min

**symbol:**

BTCUSDT, 1000LUNCUSDT, XRPBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open_interest</strong></td><td>The size of open positions. Usually, the value of it is the <strong>base asset</strong> of the symbol.</td></tr><tr><td><strong>open_interest_value</strong></td><td> Open interest value in <strong>quote asset</strong> of the symbol.</td></tr></tbody></table>

#### - Binance USD-M futures Long/Short ratio by accounts

Long/Short ratio data by the number of accounts of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_long\_short\_ratio\_by\_account\_1d, binance\_um\_futures\_long\_short\_ratio\_by\_account\_1h and binance\_um\_futures\_long\_short\_ratio\_by\_account\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

#### - Binance USD-M futures Long/Short ratio by top traders accounts

Long/Short ratio data by the number of top traders accounts of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_1d, binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_1h and binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

#### - Binance USD-M futures Long/Short ratio by top traders positions

Long/Short ratio data by the sum of  the open positions of the top traders of the Binance USD-M futures market.

**data\_name:**

binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_1d, binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_1h and binance\_um\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_5min

**symbol:**

BTCUSDT, BTCUSDT\_230929, ETHBUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

### 1-3. Binance COIN-M futures

#### - Binance COIN-M futures candlestick

Candlestick data of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_candlestick\_1d, binance\_cm\_futures\_candlestick\_1h and binance\_cm\_futures\_candlestick\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>Candlestick prices.</td></tr><tr><td><strong>base_volume</strong></td><td>Volume in base asset. In BTCUSD_PERP, it is the sum of trades in BTC.</td></tr><tr><td><strong>cont_volume</strong></td><td>Volume in contracts. In BTCUSD_PERP, since 1 cont is same as 100USD, <code>cont_volume * 100</code> is same as the volume in USD.</td></tr><tr><td><strong>buy_base_volume</strong></td><td>The sum of buys in base asset.</td></tr><tr><td><strong>cont_buy_volume</strong></td><td>The sum of buys in contracts.</td></tr><tr><td><strong>trade_count</strong></td><td>The number of the trades.</td></tr></tbody></table>

####

#### - Binance COIN-M futures index price

Index price data of the Binance COIN-M futures market. The symbol of it is actually a **pair**, which means that the symbol are made by **base asset** and **quote asset** only. For example, BTCUSD\_PERP doesn't work here.

**data\_name:**

binance\_cm\_futures\_index\_price\_1d, binance\_cm\_futures\_index\_price\_1h and binance\_cm\_futures\_index\_price\_5min

**symbol:**

BTCUSD, ETHUSD and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the index prices.</td></tr></tbody></table>

####

#### - Binance COIN-M futures mark price

Mark price data of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_mark\_candlestick\_1d, binance\_cm\_futures\_mark\_candlestick\_1h and binance\_cm\_futures\_mark\_candlestick\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the mark prices.</td></tr></tbody></table>

#### - Binance COIN-M futures funding rate history

Funding history data of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_funding\_history

**symbol:**

BTCUSD\_PERP, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>funding_rate</strong></td><td>The rate of the funding fee. If it is positive, then it means that the long positions pay fee to the short positions.</td></tr></tbody></table>

####

#### - Binance COIN-M futures open interest

Open interest data of Binance COIN-M futures market

**data\_name:**

binance\_cm\_futures\_open\_interest\_1d, binance\_cm\_futures\_open\_interest\_1h, and binance\_cm\_futures\_open\_interest\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open_interest</strong></td><td>The size of open positions. The unit of the value is <strong>cont</strong>(contract). For example, 1 cont of <strong>BTCUSD_PERP</strong> is 100USD. If open_interest of it is 1500, then it means that <strong>1500 cont(=150000 USD)</strong> is the size of the open positions of BTCUSD_PERP. Cont varies by the symbols.</td></tr><tr><td><strong>open_interest_value</strong></td><td> Open interest value in <strong>base asset</strong> of the symbol. Unlike USD-M, it is in base asset.</td></tr></tbody></table>

#### - Binance COIN-M futures Long/Short ratio by accounts

Long/Short ratio data by the number of accounts of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_long\_short\_ratio\_by\_account\_1d, binance\_cm\_futures\_long\_short\_ratio\_by\_account\_1h and binance\_cm\_futures\_long\_short\_ratio\_by\_account\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

#### - Binance COIN-M futures Long/Short ratio by top traders accounts

Long/Short ratio data by the number of top traders accounts of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_1d, binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_1h and binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_account\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

#### - Binance COIN-M futures Long/Short ratio by top traders positions

Long/Short ratio data by the sum of  the open positions of the top traders of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_1d, binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_1h and binance\_cm\_futures\_long\_short\_ratio\_by\_top\_trader\_position\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>_long</strong></td><td>The ratio of Long position ranged from 0 to 1.</td></tr></tbody></table>

#### - Binance COIN-M futures basis

Basis rate data of the Binance COIN-M futures market.

**data\_name:**

binance\_cm\_futures\_basis\_1d, binance\_cm\_futures\_basis\_1h and binance\_cm\_futures\_basis\_5min

**symbol:**

BTCUSD\_PERP, XRPUSD\_230929, ETHUSD\_PERP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>basis_rate</strong></td><td></td></tr><tr><td><strong>basis</strong></td><td></td></tr><tr><td><strong>annualized_basis_rate</strong></td><td></td></tr></tbody></table>

### 2-1. OKX spot

#### - OKX spot candlestick

Candlestick data of the OKX spot market.

**data\_name:**

okx\_candlestick\_1d, okx\_candlestick\_1h and okx\_candlestick\_5min

**symbol:**

BTC-USDT, ETH-USDT and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>Candlestick prices.</td></tr><tr><td><strong>base_volume</strong></td><td>Volume in base asset. In BTC-USDT, it is the sum of trades in BTC.</td></tr><tr><td><strong>quote_volume</strong></td><td>Volume in quote asset. In BTC-USDT, it is the sum of the trades in USDT.</td></tr></tbody></table>

### 2-2. OKX futures

{% hint style="info" %}
In the dataset, **futures** and **perpetual swap** markets in OKX are merged into the **okx\_futures**.
{% endhint %}

#### - OKX futures & perpetual swap candlestick

Candlestick data of the OKX futures & perpetual swap markets.

**data\_name:**

okx\_futures\_candlestick\_1d, okx\_futures\_candlestick\_1h and okx\_futures\_candlestick\_5min

**symbol:**

BTC-USDC-SWAP, BTC-USD-230414,  TRX-USD-SWAP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>Candlestick prices.</td></tr><tr><td><strong>base_volume</strong></td><td>Volume in base asset.</td></tr><tr><td><strong>quote_volume</strong></td><td>Volume in quote asset.</td></tr><tr><td><strong>cont_volume</strong></td><td>Volume in contracts.</td></tr></tbody></table>

#### - OKX index price

Index price data of the OKX. In actual OKX, the index price is not compared by the market types. But in UnBlinked, you can find it at **OKX futures** category.

**data\_name:**

okx\_futures\_index\_price\_1d, okx\_futures\_index\_price\_1h and okx\_futures\_index\_price\_5min

**symbol:**

BTC-USD,  XRP-USDT, SOL-USDT and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the index prices.</td></tr></tbody></table>

####

#### - OKX futures & perpetual swap mark price

Mark price data of the OKX futures & perpetual swap markets

**data\_name:**

okx\_futures\_mark\_price\_1d, okx\_futures\_mark\_price\_1h and okx\_futures\_mark\_price\_5min

**symbol:**

BTC-USDC-SWAP, BTC-USD-230414,  TRX-USD-SWAP and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the mark prices.</td></tr></tbody></table>

### 2-3. OKX option

#### - OKX option mark price

Mark price data of the OKX option market

**data\_name:**

okx\_option\_mark\_price\_1d, okx\_option\_mark\_price\_1h and okx\_option\_mark\_price\_5min

**symbol:**

BTC-USD-230408-26000-C, BTC-USD-230414-20000-P and etc.

<table><thead><tr><th width="249">value</th><th>description</th></tr></thead><tbody><tr><td><strong>time</strong></td><td></td></tr><tr><td><strong>open</strong>, <strong>high</strong>, <strong>low</strong> and <strong>close</strong></td><td>OHLC of the mark prices.</td></tr></tbody></table>

***

##


# data list

List of table\_name available for `get_raw_data` and `get_raw_data_in_df` functions.

<table data-full-width="false"><thead><tr><th>table_name</th><th data-hidden>group_column</th></tr></thead><tbody><tr><td>table_name</td><td>group_column</td></tr><tr><td>binance_candlestick_1d</td><td>symbol</td></tr><tr><td>binance_candlestick_1h</td><td>symbol</td></tr><tr><td>binance_candlestick_5min</td><td>symbol</td></tr><tr><td>binance_cm_future_funding_history</td><td>symbol</td></tr><tr><td>binance_cm_futures_candlestick_1d</td><td>symbol</td></tr><tr><td>binance_cm_futures_candlestick_1h</td><td>symbol</td></tr><tr><td>binance_cm_futures_candlestick_5min</td><td>symbol</td></tr><tr><td>binance_um_future_funding_history</td><td>symbol</td></tr><tr><td>binance_um_futures_candlestick_1d</td><td>symbol</td></tr><tr><td>binance_um_futures_candlestick_1h</td><td>symbol</td></tr><tr><td>binance_um_futures_candlestick_5min</td><td>symbol</td></tr><tr><td>binance_um_futures_open_interest_1d</td><td>symbol</td></tr><tr><td>binance_um_futures_open_interest_1h</td><td>symbol</td></tr><tr><td>binance_um_futures_open_interest_5min</td><td>symbol</td></tr><tr><td>okx_candlestick_1d</td><td>symbol</td></tr><tr><td>okx_candlestick_1h</td><td>symbol</td></tr><tr><td>okx_candlestick_5min</td><td>symbol</td></tr><tr><td>okx_futures_candlestick_1d</td><td>symbol</td></tr><tr><td>okx_futures_candlestick_1h</td><td>symbol</td></tr><tr><td>okx_futures_candlestick_5min</td><td>symbol</td></tr><tr><td>okx_futures_delivery_history</td><td>index_</td></tr><tr><td>okx_futures_funding_history</td><td>symbol</td></tr><tr><td>okx_futures_index_price_1d</td><td>symbol</td></tr><tr><td>okx_futures_index_price_1h</td><td>symbol</td></tr><tr><td>okx_futures_index_price_5min</td><td>symbol</td></tr><tr><td>okx_futures_long_short_ratio_by_account_1h</td><td>asset</td></tr><tr><td>okx_futures_long_short_ratio_by_account_5min</td><td>asset</td></tr><tr><td>okx_futures_mark_price_1d</td><td>symbol</td></tr><tr><td>okx_futures_mark_price_1h</td><td>symbol</td></tr><tr><td>okx_futures_mark_price_5min</td><td>symbol</td></tr><tr><td>okx_futures_open_interest_and_volume_1h</td><td>asset</td></tr><tr><td>okx_futures_open_interest_and_volume_5min</td><td>asset</td></tr><tr><td>okx_futures_taker_volume_1h</td><td>asset</td></tr><tr><td>okx_futures_taker_volume_5min</td><td>asset</td></tr><tr><td>okx_option_candlestick_1d</td><td>symbol</td></tr><tr><td>okx_option_candlestick_1h</td><td>symbol</td></tr><tr><td>okx_option_candlestick_5min</td><td>symbol</td></tr><tr><td>okx_option_exercise_history</td><td>index_</td></tr><tr><td>okx_option_market_data</td><td>symbol</td></tr><tr><td>okx_option_mark_price_1d</td><td>symbol</td></tr><tr><td>okx_option_mark_price_1h</td><td>symbol</td></tr><tr><td>okx_option_mark_price_5min</td><td>symbol</td></tr><tr><td>okx_option_open_interest_and_volume</td><td>asset</td></tr><tr><td>okx_option_put_call_ratio</td><td>asset</td></tr><tr><td>okx_option_taker_flow</td><td>asset</td></tr><tr><td>okx_margin_lending_ratio_1h</td><td>asset</td></tr><tr><td>okx_margin_lending_ratio_5min</td><td>asset</td></tr></tbody></table>


# What type of data can I use?

Currently, UnBlinked offers **real-time** **centralized exchanges’ market data**. From basic price candles to funding fees and liquidation volumes, you can find all sorts of market data you need for your trading. Without manually collecting the market data by yourself, stay up-to-date to the market with UnBlinked.


# How customizable are the data?

You can literally do anything with the data we provide. You can combine market data across multiple exchanges or sum up to make your own indicators.

For example, you can use BTCUSDT in Binance to check the price correlations on DOGEUSDT in Kraken. Or weight-average BTCUSDT’s RSI across 10 exchanges to see how over-sold or over-bought the market is.


# Security


# Is UnBlinked safe?


# Account


# I forgot my OTP device


# I forgot password


