Ejemplo n.º 1
0
def btc_sort():
    btc = read_to_df('xbtusd', '1d', update=True)
    btc = add_opens_days(btc)
    btc = apply_WO(btc)
    btc = apply_MO(btc)
    btc = find_body_ratio(btc)
    btc = find_volume_ratio(btc)
    btc = calc_ma(btc)
    btc = find_gradient(btc)

    btc_1m = read_to_df('xbtusd', '5m', update=True)
    btc_1m = add_opens_days(btc_1m)
    btc_1m = apply_WO(btc_1m)
    btc_1m = apply_MO(btc_1m)
    vwaps = calc_vwap(btc_1m)

    btc = btc.assign(W_vwap=vwaps[['W_vwap']])
    btc = btc.assign(M_vwap=vwaps[['M_vwap']])
    btc = find_returns(btc)

    table_btc, btc, signals_test, columns = create_table(btc)
    table_btc.insert(0, columns)
    btc = find_percentiles(btc)
    btc = find_body_ratio(btc)
    btc = find_volume_ratio(btc)
    btc = calc_ma(btc)
    btc = find_gradient(btc)

    fig_btc = dash_table.DataTable
    fig_btc = ff.create_table(table_btc)

    return btc, fig_btc
Ejemplo n.º 2
0
def main():
    conn, cur = functions.connect()
    status = True
    functions.print_menu()
    while status:
        choice = int(input('Choice: '))
        if choice == 1:
            functions.create_table(conn, cur, 'teachers')
        elif choice == 2:
            functions.insert_data(conn, cur, 'teachers')
        elif choice == 3:
            keys = input('SELECT BY: ')
            records = functions.select_from_db(conn, cur, 'teachers', keys)
            functions.print_selected_data(records, keys)
        elif choice == 4:
            records = functions.select_from_db(conn, cur, 'teachers')
            functions.print_selected_data(records)
        elif choice == 5:
            functions.disconnect(conn, cur)
            break
        functions.print_menu()
Ejemplo n.º 3
0
            print(database_name)
            break
        else:
            database_name += '.db'
            print(database_name)
            if database_name in os.listdir():
                print(
                    'This database already exists. Please select another name. \n'
                )
            else:
                break
    with sql.connect(database_name) as conn:  # connection to DB.
        c = conn.cursor()
        # Create DB table for Ad Groups
        functions.create_table(c, 'Ad Groups', {
            'Campaign Name': 'TEXT',
            'Ad Group Name': 'TEXT'
        })
        print()

        # Open reader to extract a list of headers & create table based on it
        with open('Ad_Report2.csv', 'r') as csv_file:
            csv_reader = csv.reader(csv_file)
            # Removing all "Responsive Search Ad" from headers
            # headers = [x for x in next(csv_reader) if x.startswith('Responsive Search Ad') is False]
            headers = [x for x in next(csv_reader)]
        # Creating a table with each header as a text column
        dict_columns = {
            k: v
            for k, v in zip(headers, ('' for x in range(len(headers))))
        }
        functions.create_table(c, 'Ads', dict_columns)
Ejemplo n.º 4
0
from functions import create_table, insert_table, view_table
import argparse
import sys

#Argparse Config
parser = argparse.ArgumentParser(description='TY Investments \
    Database Script')

parser.add_argument('-i',
                    '--insert',
                    help='Input data \
     into database',
                    action='store_true')
parser.add_argument('-v',
                    '--view',
                    help='Show all data \
    inside money table',
                    action='store_true')
args = parser.parse_args()

if __name__ == "__main__":
    print("running app.py")
    if args.insert:
        create_table()
        insert_table()
    elif args.view:
        view_table()
    else:
        pass
Ejemplo n.º 5
0
def main():
    f.create_db()
    f.create_table()
    f.insert_data()
Ejemplo n.º 6
0
    'client_secrets.json', scopes=["https://www.googleapis.com/auth/cloud-platform"],
        )

client = bigquery.Client(credentials=credentials, project=credentials.project_id,)

# The initial tables will live in the bronze Dataset
dataset = 'bronze_warehouse'

# Define table name and schema
table_id_warehouse = 'warehouse_overview'
warehouse_schema = [
bigquery.SchemaField("warehouse_name", bigquery.enums.SqlTypeNames.STRING),
bigquery.SchemaField("warehouse_id", bigquery.enums.SqlTypeNames.STRING),
bigquery.SchemaField("country", bigquery.enums.SqlTypeNames.STRING),
bigquery.SchemaField("update_time", bigquery.enums.SqlTypeNames.TIMESTAMP),
]

# Define table name and schema
table_id_product = 'warehouse_product'
product_schema = [
bigquery.SchemaField("sku", bigquery.enums.SqlTypeNames.STRING),
bigquery.SchemaField("inventory_quantity", bigquery.enums.SqlTypeNames.INTEGER),
bigquery.SchemaField("update_time", bigquery.enums.SqlTypeNames.TIMESTAMP),
]

# Function to create Dataset (if dataset exists this wont do anything)
f.create_dataset(client,dataset)
# Function to create Table (if Table exists this wont do anything)
f.create_table(client,dataset,table_id_warehouse,warehouse_schema)
f.create_table(client,dataset,table_id_product,product_schema)
Ejemplo n.º 7
0
def main(database, table):
    create_database(database)
    cur = connect_to_database(database)
    create_table(cur, table)