本文へ移動
← すべてのサンプル

サンプル 23

Charts by symbol

a report of the workspace by symbol — how many charts each

カテゴリ
Workspace:チャートやパネルを読む・変更する
権限
workspace.read
実行する前に
a terminal window
何をするか
none
実行方法
in TTT, open the T0 Editor, open this file, grant workspace.read,
言語
>=0.1.1, <0.2.0
ホスト
>=0.1.1, <0.2.0
必要なもの
workspace >=0.1.1, <0.2.0

ソース

// Purpose: a report of the workspace by symbol — how many charts each
// symbol has and at which timeframes — and of the panels that are not
// charts. Changes nothing.
// Category: workspace
// Permissions: workspace.read
// Preconditions: a terminal window
// Side effects: none
// Run: in TTT, open the T0 Editor, open this file, grant workspace.read,
// Run.

lang ">=0.1.1, <0.2.0";
host "ttt" ">=0.1.1, <0.2.0";
requires "workspace" ">=0.1.1, <0.2.0";
import std.list;

fn main() {
    let mut seen: List<String> = [];
    for c in workspace.charts() {
        if !list.contains(seen, c.symbol) {
            seen.push(c.symbol);
        }
    }
    for symbol in seen {
        let mut timeframes: List<String> = [];
        for c in workspace.charts() {
            if c.symbol == symbol {
                timeframes.push(c.timeframe);
            }
        }
        print(symbol + ": " + to_string(timeframes.len()) + " chart(s) " + to_string(timeframes));
    }
    let mut others = 0;
    for p in workspace.panels() {
        if p.kind != "Chart" {
            others = others + 1;
            print("panel: " + p.title);
        }
    }
    print(to_string(others) + " panel(s) besides the charts");
}