Ejemplo n.º 1
0
 def __init__(self):
     """
     docstring
     """
     self.db = Database()
     self.df = pd.DataFrame()
     self.bt = BackTest()
Ejemplo n.º 2
0
 def __init__(self):
     """
     docstring
     """
     self.bs = BuySell()
     self.db = Database()
     self.bt = BackTest()
Ejemplo n.º 3
0
 def __init__(self):
     self.db = Database()
     self.bs = BuySell(
         trading_strategy=TradingStrategies.LOGISTIC_REGRESSION,
         trading_provider=TradingProviders.ALPACA,
         fill_open_trades=OpenTradesSource.DB)
     self.bs.close_alpaca_postition = True
     self.spy_limit = 0
Ejemplo n.º 4
0
 def __init__(self):
     self.db = Database()
     self.symbols = self.db.get_symbols(TableName.DAY)
     self.sectors = self.db.get_sectors(TableName.DAY)
     self.sm = StockMess()
     self.app = self.get_home_page()
     self.sw = StockWhisperer()
     self.submit = None
Ejemplo n.º 5
0
Archivo: app.py Proyecto: 4crash/4crash
 def __init__(self):
     self.db = Database()
     self.df = self.db.load_data("p_day",
                                 symbols=['SPY'],
                                 time_from="-120d")
     self.df = sdf.retype(self.df)
     self.df = FinI.add_indicators(self.df)
     self.app = self.get_home_page(self.df)
     self.fig = None
Ejemplo n.º 6
0
Archivo: app.py Proyecto: 4crash/4crash
def update_figure(input_value):
    if len(input_value) > 1:
        input_value = "SPY"

    db = Database()
    df = db.load_data("p_day", symbols=input_value, time_from="-120d")
    df = sdf.retype(df)
    df = FinI.add_indicators(df)
    fig = go.Figure()
    fig.add_trace(
        go.Candlestick(x=df.index,
                       open=df['open'],
                       high=df['high'],
                       low=df['low'],
                       close=df['close']), )

    fig.add_trace(go.Scatter(x=df.index, y=df.sma9))

    fig.update_layout(transition_duration=500)

    return fig
Ejemplo n.º 7
0
    def __init__(self) -> None:
        db = Database()
        stocks: pd.DataFrame
        stocks_fs = db.load_data(table_name=TableName.DAY_FS, limit=1)
        db_mode = "append"

        if stocks_fs is not None and len(stocks_fs) > 0:
            stocks = db.load_data(table_name=TableName.DAY,
                                  time_from=stocks_fs.index[0])

        else:
            stocks = db.load_data(table_name=TableName.DAY, time_from="-500d")
            db_mode = "replace"

        symbols = db.get_symbols()
        for sym in symbols:
            if len(stocks) > 0:
                stocks_sym = FinI.add_indicators(stocks[stocks.sym == sym])
                # stocks.columns.drop(["symbol","sector","industry"])
                # for idx, sym_s in stocks_sym.iterrows():

                #     sql_string = "".join(["select * from financials where symbol = '",
                #                           str(sym_s.sym),
                #                           "' and date::date <= date '",
                #                           str(idx.replace(hour=23, minute=59)),
                #                           "' order by date desc limit 1"])
                #     print(sql_string)
                #     financials = db.sql_select_query_data(sql_string)
                #     new_row = pd.concat([stocks_sym, financials], axis=1)
                #     new_row.to_sql(name="p_day_fs",
                #                    if_exists="append", con=db.engine)
                if stocks_sym is not None:
                    stocks_sym.to_sql(name="p_day_fs",
                                      if_exists=db_mode,
                                      con=db.engine)
                print(stocks_sym)
Ejemplo n.º 8
0
utc = pytz.UTC
# from buy_sell import BuySell
# from sklearn import linear_model, preprocessing
from pytz import timezone

localtz = timezone('Europe/Prague')
# from plot_i import PlotI
# from fin_i import FinI
# from utils import Utils
# from check_indicators import CheckIndicators as chi
from alpaca_examples.market_db import Database, TableName
from buy_sell import BuySell
import logging
# import pytest

db = Database()
bs = BuySell()
data_intc = db.load_data(table_name=TableName.DAY,
                         time_from="-10d",
                         symbols=["INTC"])
data_amd = db.load_data(table_name=TableName.DAY,
                        time_from="-10d",
                        symbols=["AMD"])


def test_buy_sell_stock_t():
    bs.buy_sell_open = pd.DataFrame()
    bs.money = 10000

    bs.buy_stock_t(data_intc.iloc[0],
                   data_intc.iloc[0].close,
Ejemplo n.º 9
0
 def __init__(self):
     """
     docstring
     """
     self.db = Database()