fundamentals.stockcode.in_(context.hs300) ).limit(10) fund = get_fundamentals(q) # 行列内容以及索引一起进行转置 # print(fund.T) context.stock_list = fund.T.index # before_trading此函数会在每天策略交易开始前被调用,当天只会被调用一次 def before_trading(context): pass # 你选择的证券的数据...
import pandas as pdimport jyimport stockimport 画K线def ma(收盘价, 参数): 均线 = 收盘价.rolling(参数).mean() 均线=round(均线,3) return 均线def bull(收盘价, 均线, 参数): std = 收盘价.rolling(参数).std() up_bb = 均线 + std * 2 low_bb = 均线 - std * 2 ...
Put-Call Parity Calculation:Left-hand side (LHS): Call option price adjusted for present value of strike - -99.63523669507855Right-hand side (RHS): Put option price + Stock price - 107Difference between LHS and RHS: -206.63523669507856Put-Call Parity does not hold.接近于零的值表明奇偶性成立...
import pandas as pd# 导入DataFrame数据import stock #导入股票数据模块import 画K线import macd策略# 导入数据股票代码='002191'天数 = 500截止日期="20210312"股票数据 = stock.读取csv数据(股票代码,天数,截止日期)def 读取数据(股票日线数据): # 导入股票数据 股票日线数据 = stock.读取csv数据(股票...
deftrading_strategy(market_data):# 示例策略:假设我们选择价格低于某个阈值的股票threshold_price=100forstockinmarket_data['stocks']:ifstock['price']<threshold_price:print(f"建议买入股票:{stock['name']}价格:{stock['price']}")returnstock['code']# 返回建议买入的股票代码returnNone ...
lg = bs.login() # 显示登陆返回信息 print('login respond error_code:'+lg.error_code) print('login respond error_msg:'+lg.error_msg) #获取股票的代码,你可以加入多个股票序列 StockCodes=['000001','600017','000015'] for code in StockCodes: #6开头的是上证 if code[0]=='6': code="sh...
第一步,对照原版研报,获取沪深300指数从2005年至今的开高低收行情数据,这里使用的是股票量化开源库qstock,“pip install qstock”安装后,基本的功能无需注册便可以使用,萌新使用起来也非常丝滑。 import qstock as qs # 获取沪深300指数从2005年至今的高开低收等行情数据,index是日期 data = qs.get_data(code_...
Examples for stock_code are "WIPRO" or "ZEEENT". product_type can be either 'Futures', 'Options' or an empty string. Product_type can not be an empty string for exchange_code 'NDX', 'MCX' and 'NFO'. strike_date can be in DD-MMM-YYYY(Ex.: 01-Jan-2022) or an empty string. ...
from stock_util import get_trading_dates DB_CONN = MongoClient('mongodb://127.0.0.1:27017')['quant_01'] #从tushare获取股票基础数据,保存到本地的MongoDB数据库中 def crawl_basic(begin_date=None, end_date=None): """ 抓取指定时间范围内的股票基础信息 ...
As passed above, it shows the trading categories that are imported from Japan and China. Yahoo Finance Yahoo! Finance is a component of Yahoo’s network. It is the most widely used business news website in the United States, featuring stock quotes, press announcements, financial reports, and...