Exemplo n.º 1
0
from sqlalchemy.orm import sessionmaker
from model import getaitraderengine
from model import CotizacionMC
from globalutils import gettimestampfromfechatexto
engine = getaitraderengine()
"""
Archivo para rellenar el campo de derivedsourcetimestamp en la tabla cotizaciones_mc
"""

Session = sessionmaker(bind=engine)
session = Session()

cotizaciones = session.query(CotizacionMC).all()
tostore = []
for c in cotizaciones:
    if c.derivedsourcetimestamp == None:
        c.derivedsourcetimestamp = gettimestampfromfechatexto(c.source, c)
        tostore.append(c)

for c in tostore:
    session.add(c)
session.commit()
Exemplo n.º 2
0
#Check if continuous descent/increase in closing price afects the following day closing price and the intensity in the
#shift if any

#read the data
sql = "select distinct ticker,str_to_date(fechatexto, '%d-%m-%Y') as fecha, valorcierre, split from \
( \
select *, str_to_date(fechatexto, '%d-%m-%Y') from cotizaciones_hist_mc \
) as st1 \
order by ticker asc, fecha asc"

import pandas
from model import getaitraderengine
engine = getaitraderengine("localhost", 3306, "aitrader")
df = pandas.read_sql(sql, engine)

tikers = {}

for i in range(len(df)):

    if (not df["ticker"][i] in tikers.keys()):
        prevvalue = None
        prevpercdiff = None
        percdiff = None
        lastiterationshiftsign = None
        numsessions = None
        tikers[df["ticker"][i]] = {}
        tikers[df["ticker"][i]]["fechas"] = {}
        tikers[df["ticker"][i]]["shiftaftersessionsbullish"] = {}
        tikers[df["ticker"][i]]["shiftaftersessionsbearish"] = {}
        tikers[df["ticker"][i]]["noshiftaftersessions"] = {}
        tikers[df["ticker"][i]]["totalsessions"] = 0
Exemplo n.º 3
0
        mdi.consensus = consensus
        mdi.forecast = forecast
        mdi.date = datetime.datetime.strptime(day, pattern)

        Session = sessionmaker(bind=engine)
        session = Session()
        session.add(mdi)
        session.commit()


    y = 2

    y = 2

import model
engine = model.getaitraderengine()
pattern = "%d/%m/%Y"
datefromstr = "27/05/2020"
datetostr = "04/10/2020"
datefrom = datetime.datetime.strptime(datefromstr, pattern)
dateto = datetime.datetime.strptime(datetostr, pattern)
currdate = datefrom
while(currdate.strftime(pattern)!=datetostr):
    if (currdate.weekday() in (0,1,2,3,4)):
        print(currdate.strftime(pattern))
        doextractday(currdate.strftime(pattern), pattern, engine)
    currdate = currdate + timedelta(days=1)
    time.sleep(5)


Exemplo n.º 4
0
                consolidatedata(engine)
                mthprint(
                    "DATACONSOLIDATION: Data consolidation run successfully")
            except BaseException as e:
                import traceback
                logexception2mail(traceback.format_exc(), e)
            time.sleep(15)
        else:
            mthprint("DATACONSOLIDATION: Fuera de horario")
            time.sleep(60)

    consolidatedata(engine)


from model import getaitraderengine
engineinfobolsa = getaitraderengine()
enginebsmarkets = getaitraderengine()
enginebolsademadrid = getaitraderengine()
enginedataconsolidation = getaitraderengine()

#loading tickers dictionaries for the different sources
gettickersdictionary(INFOBOLSA, engineinfobolsa)
gettickersdictionary(BOLSADEMADRID, enginebolsademadrid)
gettickersdictionary(BSMARKETS, enginebsmarkets)

th1 = threading.Thread(None, infobolsa, args=([engineinfobolsa]))
th2 = threading.Thread(None, bolsademadrid, args=([enginebolsademadrid]))
th3 = threading.Thread(None, bsmarkets, args=([enginebsmarkets]))
# th4 = threading.Thread(None, dataconsolidation, args=([enginedataconsolidation]))

print("pasa modulo:" + __name__)