Exemplo n.º 1
0
def main(argv):
    db = dbConnector("test")
    
    try:
        table = db.getTable(argv[0])   
    except :
        print 'WRONG TABLE NAME.'
        
    for element in table:
        doc=table[element]
        print '------------------------------------------------------------------------------------------------'
        print doc['texto']
Exemplo n.º 2
0
def dashboard():
    if request.method == 'GET':
        global symbol
        connector = db.dbConnector()
        connection = connector.createConnection()

        scrapedStocks = connector.getMentions(connection)
        symbols = []
        for x in scrapedStocks:
            symbols.append(x['symbol'])

        this = datetime.datetime.today() - timedelta(days=5)
        time = str(this.year) + "-" + str(this.month) + "-" + str(
            this.day) + " " + str(datetime.time(9, 35))
        day = str(this.year) + "-" + str(this.month) + "-" + str(this.day)
        print(day)
        trades = connector.getTradeRecents(connection, time)
        trades = trades[0:25]
        stonks = connector.getBarsByTime(connection, time)
        stonks = stonks[0:25]
        results = connector.getResultsByDate(connection, day)
        for x in results:
            diff = x['endCash'] - x['startCash']
            percentChange = diff / floaty(x['startCash']) + 1
            x['percentChange'] = percentChange
        strategy = ad.Strategy()
        hammerChanges = strategy.calculateProfits(connector, connection,
                                                  'hammer')
        morningStarChanges = strategy.calculateProfits(connector, connection,
                                                       'morningStar')
        senkouBChanges = strategy.calculateProfits(connector, connection,
                                                   'senkouB_')
    if request.method == 'POST':
        symbol = request.form.get('symbol')

        df = api.polygon.historic_agg_v2(symbol,
                                         1,
                                         'minute',
                                         _from='2020-07-01',
                                         to='2020-07-01').df
        df['timestamp'] = df.index
        df = df.reset_index(drop=True)
        return render_template('graph.html', df=df.to_json(), symbol=symbol)

    return render_template('dashboard_copy.html',
                           symbols=symbols,
                           trades=trades,
                           stonks=stonks,
                           results=results,
                           hammerChanges=hammerChanges,
                           morningStarChanges=morningStarChanges,
                           senkouBChanges=senkouBChanges)
import alpaca_trade_api as tradeapi
import csv
from numpy import float as floaty

ALPACA_KEY_ID = 'PK3VZLXGJAE5FPVLWCOU'
ALPACA_SECRET_KEY = r'NtLnmeY6PtUpPXD2kGblhezLg/6f4lHqEcIqrR/3'

api = tradeapi.REST(key_id=ALPACA_KEY_ID,
                    secret_key=ALPACA_SECRET_KEY,
                    base_url='https://paper-api.alpaca.markets')

if __name__ == "__main__":
    fromTime = "06-01-2017"
    toTime = "06-30-2017"

    connector = db.dbConnector()
    connection = connector.createConnection()
    symbols = connector.getAllDistinctMentions(connection)
    symbols = symbols[0:700]
    print(len(symbols))
    stocks = []
    takeProfit = 1.03
    takeLoss = .985
    filename = "/Users/ryangould/Desktop/hammerTradeTrainData.csv"
    fields = [
        "takeLoss", "takeProfit", "SMA", "tailLength", "volume", "hourOfBuy",
        "minuteOfBuy", "profitable"
    ]
    for x in symbols:
        stocks.append(x['symbol'])
    positions = bt.algoStart(api, stocks, fromTime, toTime, 25000)
Exemplo n.º 4
0
import dbConnector
from custom_validators import height_validator, weight_validator
import requests
import json

from flask import Flask, render_template, flash, request
from wtforms import Form, TextField, validators, SubmitField, SelectField, IntegerField

db = dbConnector.dbConnector()
db.build_table()

app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = 'SeCrEt'


class Questionnaire(Form):

    nombreunidadproductiva = TextField('Nombre_unidad_productiva:',
                                       [validators.InputRequired()])
    callenumero = TextField('Calle_y_numero:', [validators.InputRequired()])
    localidad = TextField('Localidad:', [validators.InputRequired()])
    rubro = TextField('Rubro:', [validators.InputRequired()])
    aniorecuperacion = IntegerField('Año_de_recuperacion:',
                                    [validators.InputRequired()])

    feelings_options = requests.get('http://localhost:8081/categories').json()
    feelings_options2 = requests.get(
        'http://localhost:8081/categories/1/subcategories').json()
    feelings_options3 = requests.get(
        'http://localhost:8081/business-area').json()
Exemplo n.º 5
0
if __name__ == '__main__':
	
	__CRITERIASFILE__ = '../../static/DATA/criterias.xml'
	__OUTPUTFILE__ = '../../static/DATA/data.tab'

	ta = TextAnalyser(__CRITERIASFILE__)
	serFile = TextFileWriter()
	

	#StringIO is an objet that kinda works like a file
	ofile = StringIO()

	print 'Creation of the file:'
	ofile.write(ta.createTabHeader())
	
	db = dbConnector("test")	
	print '\t- Manchetes...'
	table = db.getTable("manchete")
	if table != None:
		for element in table:
			try:
				ofile.write(ta.passTheCriterias(table[element]['titulo'],"manchete"))
			except:
				pass
	else:
		print ' --> No record in the table'
	
	print '\t- Noticia...'
	table = db.getTable("noticia")
	if table != None:
		for element in table:
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
from dbConnector import dbConnector
from models.Models import School,Student,Admin

if __name__ == '__main__':
    students = None
    schools = None
    
    db = dbConnector("jogodojornal")

    print "--> Students..."

    aStudent = Student(_id="Damien",grade="9th grade")
    aStudent = Student(_id="Chuck",grade="9th grade")
    aStudent = Student(_id="Pedro",grade="9th grade")
    aStudent = Student(_id="Didier",grade="9th grade")
    print aStudent
    
    print '--> Schools...'
    if not db.has("schools"):
        db.createTable('schools')
    schools = db.getTable('schools')
    aSchool = School(name="Escola Santa Clara" ,password='******',studentPassword='******',email='*****@*****.**')
    aSchool.addStudent(aStudent)
    aSchool.store(schools)
    
    print '--> Admin...'
    
    anAdmin = Admin(name='damien' , email = '*****@*****.**', password = '******')
    if not db.has('admins-jogodojornal'): 
        db.createTable('admins-jogodojornal')
Exemplo n.º 7
0
 def __init__(self):
     self.db_connector = dbConnector()
     self.notifier = Notifier()