This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| import zlib | |
| s3 = boto3.session.Session().client('s3') | |
| resp = s3.get_object( Bucket='BUCKET', Key='PATH' ) | |
| b = resp['Body'] | |
| i = 0 | |
| cnt = 0 | |
| c = 0 | |
| decb = b'' | |
| dec = zlib.decompressobj(zlib.MAX_WBITS|32) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############ REQUIREMENTS TO INSTALL #################### | |
| # THIS SCRIPT use category table from AWS sample data (https://docs.aws.amazon.com/redshift/latest/gsg/rs-gsg-create-sample-db.html) | |
| # we use this sample data s3://awssampledbuswest2/tickit/category_pipe.txt | |
| ###### Linux users | |
| #`sudo apt-get install libpq-dev` | |
| ###### Mac users | |
| #`brew install libpq` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from io import BytesIO | |
| import gzip | |
| import shutil | |
| def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'): | |
| """Compress and upload the contents from fp to S3. | |
| If compressed_fp is None, the compression is performed in memory. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # For Windows users# Note: <> denotes changes to be made | |
| #Create a conda environment | |
| conda create --name <environment-name> python=<version:2.7/3.5> | |
| #To create a requirements.txt file: | |
| conda list #Gives you list of packages used for the environment | |
| conda list -e > requirements.txt #Save all the info about packages to your folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from base import * | |
| import datetime | |
| class FXBot(BaseBot): | |
| def __init__(self): | |
| super(FXBot, self).__init__() | |
| self.contracts = [0]*8 # EURJPY/CHFJPY/USDCHF/EURCHF/EURCAD/EURUSD/USDJPY/USDCAD | |
| self.cash = [0]*8 # JPY/EUR/USD/CHF/CAD | |
| self.limits = [102000000, 900000, 1000000, 980000, 1300000] # JPY/EUR/USD/CHF/CAD | |
| self.bids = [] # EURJPY/CHFJPY/USDCHF/EURCHF/EURCAD/EURUSD/USDJPY/USDCAD | |
| self.asks = [] # EURJPY/CHFJPY/USDCHF/EURCHF/EURCAD/EURUSD/USDJPY/USDCAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #required libraries | |
| library(quantmod) | |
| library(zoo) | |
| library(chron) | |
| #following section loads "Systematic Investor Toolbox" | |
| setInternet2(TRUE) | |
| con <- gzcon(url('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', 'rb')) | |
| source(con) | |
| close(con) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(quantmod) | |
| library(zoo) | |
| library(chron) | |
| #following section loads "Systematic Investor Toolbox" | |
| setInternet2(TRUE) | |
| con <- gzcon(url('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', 'rb')) | |
| source(con) | |
| close(con) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Copyright (C) 2015 Baxter Eaves | |
| License: Do what the fuck you want to public license (WTFPL) V2 | |
| Bayesian hierarchical clustering. | |
| Heller, K. A., & Ghahramani, Z. (2005). Bayesian Hierarchical Clustering. | |
| Neuroscience, 6(section 2), 297–304. doi:10.1145/1102351.1102389 | |
| """ | |
| import itertools as it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! Python 3.4 | |
| """ | |
| Open a file dialog window in tkinter using the filedialog method. | |
| Tkinter has a prebuilt dialog window to access files. | |
| This example is designed to show how you might use a file dialog askopenfilename | |
| and use it in a program. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # see also https://github.com/wrobstory/pgshift | |
| import gzip | |
| from io import StringIO, BytesIO | |
| from functools import wraps | |
| import boto | |
| from sqlalchemy import MetaData | |
| from pandas import DataFrame | |
| from pandas.io.sql import SQLTable, pandasSQL_builder |
NewerOlder