量化合约项目系统开发技术丨合约量化系统开发流程方案

简介: 量化合约项目系统开发技术丨合约量化系统开发流程方案

1.实现Instance类型
instantiable pallets必须调用decl_storage!宏才能Instance创建类型。

Instance在 Config trait、Event 类型和 Store trait 中添加一个泛型类型。 下面的代码片段显示了pallet的Config和Store trait所需的修改:

pub trait Config<I: Instance>: frame_system::Config {
type Event: From<Event> + Into<::Event>;
}
/// Include the I: Instance type parameter in storage declaration
decl_storage! {
trait Store for Module<T: Config, I: Instance> as MintToken {
/ --snip-- /
配置你的运行时
包括mint_tokenin 的两个实例runtime/src/lib.rs:
/ --snip-- /
// Instance1 of mint_token
impl mint_token::Config<mint_token::Instance1> for Runtime {

type Event = Event;

}

// Instance2 of mint_token
impl mint_token::Config<mint_token::Instance2> for Runtime {

type Event = Event;

}

/ --snip-- /
MintToken1: mint_token::::{Pallet, Call, Storage, Event},
MintToken2: mint_token::::{Pallet, Call, Storage, Event},
/ --snip-- /
示例-波卡的运行时

// Copyright 2017-2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see http://www.gnu.org/licenses/.

//! The Polkadot runtime. This can be compiled with #[no_std], ready for Wasm.

![cfg_attr(not(feature = "std"), no_std)]

// construct_runtime! does a lot of recursion and requires us to increase the limit to 256.

![recursion_limit = "256"]

use pallet_transaction_payment::CurrencyAdapter;
use runtime_common::{

auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar,
prod_or_fast, slots, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate,

};

use runtime_parachains::{

configuration as parachains_configuration, disputes as parachains_disputes,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points,
runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler,
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,

};

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_election_provider_support::{generate_solution_type, onchain, SequentialPhragmen};
use frame_support::{

construct_runtime, parameter_types,
traits::{
    Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
    PrivilegeCmp,
},
weights::ConstantMultiplier,
PalletId, RuntimeDebug,

};
use frame_system::EnsureRoot;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::v2::{

AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId,
InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption,
PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode,
ValidationCodeHash, ValidatorId, ValidatorIndex,

};
use sp_core::OpaqueMetadata;
use sp_mmr_primitives as mmr;
use sp_runtime::{

create_runtime_str,
curve::PiecewiseLinear,
generic, impl_opaque_keys,
traits::{
    AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT,
    OpaqueKeys, SaturatedConversion, Verify,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, KeyTypeId, Perbill, Percent, Permill,

};
use sp_staking::SessionIndex;
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};

[cfg(any(feature = "std", test))]

use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;

pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
pub use pallet_election_provider_multi_phase::Call as EPMCall;

[cfg(feature = "std")]

pub use pallet_staking::StakerStatus;
pub use pallet_timestamp::Call as TimestampCall;

[cfg(any(feature = "std", test))]

pub use sp_runtime::BuildStorage;

相关文章
|
数据挖掘 机器人 API
量化合约系统开发(源码)合约量化系统开发(技术方案)
stock_weights=[]      num_assets=len(selected)
合约量化/量化合约开发源码说明,量化合约/合约量化系统开发(成熟及方案)丨运营版
  Quantitative trading refers to the use of advanced mathematical models instead of subjective judgments,and the use of computer technology to select multiple&quot;high probability&quot;events that can bring excess returns from huge historical data to formulate strategies,greatly reducing the impact of inves
|
人工智能 算法 PyTorch
量化合约系统开发(成熟技术)丨合约量化系统开发(项目策略)及源码详解
  人工智能(Artificial Intelligence,简称AI)是指计算机系统在完成类似人类智力所需的任务时所表现出来的能力。它是一种复杂的技术,通过将大量的数据输入到算法中进行学习,不断调整和改进自己的算法,从而不断优化其性能。
|
前端开发 数据挖掘 API
量化合约系统开发方案丨量化合约系统实现案例源码
量化合约系统开发是指开发一种能够自动化执行交易策略的软件系统,该系统能够根据预设的规则和条件自动执行交易,从而实现量化交易。
|
区块链
合约量化系统开发(项目及方案)丨合约量化系统开发(详细及源码)
  智能合约(Smart contract)是依托计算机在网络空间运行的合约,它以信息化方式传播、验证或执行合同,由计算机读取、执行,具备自助的特点。而区块链的去中心化,数据的防篡改,决定了智能合约更加适合于在区块链上来实现
|
人工智能
量化合约系统开发(案例项目)丨合约量化系统开发(方案成熟)
 Artificial intelligence(AI)refers to the ability of computer systems to perform tasks similar to human intelligence.It is a complex technology,which constantly adjusts and improves its own algorithm by inputting a large amount of data into the algorithm for learning,so as to continuously optimize i
|
存储 5G
量化合约系统开发(策略源码)丨合约量化系统开发(成熟项目)
 With the continuous progress of information technology and communication technology,we have entered the era of intelligent industry.In this era,the application of various intelligent technologies is driving the upgrading and transformation of industry,and new generation information technologies suc
|
人工智能 安全 5G
合约量化系统开发(策略及功能)丨合约量化开发运营版及源码部署
 随着人工智能、5G通信、工业互联网等技术的发展,智能工业正日益成为现代工业发展的主流趋势。智能工业可以通过数字化、智能化、绿色化、协同化的方式实现生产和管理的高效、智能、环保和协同,同时也面临着技术、安全和隐私等方面的挑战和问题。因此,需要加强技术研究和应用实践,保障系统的安全性和可靠性,加强隐私保护和数据安全,推动智能工业的健康发展,为实体经济高质量发展做出贡献。
|
人工智能 并行计算 PyTorch
合约量化系统开发(开发运营版)丨合约量化系统开发(策略及源码)
Artificial intelligence can be divided into two categories:weak artificial intelligence and strong artificial intelligence.Weak AI(also known as narrow AI)refers to AI systems that can only exhibit human intelligence in specific task areas.For example,voice recognition system,auto drive system,etc.S
|
机器学习/深度学习 数据可视化 Linux
ppt量化合约系统开发丨合约量化系统开发丨量化合约策略开发方案
ppt量化合约系统开发丨合约量化系统开发丨量化合约策略开发方案
131 0