Skip to content

Instantly share code, notes, and snippets.

Avatar

Toni anthonytxie

View GitHub Profile
View gist:1b60abbf10ff4e096367546192d81d7d
https://gist.github.com/anonymous/ba399aea35e060fac8e26be30530e3bd
View gist:0b8dd5b20885b7f4d09657810ea89199
https://gist.github.com/anthonytxie/325a9287763107eb45803eac0e873646
@anthonytxie
anthonytxie / hodl20.py
Created Mar 24, 2018
Hodl 20 Rebalancing Algorithm
View hodl20.py
def calc_allocations(self, date, quantity, cap):
"""Figure out ideal allocations for a given date"""
# {
# coin_name: (percent_allocation, data)
# }
top_market = self.get_top_market(date, quantity)
total_cap = sum([coin.market_cap for coin in top_market])
allocations = [{
View reddit-hodl.js
const fetchComments = async (startDate, limit) => {
console.log(`beginning comment fetch from ${startDate} to ${endDate}`);
while (startDate < endDate) {
// gets the first limit comments after startDate
const response = await axios.get(
`https://apiv2.pushshift.io/reddit/search/comment/?q=hodl&size=${limit}&after=${startDate
.toString()
.substr(0, 10)}`
);
const comments = response.data.data;
View Comment.js
const commentSchema = new Schema({
commentDate: {
type: Date,
index: true
},
body: {
type: String
},
subreddit: {
View hodlCount.js
Comment.find({})
.sort({ commentDate: 1 })
.then(comments => {
let commentsObject = {};
comments.forEach(comment => {
let commentDate = moment(comment.commentDate).startOf("day");
if (!commentsObject[commentDate]) {
commentsObject[commentDate] = 1;
} else {