合约量化系统是一种自动化交易工具,它通过计算机程序实现交易决策和执行。
合约量化系统的工作原理如下:
1.Traders send trading instructions to the contract quantification system through the front-end interface,包括交易品种、交易数量、交易时间等信息。
2.After receiving trading instructions from traders,the contract quantification system will analyze and verify the trading instructions.If the trading instructions comply with regulations,the contract quantification system will execute the transaction.
3.合约量化系统会通过区块链网络接收交易数据,并对交易数据进行验证和计算。
4.The contract quantification system will,based on trading strategies and risk management rules,对交易数据进行分析和决策。
5.如果交易策略生效,合约量化系统将会执行交易,And provide feedback on the trading results to the traders.
import os
import pandas as pd
import tushare as ts
import numpy as np
from pathlib import Path
import matplotlib.pyplot as plt
import mplfinance as mpf
import matplotlib as mpl
from cycler import cycler#用于定制线条颜色
import time
def dividend(ts_code):
df=pro.dividend(ts_code=ts_code)
df.to_csv('dividend.csv',encoding='utf_8_sig')
def draw_finance(ts_codes,begin_count,end_count=-1):
df=load_data(ts_codes)
fig=plt.figure()
ax=fig.add_subplot(111)
opens=df['open'].values[begin_count:end_count]
closes=df['close'].values[begin_count:end_count]
highs=df['high'].values[begin_count:end_count]
lows=df['low'].values[begin_count:end_count]
dates=df['trade_date'].values[begin_count:end_count]
vols=df['vol'].values[begin_count:end_count]
data=[dates,opens,closes,highs,lows,vols]
data=np.transpose(data)#矩阵转置
df=pd.DataFrame(data,columns=['Date','Open','Close','High','Low','Volume'])
df['Date']=pd.to_datetime(df['Date'])
df.set_index(['Date'],inplace=True)
#df.index.name='Date'
#设置基本参数
#type:绘制图形的类型,有candle,renko,ohlc,line等
#此处选择candle,即K线图
#mav(moving average):均线类型,此处设置7,30,60日线
#volume:布尔类型,设置是否显示成交量,默认False
#title:设置标题
#y_label:设置纵轴主标题
#y_label_lower:设置成交量图一栏的标题
#figratio:设置图形纵横比
#figscale:设置图形尺寸(数值越大图像质量越高)
kwargs=dict(
type='candle',
mav=(5,10,20),
volume=True,
title='nA_stock%s candle_line'%(ts_codes),
ylabel='OHLC Candles',
ylabel_lower='SharesnTraded Volume',
figratio=(50,30),
figscale=15)