Skip to content

Instantly share code, notes, and snippets.

@bharddwaj
bharddwaj / predictMSFT.py
Created July 8, 2020 23:10
i'm pretty sure i messed this up but I want to keep it anyway
import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
msft = pd.read_csv("MSFT.csv")
print(msft.shape)
msft_returns = []
for i in range(1,1259):
@bharddwaj
bharddwaj / waterJugPuzzle.cpp
Last active March 14, 2020 02:27
3 jug water puzzle that assumes all the water starts from jugC in the beginning and no water can be added or taken out of the system. Follow 6 specific steps and use Breadth First Search so that everyone gets the fastest solution (as well as the same solution).)
/*******************************************************************************
* Name : waterJugPuzzle.cpp
* Author : Bharddwaj Vemulapalli
* Date : March 13, 2020
* Description : Solves the water jug puzzle.
* Pledge : I pledge my honor that I have abided by the Stevens Honor System.
******************************************************************************/
#include <iostream>
#include <sstream>
#include <vector>
@bharddwaj
bharddwaj / GameAndWatch.cpp
Last active February 8, 2020 16:34
Trying to calculate the true probability of getting a 9 with "Judge" on Game and Watch from Super Smash Bros Ultimate. Each number is equally likely to appear (9 possibilities so 1/9 for a 9), but no number can appear twice in a row. I ran some simulations and it seems to me like that there is a 11.1% chance of getting a 9.
//
// main.cpp
// GameAndWatch
//
// Created by Bharddwaj Vemulapalli on 2/7/20.
// Copyright © 2020 Bharddwaj Vemulapalli. All rights reserved.
//
#include <iostream>
#include <random>
@bharddwaj
bharddwaj / randomWalks.py
Created January 8, 2020 12:12
Page 17 problem in Introduction to Probability by Grinstead and Snell
import random
def SingleDimensionWalk(x,count):
'''
Write a program to simulate a random walk in one dimension starting at 0.
Have your program print out the lengths of the times between returns to the starting point (returns to 0).
'''
if random.randint(0,1):
x+=1
else:
package homework;
import java.util.Random;
import java.util.Stack;
/**
* @param <E>
*/
//Bharddwaj Vemulapalli
//CS284
//I pledge my honor that I have abided by the Stevens Honor System.
public class treap<E extends Comparable<E>>{
@bharddwaj
bharddwaj / LeastSquares.py
Created November 10, 2019 00:02
Linear Regression from scratch using Linear Algebra concept
def LinearRegression(x,y,round_digits):
'''
x: feature vector (Preferably Numpy Array)
y: dependent vector (Preferably Numpy Array)
round_digits: number of digits you want to round the final equation to
This function returns the Ordinary Least Squares Regression model.
'''
c = np.ones((len(x[0]),))
A = []
A.append(c)
@bharddwaj
bharddwaj / bid_ask_spread_basis.py
Created July 6, 2019 02:26
top 15 most frequent bid ask spread percentages. the bid ask spread percentage is ((bid - ask)/ask)*10000
import pandas as pd
import numpy as np
import csv
import seaborn as sns
import matplotlib.pyplot as plt
import math
from collections import OrderedDict
data = pd.read_csv("CL_June_2019.csv")
print(type(data))
@bharddwaj
bharddwaj / bid_ask_size_spread.py
Created June 30, 2019 02:40
finds the bid-ask spread for each row and records the frequency of each different size spread and graphs them at the end. Used this for liquidity research on 64 million rows of data!
import pandas as pd
import numpy as np
import csv
import seaborn as sns
import matplotlib.pyplot as plt
import math
data = pd.read_csv("CL_June_2019.csv")
print(type(data))
#new_data = data[59528000:59800000]
@bharddwaj
bharddwaj / volume.py
Created June 30, 2019 01:14
Calculates volume per trading day in the csv file and graphs it. Also writes down the exact volumes at each day to a txt file
import pandas as pd
import numpy as np
import csv
import seaborn as sns
import matplotlib.pyplot as plt
import math
data = pd.read_csv("CL_June_2019.csv")
#new_data = data[59528000:59800000]
@bharddwaj
bharddwaj / bid_ask_spread.py
Last active June 30, 2019 01:12
finds the bid-ask spread for each row and records the frequency of each different spread and graphs them at the end. Used this for liquidity research on 64 million rows of data!
import pandas as pd
import numpy as np
import csv
import seaborn as sns
import matplotlib.pyplot as plt
import math
data = pd.read_csv("CL_June_2019.csv")
print(type(data))
#new_data = data[59528000:59800000]