def test_add_order_total(recorder, mocker): yf_download = ark_model.yf.download def mock_yf_download(*args, **kwargs): kwargs["threads"] = False return yf_download(*args, **kwargs) mocker.patch("yfinance.download", side_effect=mock_yf_download) df_orders = ark_model.get_ark_orders() result_df = ark_model.add_order_total(df_orders=df_orders.head(2)) recorder.capture(result_df)
def ark_orders_view(num: int, export: str): """Prints a table of the last N ARK Orders Parameters ---------- num: int Number of stocks to display export : str Export dataframe data to csv,json,xlsx file """ df_orders = ark_model.get_ark_orders() if df_orders.empty: print("The ARK orders aren't available at the moment.\n") return pd.set_option("mode.chained_assignment", None) df_orders = ark_model.add_order_total(df_orders.head(num)) if gtff.USE_COLOR: df_orders["direction"] = df_orders["direction"].apply(direction_color_red_green) # df_orders["link"] = "https://finviz.com/quote.ashx?t=" + df_orders["ticker"] print("Orders by ARK Investment Management LLC") print( tabulate( df_orders, headers=df_orders.columns, floatfmt=".2f", showindex=False, tablefmt="fancy_grid", ), ) print("") export_data( export, os.path.dirname(os.path.abspath(__file__)), "arkord", df_orders, )
def ark_orders_view( num: int, sort_col: str = "", ascending: bool = False, buys_only: bool = False, sells_only: bool = False, fund: str = "", export: str = "", ) -> None: """Prints a table of the last N ARK Orders Parameters ---------- num: int Number of stocks to display sort_col : str Column to sort on ascending : bool Flag to sort in ascending order buys_only : bool Flag to filter on buys only sells_only : bool Flag to sort on sells only fund : str Optional filter by fund export : str Export dataframe data to csv,json,xlsx file """ df_orders = ark_model.get_ark_orders() if df_orders.empty: console.print("The ARK orders aren't available at the moment.\n") return if fund: df_orders = df_orders[df_orders.fund == fund] if buys_only: df_orders = df_orders[df_orders.direction == "Buy"] if sells_only: df_orders = df_orders[df_orders.direction == "Sell"] df_orders = ark_model.add_order_total(df_orders.head(num)) if sort_col: df_orders = df_orders.sort_values(by=sort_col, ascending=ascending) if gtff.USE_COLOR: df_orders["direction"] = df_orders["direction"].apply( lambda_direction_color_red_green) print_rich_table( df_orders, headers=[x.title() for x in df_orders.columns], show_index=False, title="Orders by ARK Investment Management LLC", ) console.print("") export_data( export, os.path.dirname(os.path.abspath(__file__)), "arkord", df_orders, )
def test_get_ark_orders(recorder): result_df = ark_model.get_ark_orders() recorder.capture(result_df)
def test_add_order_total(self): orders = get_ark_orders() ret = add_order_total(orders) print(ret)
def test_get_ark_orders(self): ret = get_ark_orders() print(ret)
def ark_orders_view( num: int, sort_col: str = "", ascending: bool = False, buys_only: bool = False, sells_only: bool = False, fund: str = "", export: str = "", ): """Prints a table of the last N ARK Orders Parameters ---------- num: int Number of stocks to display sort_col : str Column to sort on ascending : bool Flag to sort in ascending order buys_only : bool Flag to filter on buys only sells_only : bool Flag to sort on sells only fund : str Optional filter by fund export : str Export dataframe data to csv,json,xlsx file """ df_orders = ark_model.get_ark_orders() if df_orders.empty: print("The ARK orders aren't available at the moment.\n") return if fund: df_orders = df_orders[df_orders.fund == fund] if buys_only: df_orders = df_orders[df_orders.direction == "Buy"] if sells_only: df_orders = df_orders[df_orders.direction == "Sell"] df_orders = ark_model.add_order_total(df_orders.head(num)) if sort_col: df_orders = df_orders.sort_values(by=sort_col, ascending=ascending) if gtff.USE_COLOR: df_orders["direction"] = df_orders["direction"].apply( direction_color_red_green) # df_orders["link"] = "https://finviz.com/quote.ashx?t=" + df_orders["ticker"] print("Orders by ARK Investment Management LLC") print( tabulate( df_orders, headers=df_orders.columns, floatfmt=".2f", showindex=False, tablefmt="fancy_grid", ), ) print("") export_data( export, os.path.dirname(os.path.abspath(__file__)), "arkord", df_orders, )