semvec/pypi-packages huggingface dataset:
quantzero 0.0.5
This package is specially designed for Taiwan stock market.
License: MIT
Requires Python: >=3.7.0

# 使用教學

以下文件將幫助使用者快速上手`iStock`，功能包含**建立數據資料庫**、**每日自動化爬蟲**、**最真實的回測模組**，提供量化交易的最佳Python套件!

```py
__init__.py
data.py
crawler.py
plotting.py
backtesting.py
linebot.py
```

## Demo 
#### 建立資料庫
```py
import iStock

# 自動建立DB & 手動下載雲端數據
iStock.setup()
```

#### 多線程爬蟲
```py
from iStock import crawler

crawler.auto_update()
```

#### 使用資料庫
```py
from iStock import data

# 取得臺股上市櫃收盤價
close = data.get_twstock('收盤價')

# 取得臺股上市櫃外資買賣超股數
foreign_investors = data.get_twstock('外資買賣超股數')

# 取得臺股上市櫃融資餘額增減股數
margin_trading = data.get_twstock('融資餘額增減張數')

# 取得臺股上市櫃當月營收
rev = data.get_twstock('當月營收')

# 取得加密貨幣數據
btc = data.get_binance('BTCUSDT','1h')
eth = data.get_binance('ETHUSDT','1h')

# 取得個股開高低收量
stock_id = '2330' # 選擇股票代號(全球股市+加密市場)，如:0050,APPL,BTCUSDT
ohlcv = data.get_klines(stock_id)
```

#### 取得即時報價
```py
from iStock import data

# 取得個股最新報價
stock_id = '2330'
ohlcv = data.get_klines(stock_id,realtime=True)

# 取得臺股上市上櫃全部最新報價
price = data.get_twstock('即時報價')
```

#### 股市Kline
```py
from iStock import data,plotting

stock_id = '2330'
ohlcv = data.get_klines(stock_id)

# 繪製互動式K線圖
plotting.kline_chart(ohlcv,stock_id)

# 繪製靜態式K線圖
plotting.candlestick(ohlcv,stock_id)
```

#### 策略回測
回測分為針對單一商品及多商品組合(portfolio)，以下使用常見的均線策略作範本:

##### **單一商品**
```py
from iStock import data
from iStock import backtesting

stock_id = '2330'
ohlcv = data.get_klines(stock_id)

# 建立技術指標
def ma(n):
    return ohlcv.close.rolling(n,min_periods=1).mean()

# 黃金交叉時買進;死亡交叉時賣出
entry = (ma(5)>=ma(20))&(ma(5).shift()<ma(20).shift())
exit = (ma(5)<ma(20))&(ma(5).shift()>=ma(20).shift())

# 虧損達6%時停損
stop_loss = -6

# 開始回測
strategy = backtesting.individual_stock(ohlcv,entry,exit,stop_loss=stop_loss)
```

##### **多商品組合(portfolio)**
```py
from iStock import data
from iStock import backtesting

c = data.get_twstock('收盤價')
o = data.get_twstock('開盤價')
h = data.get_twstock('最高價')
v = data.get_twstock('成交股數')/1000

# 建立技術指標
def ma(n):
    return c.rolling(n,min_periods=1).mean()

def pressure(n):
    return (h/h.shift().rolling(n,min_periods=5).max()-1)*100
    
buy1 = (c>10)&(c<200)&(v.rolling(20).mean()>=100)
buy2 = (pressure(120)>=0)&(pressure(120).shift()<0)
buy3 = c>o*1.03

sell1 = c<ma(5)
sell2 = c<o*0.97

entry = buy1&buy2&buy3
exit = sell1&sell2
hold_days = 10
price_df = c

start_date = '2010-10-26'
end_date = c.index[-1]
stop_loss = -5

# 開始回測
strategy = backtesting.portfolio_stocks(entry,exit,hold_days,price_df,start_date,end_date,stop_loss=stop_loss)
```

##### **金字塔交易(pyramid)**
```py
from iStock import data
import pandas as pd
import pandas_ta as ta

stock_id = '0050'
ohlcv = data.get_klines(stock_id)
rsi = ohlcv.ta.rsi(5)

entry = pd.DataFrame({
    '10<RSI<12':(10<rsi)*(rsi<12)*0.1,
    '5<RSI<10':(5<rsi)*(rsi<10)*0.2,
    'RSI<5':(rsi<5)*0.3
})

exit = pd.DataFrame({
    '95<RSI':(95<rsi)*0.2,
    'break-240-high':(ohlcv.close>=ohlcv.high.shift().rolling(240).max())*0.1
})

from iStock import backtesting

strategy = backtesting.pyramid_trade(ohlcv,entry,exit)
```
movies-download 0.0.2
视频下载助手
License: MIT
Requires Python: >=3.8

# 自由行
一个下载电影的助手。
方便下载m3u8格式的视频文件。

# 使用方法
请自行研究。

# 打包程序

## 安装打包工具
```shell
python -m pip install --upgrade build
```
## 创建配置文件后, 开始打包，执行下面的命令
```shell
python -m build
```

## 安装上传工具并上传到PyPI，执行下面的命令
```shell
python -m pip install --upgrade twine
python -m twine upload dist/*
```