量化交易機器人系統(tǒng)開發(fā)詳細(xì)及策略丨量化合約/合約量化系統(tǒng)開發(fā)成熟及技術(shù)丨源碼案例
The two main uses of quantitative trading robots are to make markets through arbitrage;When the market is relatively cold,act as the corresponding seller or buyer,and activate trading volume in the market;After initializing the setting parameters,the quantitative trading robot will trade according to the strategy,automatically buying or selling when the set conditions are met,without the need for long-term trading;Strictly implement trading strategies based on the new market situation;Real time viewing of transaction conditions to ensure real-time execution of transactions;Try to avoid adverse effects caused by human subjective factors as much as possible.
量化策略是指使用計算機作為工具,通過一套固定的邏輯來分析、判斷和決策。量
化策略既可以自動執(zhí)行,也可以人工執(zhí)行;開發(fā)策略及詳情唯:MrsFu123,從本質(zhì)上說,交易機器人是一種軟件程序,它直接與金融交易所進(jìn)行交互(通常使用API獲取和解釋相關(guān)信息),并根據(jù)市場數(shù)據(jù)的解釋發(fā)出買賣訂單。
這是一個PPQ量化的入口腳本,將你的模型和數(shù)據(jù)按要求進(jìn)行打包:
This file will show you how to quantize your network with PPQ
You should prepare your model and calibration dataset as follow:
~/working/model.onnx<--your model
~/working/data/*.npy or~/working/data/*.bin<--your dataset
if you are using caffe model:
~/working/model.caffemdoel<--your model
~/working/model.prototext<--your model
###MAKE SURE YOUR INPUT LAYOUT IS[N,C,H,W]or[C,H,W]###
quantized model will be generated at:~/working/quantized.onnx
"""
from ppq import*
from ppq.api import*
import os
#modify configuration below:
WORKING_DIRECTORY='working'#choose your working directory
TARGET_PLATFORM=TargetPlatform.PPL_CUDA_INT8#choose your target platform
MODEL_TYPE=NetworkFramework.ONNX#or NetworkFramework.CAFFE
INPUT_LAYOUT='chw'#input data layout,chw or hwc
NETWORK_INPUTSHAPE=[1,3,224,224]#input shape of your network
CALIBRATION_BATCHSIZE=16#batchsize of calibration dataset
EXECUTING_DEVICE='cuda'#'cuda'or'cpu'.
REQUIRE_ANALYSE=False
DUMP_RESULT=False#是否需要Finetuning一下你的網(wǎng)絡(luò)
#SETTING對象用于控制PPQ的量化邏輯
#當(dāng)你的網(wǎng)絡(luò)量化誤差過高時,你需要修改SETTING對象中的參數(shù)進(jìn)行特定的優(yōu)化
SETTING=UnbelievableUserFriendlyQuantizationSetting(
platform=TARGET_PLATFORM,finetune_steps=2500,
finetune_lr=1e-3,calibration='kl',#【改】量化算法可選'kl','pecentile','mse'
equalization=True,non_quantable_op=None)
SETTING=SETTING.convert_to_daddy_setting()
print('正準(zhǔn)備量化你的網(wǎng)絡(luò),檢查下列設(shè)置:')
print(f'WORKING DIRECTORY:{WORKING_DIRECTORY}')
print(f'TARGET PLATFORM:{TARGET_PLATFORM.name}')
print(f'NETWORK INPUTSHAPE:{NETWORK_INPUTSHAPE}')
print(f'CALIBRATION BATCHSIZE:{CALIBRATION_BATCHSIZE}')
#此腳本針對單輸入模型,輸入數(shù)據(jù)必須是圖像數(shù)據(jù)layout:[n,c,h,w]
#如果你的模型具有更復(fù)雜的輸入格式,你可以重寫下面的load_calibration_dataset函數(shù)
#請注意,任何可遍歷對象都可以作為PPQ的數(shù)據(jù)集作為輸入
dataloader=load_calibration_dataset(
directory=WORKING_DIRECTORY,
input_shape=NETWORK_INPUTSHAPE,
batchsize=CALIBRATION_BATCHSIZE,
input_format=INPUT_LAYOUT)
print('網(wǎng)絡(luò)正量化中,根據(jù)你的量化配置,這將需要一段時間:')
quantized=quantize(
working_directory=WORKING_DIRECTORY,setting=SETTING,
model_type=MODEL_TYPE,executing_device=EXECUTING_DEVICE,
input_shape=NETWORK_INPUTSHAPE,target_platform=TARGET_PLATFORM,
dataloader=dataloader,calib_steps=32)