8
Follow
0
Followers
諸君,私は,特定の周期K線における取引量を,バイセルの2種類別に分けて計算したい.例えば,1分周期のK線図,各K線における取引量の,バイセルの2種類別の取引量はどれぐらいですか.
私の考えは,新しいKラインが生成されないときに,トレードデータを取得して累積し,新しいKラインが生成された後に,累積されたトレードデータを分類統計処理し,取値の各パラメータをリセットし,次のループに移動することです. しかし,リッドディスクレベルの回測時に問題が発生します.[-2]["Volume"の売上高は相違しており, 統計的に見ると,購入売上高と販売売上高は,recordsよりも大きい.[-2]["Volume"では,取引量が多く表示されています.
このコードは,私の周りを2日間回りました。皆さん,論理的な問題があるのか,それとも反省自体に問題があるのでしょうか? 論理的な問題がある場合は,詳細に教えて下さい,ありがとう。
def GetRecords(self):
if self.LastBarTime == self.BarTime:
trades = _C(exchange.GetTrades)
if trades :
for i in range (len(trades)):
if trades[i] not in self.trades:
self.trades.append(trades[i])
if self.LastBarTime != self.BarTime: #新K线
if self.trades :
for i in range (len(self.trades)):
if self.trades[i]["Type"] == 0 : #买单
self.trade_buy.append(self.trades[i])
if self.trades[i]["Type"] == 1 : #卖单
self.trade_sell.append(self.trades[i])
if self.trade_buy:
for i in range (len(self.trade_buy)):
self.totlebuyamount += self.trade_buy[0-i]["Amount"]
if self.trade_sell:
for i in range (len(self.trade_sell)):
self.totlesellamount += self.trade_sell[0-i]["Amount"]
Log("总成交量",self.totlebuyamount+self.totolesellamoun,"买单成交量",self.totlebuyamount,"卖单成交量",self.totolesellamount)
self.trades = []
self.trade_buy = []
self.trade_sell = []
self.totlebuyamount = 0
self.totlesellamount = 0
Related Recommendations
Financial Magic Zone Global KOL RecruitmentFAQ Summary (Updating...)PINE Language Introductory Tutorial of FMZ QuantPrimary Tutorial of Strategy Writing with FMZ Quant Trading Platform (Must Read)Getting Started with FMZ Quant Trading Platform (Must Read)MyLanguage DocFMZ PINE Script DocNotes & Explanation of Futures Reverse Doubling Algorithm StrategySolutions to Obtaining Docker Http Request MessageExtending Custom Template by Visual (Blockly ) Strategy Editing
Comment
All comments (4)
- 1
