# your_package_name/client.py
import requests
import pandas as pd

pd.set_option('display.max_columns', None)

BASE_URL = "http://8.155.52.153:8000"


class DataClient:
    def __init__(self, base_url: str = BASE_URL):
        self.base_url = base_url

    def fetch_option_instruments(self, trade_date: str):
        url = f"{self.base_url}/option/instruments"
        params = {"trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return resp.json()

    def fetch_future_instruments(self, trade_date: str):
        url = f"{self.base_url}/future/instruments"
        params = {"trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return resp.json()

    def fetch_option_data(self, instrument_id: str, trade_date: str):
        url = f"{self.base_url}/option/data"
        params = {"instrument_id": instrument_id, "trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return pd.DataFrame(resp.json())

    def fetch_future_data(self, instrument_id: str, trade_date: str):
        url = f"{self.base_url}/future/data"
        params = {"instrument_id": instrument_id, "trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return pd.DataFrame(resp.json())

    def fetch_option_basic(self, trade_date: str):
        url = f"{self.base_url}/option/basic"
        params = {"trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return pd.DataFrame(resp.json())

    def fetch_future_basic(self, trade_date: str):
        url = f"{self.base_url}/future/basic"
        params = {"trade_date": trade_date}
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        return pd.DataFrame(resp.json())