Index future simple stat and time-series backtest module
Project description
Index Futures Simple Backtest Module (Personal Usage)
Chang Sun Email
Install and Update
pip install --upgrade sc-backtest
Simple Test
- Check for factor validity
- Statistical:
- CDF
- Markout
- Hist
- Time-Series:
- Sign-Trade
- Value-Trade
- Threshold-Trade
- Backtest
- get_report
- get_pnl_plot
- Statistical:
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
from sc_backtest import simpletest
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = simpletest(is_day=True)
st.plot_cdf(x, y)
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
from sc_backtest import simpletest, bt
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = sb.simpletest(is_day=True)
data = st.simple_pnl(x, y, data_return=True)
report = bt.get_report(data['delta_med'], y)
bt.get_pnl_plot(data['delta_med'], y)
Technical Analysis (ta)
Reference: ta
Technical Analysis2 (ta2)
Variou moving average function
- SMA
- EMA
- WMA
- MMA
- QMA
- ...
import pandas as pd
import numpy as np
from sc_backtest import ta2
wma = ta2.wma(pd.Series(np.random.rand(100)), window=5)
Example
Input your factor and underlying asset's future return series with index type as DatetimeIndex and get the composite stat and time-series plots.
# x: factors
# y: asset's future ret
import pandas as pd
import numpy as np
from sc_backtest import simpletest
data = pd.read_csv('.\factor_and_ret.csv', index_col=0, header=0)
x = data.loc[:, 'factor']
y = data.loc[:, 'ret']
st = simpletest(is_day=True)
st.plot_composite(x, y, markout_periods=30, cdf_period2=5)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sc-backtest-0.0.9.tar.gz
(9.0 kB
view hashes)
Built Distribution
Close
Hashes for sc_backtest-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c3c5f1b4cde3e98afd5b33014ee5f2799d53b4aee0a5c56fb2549f4b43332a7 |
|
MD5 | 675ac469e9134ba1bf1c7310a1c1297b |
|
BLAKE2b-256 | 31e96b54cfdfcd31f48abcb193a7aeadfe8fb40cff8c335efca3c3ffe2102aad |