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.

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})

How to get market data

Unlike the function mode, 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. It returns the data as an array of dictionaries. It requires four arguments; table_name, symbol, start_time, and end_time.

Check here 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 for more detail.


Python version : 3.11.1

pandas : 2.0.0

numpy : 1.24.2

Last updated

Copyright © 2023, UnBlinked Co., Ltd. | All rights reserved.