Skip to content

Commit

Permalink
type hints update
Browse files Browse the repository at this point in the history
  • Loading branch information
alpha-xone committed Dec 29, 2020
1 parent a56afa7 commit 5eba621
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 8 additions & 4 deletions xone/chart.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import pandas as pd

from typing import Union
from xone import utils
from matplotlib import pyplot as plt


def plot_ts(
data: (pd.Series, pd.DataFrame), fld='close',
tz=None, vline=None, **kwargs
data: Union[pd.Series, pd.DataFrame],
fld='close',
tz=None,
vline=None,
**kwargs,
):
"""
Time series data plots
Expand Down Expand Up @@ -229,7 +233,7 @@ def add_lines(
return axes


def xticks(data: (pd.Series, pd.DataFrame), max_cnt=8) -> pd.DataFrame:
def xticks(data: Union[pd.Series, pd.DataFrame], max_cnt=8) -> pd.DataFrame:
"""
Get x-ticks for intraday data
Expand Down Expand Up @@ -273,7 +277,7 @@ def xticks(data: (pd.Series, pd.DataFrame), max_cnt=8) -> pd.DataFrame:
)


def intraday(data: (pd.Series, pd.DataFrame), max_cnt=8, **kwargs):
def intraday(data: Union[pd.Series, pd.DataFrame], max_cnt=8, **kwargs):
"""
Plot intraday data
Expand Down
12 changes: 10 additions & 2 deletions xone/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
import inspect
import sys

from typing import Union
from xone import __version__

__all__ = ['__version__']
__all__ = [
'__version__',
'tolist',
'fmt_dt',
'trade_day',
'cur_time',
'align_data',
]

DEFAULT_TZ = pytz.FixedOffset(-time.timezone / 60)

Expand Down Expand Up @@ -414,7 +422,7 @@ def func_kwarg(func, **kwargs) -> dict:
return {k: v for k, v in kwargs.items() if k in kind}


def perf(data: (pd.DataFrame, pd.Series)) -> (pd.DataFrame, pd.Series):
def perf(data: Union[pd.DataFrame, pd.Series]) -> Union[pd.DataFrame, pd.Series]:
"""
Price performance based at 100
Expand Down

0 comments on commit 5eba621

Please sign in to comment.