Skip to content

Instantly share code, notes, and snippets.

View shinseitaro's full-sized avatar
🏠
Working from home

shinseitaro

🏠
Working from home
View GitHub Profile
@shinseitaro
shinseitaro / get-index.clj
Last active December 18, 2015 19:39
リスト(コレクション)のインデックスを返す
(.indexOf [:a :b :c :d :e] :d) ;; 3
(.indexOf [:a :b :c :d :e] :x) ;; -1
@shinseitaro
shinseitaro / slice.clj
Last active December 18, 2015 19:39
スライス
(take 3 [:a :b :c :d :e]) ;; (:a :b :c)
(drop 3 [:a :b :c :d :e]) ;; (:d :e)
(subs "clojure" 3) ;; "jure"
(subs "clojure" 0 3) ;; "clo"
@shinseitaro
shinseitaro / foo.clj
Last active December 18, 2015 20:48
clj-time のマイマイメモ。ハマったものを書いていきます。
;:dependencies [[org.clojure/clojure "1.5.1"]
; [clj-time "0.5.0"]]
(ns foo.core
(:require
[clj-time.core :as t]
[clj-time.format :as f]
[clj-time.local :as l]
[clj-time.coerce :as c]))
@shinseitaro
shinseitaro / tutorial.scrape1.clj
Created August 24, 2013 08:12
enlive の 自分メモ
;; enlive の tutorial がふるくなってるので自分でやるよ
(ns tutorial.scrape1
(:require [net.cgrand.enlive-html :as html])
(:import [java.net URL]))
(def base-url "https://news.ycombinator.com/")
;; html の中身をとってきます
(defn fetch-url [url]
(html/html-resource (URL. url)))
@shinseitaro
shinseitaro / project.clj
Created August 24, 2013 08:16
enlive tutorial の project.clj
(defproject enlive-tutorial "0.1.0"
:description "Enlive Tutorial"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojure-contrib "1.2.0"]
[enlive "1.1.1"]
[ring "0.2.5"]
[net.cgrand/moustache "1.0.0-SNAPSHOT"]]
:dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]]
:source-path "src")
import os
print(1)
@shinseitaro
shinseitaro / 2020_YTD_stock_change_by_sector.md
Last active May 25, 2020 09:07
2020 YTD stock change by sector

第一波で大きく下落したセクターを調べる

MORNINGSTAR_INDUSTRY_GROUP_CODES_after_Nov2019 =  {10110: 'Agricultural Inputs',
 10120: 'Building Materials',
 10130: 'Chemicals,Specialty Chemicals',
 10140: 'Lumber & Wood Production,Paper & Paper Products',
 10150: 'Aluminum,Copper,Other Industrial Metals & Mining,Gold,Silver,Other Precious Metals & Mining',
 10160: 'Coking Coal,Steel',
日付け 終値 始値 高値 安値 出来高 前日比%
2020年07月01日 22,089.50 22,331.50 22,358.50 22,024.50 - -0.89%
2020年06月30日 22,288.14 22,335.10 22,448.30 22,273.38 741.69M 1.33%
2020年06月29日 21,995.04 22,255.05 22,281.38 21,969.59 737.16M -2.30%
2020年06月26日 22,512.08 22,424.37 22,589.14 22,408.27 666.39M 1.13%
2020年06月25日 22,259.79 22,287.87 22,423.41 22,165.14 808.20M -1.22%
2020年06月24日 22,534.32 22,541.01 22,663.29 22,479.86 669.68M -0.07%
2020年06月23日 22,549.05 22,636.06 22,693.89 22,257.14 - 0.50%
2020年06月22日 22,437.27 22,353.69 22,575.74 22,311.94 545.97M -0.18%
2020年06月19日 22,478.79 22,515.75 22,523.66 22,352.16 969.60M 0.55%
@shinseitaro
shinseitaro / million_billion.py
Last active August 7, 2020 10:00
million や billion を数値に変えるたいときに使える pandas
# 下記のデータをヘッダーをKey、各行をValueにもつ辞書のリストに変換する。ただし、
# company nameは 大文字に変換
# revenueは、通貨記号は削除
# B: billion = 10億 で数値変換
# M: millon = 100万 で数値変換
# n/a: は numpy nan に変換
# stock priceは 小数点1位まで(四捨五入)
string_data = """company name,revenue,stock price
Orelie,$1.64B,50.406
日付け 始値 高値 安値 終値 出来高
2001年1月5日 13763.22 13947.06 13725.46 13867.61 0
2001年1月9日 13732.85 13732.85 13460.82 13610.51 0
2001年1月10日 13593.16 13593.16 13349.15 13432.65 0
2001年1月11日 13433.09 13436.61 13123.81 13201.07 0
2001年1月12日 13246.2 13451.95 13246.2 13347.74 0
2001年1月15日 13450.28 13573.55 13441.52 13506.23 0
2001年1月16日 13561.73 13598.2 13442.09 13584.45 0
2001年1月17日 13593.83 13688.9 13476.55 13667.63 0
2001年1月18日 13734.79 13931.91 13723.21 13873.92 0