This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from openopt import QP | |
H = [[4, 1], | |
[1, 2]] | |
f = [1, 1] | |
Aeq = [1, 1] | |
beq = 1 |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import FuncDesigner as fd | |
from openopt import QP | |
x1, x2 = fd.oovars(2) | |
f = 2 * x1 ** 2 + x2 ** 2 + x1 * x2 + x1 + x2 | |
startpoint = {x1: 0, x2: 0} | |
constraints = [] |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import FuncDesigner as fd | |
from openopt import QP | |
import numpy as np | |
x = fd.oovars(2) | |
H = np.array([[4, 1], | |
[1, 2]]) |
This file contains 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
#!/usr/bin/python | |
# coding: utf-8 | |
# 日経平均資料室(http://indexes.nikkei.co.jp/nkave/archives/data)の日次データの差分をクロールして追加するプログラム | |
import urllib2 | |
import lxml.html | |
import csv | |
import re | |
import time | |
from datetime import datetime as dt |
This file contains 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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import numpy as np | |
# it's for unweighted and undirected graph. | |
# Adjency matrix of the graph | |
adjency_mat = np.array([[0, 1, 1, 1, 0, 0], | |
[1, 0, 1, 0, 0, 1], | |
[1, 1, 0, 1, 1, 0], | |
[1, 0, 1, 0, 1, 0], |
This file contains 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 pandas as pd | |
import jsm | |
import datetime | |
def get_historical_price(stockcode, start_date=None, end_date=None): | |
q = jsm.Quotes() | |
if start_date is None or end_date is None: | |
jsm_data = q.get_historical_prices(stockcode) | |
else: | |
jsm_data = q.get_historical_prices(stockcode, jsm.DAILY, start_date, end_date, jsm.DAILY) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
## Convert strings of 2-digits number have the following tricky format to an integer. | |
## Tricky format: the last digit is described as decimal, and the first digit is chosen from {1, ..., 9, A, ..., Z, a, ..., z}. | |
## The min is 0(="00") and the max is 619(="z9"). | |
## Example: "15" -> 15, "A0" -> 100, "Z9" -> 359, "a0" -> 360, "c5" -> 385 | |
def num2int(num): | |
if num.isdigit(): | |
return int(num) | |
elif num[0].isupper(): | |
return int(num[0], 36) * 10 + int(num[1]) |
This file contains 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
# julia> versioninfo() | |
# Julia Version 1.5.0 | |
# Commit 96786e22cc (2020-08-01 23:44 UTC) | |
# Platform Info: | |
# OS: macOS (x86_64-apple-darwin18.7.0) | |
# CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz | |
# WORD_SIZE: 64 | |
# LIBM: libopenlibm | |
# LLVM: libLLVM-9.0.1 (ORCJIT, skylake) |
This file contains 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 time | |
import numpy as np | |
import pandas as pd | |
def np_mode(df): | |
""" | |
与えられたDataFrameの各列から最頻値を返す | |
Original: https://twitter.com/nkay/status/1328231713919496194 | |
""" |
OlderNewer