Skip to content

Instantly share code, notes, and snippets.

View usametov's full-sized avatar

Ulan Sametov usametov

  • Asta Nova Enterprise Solutions
View GitHub Profile
@usametov
usametov / traverse.ts
Last active April 3, 2018 05:27
traverse object tree in javascript
//this will hopefully run in debug mode
//https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html#ws_node_debugging_debugger_console
function traverse(o ) {
for (i in o) {
if (!!o[i] && typeof(o[i])=="object") {
// use typescript instanceof operator here
// we should be able to travel to desired type
console.log(i, o[i])
traverse(o[i] );
}
@usametov
usametov / mls.py
Last active July 19, 2018 16:36 — forked from DenisCarriere/mls.py
MLS Scraper
import geocoder
import requests
import unicodecsv as csv
import time
container = {}
g = geocoder.google("Ontario, Canada")
url = "https://api-pr.realtor.ca/Listing.svc/PropertySearch_Post"
PropertySearchType = {
5 + 5
You can tell me what this is, right? It’s 10, that’s right.
What about this?
5 + '5'
This is '55'. Makes sense, right?
'5' + 5
This is also '55'. This makes more sense than the last one, though, even though it still makes no sense.
@usametov
usametov / sentiment.fs
Created January 26, 2019 02:52 — forked from sudipto80/sentiment.fs
Sentiment Analysis
open System.Text.RegularExpressions
type SentiWordNetEntry = {POS:string; ID:string; PositiveScore:string; NegativeScore:string; Words:string}
let sentiWordList = System.IO.File.ReadAllLines(@"SentiWordNet_3.0.0_20130122.txt")
|> Array.filter (fun line -> not (line.StartsWith("#")))
|> Array.map (fun line -> line.Split '\t')
|> Array.map (fun lineTokens -> {POS = lineTokens.[0];
ID = lineTokens.[1];
PositiveScore = lineTokens.[2].Trim();
@usametov
usametov / core-async.examples.cljs
Created January 27, 2019 02:17
TODO: port this to shadow-cljs
;;;; ClojureScript examples ;;;;
(require 'cljs.repl.browser)
(cemerick.piggieback/cljs-repl
:repl-env (cljs.repl.browser/repl-env :port 9000))
(ns cljs-examples
(:require [cljs.core.async :refer [chan put! take! timeout] :as async]
[clojure.walk :refer [prewalk]]
# https://stackoverflow.com/questions/1143671/how-to-sort-objects-by-multiple-keys-in-python/29849371
people = [
{ 'name': 'John', "age": 64 },
{ 'name': 'Janet', "age": 34 },
{ 'name': 'Ed', "age": 24 },
{ 'name': 'Sara', "age": 64 },
{ 'name': 'John', "age": 32 },
{ 'name': 'Jane', "age": 34 },
{ 'name': 'John', "age": 99 },
# pip install python-twitter
# pip install nltk
# python -m nltk.downloader vader_lexicon
# pip install matplotlib
# pip install seaborn
import twitter
import os
import datetime
import nltk
to evaluate the whole buffer use <localleader>eb
to evaluate the inner form use <localleader>ee
to open the log buffer horizontally (<localleader>ls),
vertically (<localleader>lv) or
in a tab (<localleader>lt)
All visible log windows (including the HUD) can be closed with <localleader>lq

Looking up documentation

The REPL can also be used for looking up API documentation, using the clojure.repl lib. Evaluate the following expression at the REPL:

user=> (require '[clojure.repl :refer :all])

This expression makes all the names defined in the clojure.repl namespace available in the REPL. doc

"""
Bars indexed by total volume, with each set # of shares traded creating a distinct bar.
We can transform minute bars into an approximation for volume bars, but ideally we would use tick bars
to maintain information for all parameters across bars.
Let's set a target bar volume equal to the maximum minutely volume in our dataset
(otherwise we'd have to split minute bars, which we can't).
Then, we construct our bars in such a way as to minimize the distance from this target:
Combine minute bars while maintaining the time of the first and final minutes,
adding volume of bars together, and keeping track of the high and low over the interval.