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
def dollar_averaging(df, trade_date, trade_amount, f_or_b = 'f'): | |
''' | |
Input: | |
1. df (dataframe) | |
---> Datetime object should be set as index | |
2. trade_date (int) | |
---> determine which date to invest |
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 scipy.stats as st | |
import numpy as np | |
def black_scholes_pricing_model( | |
option_type: str, | |
s: float, | |
k: float, | |
r: float, | |
v: float, |
Loading
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
import random | |
doors = ['Goat', 'Car', 'Goat'] | |
n = 1000 | |
win = 0 | |
lose = 0 | |
for _ in range(n): | |
#-------------------------# |
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 | |
from io import StringIO | |
import requests | |
import time | |
import random | |
def get_put_call_ratio_df(q_start_date: str, q_end_date:str): | |
url = 'https://www.taifex.com.tw/cht/3/pcRatioDown' | |
payload = { | |
'queryStartDate': q_start_date, |
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
from enum import Enum | |
import numpy as np | |
import scipy.stats as st | |
class OptionType(str, Enum): | |
call = 'Call' | |
put = 'Put' | |
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 requests | |
# 設定目標日期 | |
target_date = '20230928' | |
# 把 csv 檔抓下來 | |
url = f'https://www.twse.com.tw/rwd/zh/afterTrading/MI_INDEX?date={target_date}&type=ALL&response=csv' | |
res = requests.get(url) | |
data = res.text |
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
from urllib.parse import urlencode, urljoin | |
from datetime import datetime | |
from pandas.core.frame import DataFrame | |
import requests | |
import pandas as pd | |
def get_etf_dividend_history( | |
symbol: str = "", | |
start_date: str = '20050101', |
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 scipy.stats as st | |
import numpy as np | |
def binomial_tree_pricing_model( | |
option_type: str, | |
s: float, | |
k: float, | |
r: float, | |
v: float, |
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
from pydantic import BaseModel | |
from enum import Enum | |
from datetime import date, datetime, timedelta | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FormatStrFormatter | |
class OptionType(str, Enum): | |
Call = 'Call' | |
Put = 'Put' |
OlderNewer