Closed szz65 closed 12 months ago
Thank you for posting the code @szz65. I tried querying with just the DataSource, and I also received an empty DataFrame:
ds = AKShare()
rows = ds.query(symbols=['sh110079'], start_date='4/6/2022', end_date='11/24/2023')
@albertandking do you know if there is an issue with the above symbol?
Currently, pyb's support for akshare can only support stock queries. See line 67 of pybroker/ext/data.py:
temp_df = akshare.stock_zh_a_hist(
symbols_simple[i],
start_date=start_date_str,
end_date=end_date_str,
period="daily",
adjust=adjust if adjust is not None else "",
)
sh110079 is a convertible bonds. Use a different API: https://akshare.akfamily.xyz/data/bond/bond.html#id24
import akshare as ak
bond_zh_hs_cov_daily_df = ak.bond_zh_hs_cov_daily(symbol="sh110079")
print(bond_zh_hs_cov_daily_df)
Thank you for posting the code @szz65. I tried querying with just the DataSource, and I also received an empty DataFrame:
ds = AKShare() rows = ds.query(symbols=['sh110079'], start_date='4/6/2022', end_date='11/24/2023')
@albertandking do you know if there is an issue with the above symbol?
yes, ref @none2003
Thank you @none2003 and @albertandking!
Hi, there. It's my first time to try pybroker. And when I test a script, I just met the error "ValueError: DataSource is empty." Here are my test script: import pybroker from pybroker import Strategy, StrategyConfig, ExecContext from pybroker.ext.data import AKShare
config = StrategyConfig(initial_cash=500_000)
strategy = Strategy(data_source=AKShare(), start_date='4/6/2022', end_date='11/24/2023', config=config)
def buy_low(ctx):
If shares were already purchased and are currently being held, then return.
strategy.add_execution(buy_low, symbols=['sh113055'])
def short_high(ctx):
If shares were already shorted then return.
strategy.add_execution(short_high, symbols=['sh110079'])
result = strategy.backtest()"