Table of Contents

Class PlatformModule

Namespace
ATAS.Indicators.Modules
Assembly
ATAS.Indicators.dll

Base class of a custom module written in a custom assembly: a panel of the classic %ATAS and a widget of %ATAS X whose whole client area the module draws through RenderContext — one code base for both platforms. Derive from it, mark the class with PlatformModuleAttribute, give it a public parameterless constructor and override OnRender(RenderContext, Rectangle); the other hooks are optional.

Not in ATAS 8.0.15 yet: available from the next version.

[Obfuscation(Feature = "renaming", ApplyToMembers = true, Exclude = true)]
public abstract class PlatformModule
Inheritance
object
PlatformModule
Extension Methods

Remarks

The platform never calls one module instance concurrently: data callbacks, the timer, input and the drawing are serialized, so the module needs no locks for its own fields. Data callbacks are delivered on a platform thread shortly after the data arrives (in arrival order), never on the thread of the data feed. Drawing and input are called on the thread of the panel.

Public read/write properties are the module settings: they are shown in the settings window of the panel (use [Display] for names, groups and order, [Browsable(false)] to hide one) and saved with the workspace. OnSettingsChanged() is called after the user changed them.

A module reads market data and draws; it has no access to orders, accounts or positions.

If an override throws, the platform logs the exception, releases the instance (OnDispose()) and shows the error in the panel; clicking the panel, opening its settings or loading the workspace again starts a new instance with the saved settings.

Constructors

PlatformModule()

Initializes the module. The platform creates it with its parameterless constructor; the module is attached to its panel afterwards, so do not use the platform services here.

protected PlatformModule()

Properties

Context

The panel the module is shown in. Available from OnInitialize() on.

protected IPlatformModuleContext Context { get; }

Property Value

IPlatformModuleContext

Exceptions

InvalidOperationException

The module is not attached to a panel yet.

IsAttached

True once the module is attached to a panel (Context is available).

protected bool IsAttached { get; }

Property Value

bool

Methods

OnBestBidAskChanged(MarketDataArg)

The best bid or the best ask changed (DataType tells which). The latest value is delivered: changes that happen faster than the platform delivers them are merged.

protected virtual void OnBestBidAskChanged(MarketDataArg bestPrice)

Parameters

bestPrice MarketDataArg

OnBestBidAskChanged(IPlatformModuleInstrument, MarketDataArg)

The best bid or the best ask of an additional instrument changed; the latest value is delivered.

protected virtual void OnBestBidAskChanged(IPlatformModuleInstrument instrument, MarketDataArg bestPrice)

Parameters

instrument IPlatformModuleInstrument
bestPrice MarketDataArg

OnButtonClick(PlatformModuleButton)

The user clicked a button of Buttons. For a toggle (IsCheckable) the platform has already flipped IsChecked. The default implementation calls Click.

protected virtual void OnButtonClick(PlatformModuleButton button)

Parameters

button PlatformModuleButton

OnDispose()

The platform stops using this instance: the panel was closed (also when the workspace is switched or the platform exits), the module was stopped by an error, the tariff no longer allows custom modules, its settings were replaced as a whole, or the assembly was reloaded. Called exactly once for every instance whose constructor completed, even if OnInitialize() was not reached or threw. Release what the module created (timers, files, subscriptions to your own services, native resources) here; no other method is called afterwards. An exception thrown here is logged and ignored.

protected virtual void OnDispose()

OnInitialize()

Called when the module is attached to its panel (once per instance), after its saved settings were restored. Context is available from here on.

protected virtual void OnInitialize()

OnInstrumentChanged()

Called after the panel switched to another instrument (or lost it: Instrument is then null), and once after OnSettingsChanged() when an instrument is selected. Reset the accumulated data here; the data callbacks that follow belong to the new instrument.

protected virtual void OnInstrumentChanged()

OnInstrumentStateChanged(IPlatformModuleInstrument)

The state of an additional instrument (AddInstrument(string, string?, bool)) changed: the platform subscribed to its data, stopped delivering it, or delivers it again. When the instrument becomes Active, its statistics and — if asked for — its whole order book follow right after this call.

protected virtual void OnInstrumentStateChanged(IPlatformModuleInstrument instrument)

Parameters

instrument IPlatformModuleInstrument

OnKeyDown(PlatformModuleKeyEventArgs)

A key was pressed while the module has the keyboard focus (the user clicked it).

protected virtual void OnKeyDown(PlatformModuleKeyEventArgs e)

Parameters

e PlatformModuleKeyEventArgs

OnKeyUp(PlatformModuleKeyEventArgs)

A key was released while the module has the keyboard focus.

protected virtual void OnKeyUp(PlatformModuleKeyEventArgs e)

Parameters

e PlatformModuleKeyEventArgs

OnMarketDepthChanged(IPlatformModuleInstrument, IReadOnlyList<MarketDataArg>)

Changed order book levels of an additional instrument added with the order book (a zero volume removes the level). The first call after the instrument became active carries its whole book. Do not keep the list.

protected virtual void OnMarketDepthChanged(IPlatformModuleInstrument instrument, IReadOnlyList<MarketDataArg> levels)

Parameters

instrument IPlatformModuleInstrument
levels IReadOnlyList<MarketDataArg>

OnMarketDepthChanged(IReadOnlyList<MarketDataArg>)

Changed order book levels (DataType is Bid or Ask; a zero volume removes the level). The first call after OnInstrumentChanged() carries the whole book of the new instrument. The book as of the delivered changes is available through GetDepth(bool). Do not keep the list: it belongs to this call.

protected virtual void OnMarketDepthChanged(IReadOnlyList<MarketDataArg> levels)

Parameters

levels IReadOnlyList<MarketDataArg>

OnMouseClick(RenderControlMouseEventArgs)

The user clicked the module. Set Handled to suppress the panel context menu of a right click.

protected virtual void OnMouseClick(RenderControlMouseEventArgs e)

Parameters

e RenderControlMouseEventArgs

OnMouseDown(RenderControlMouseEventArgs)

A mouse button was pressed over the module.

protected virtual void OnMouseDown(RenderControlMouseEventArgs e)

Parameters

e RenderControlMouseEventArgs

OnMouseLeave()

The mouse left the module.

protected virtual void OnMouseLeave()

OnMouseMove(RenderControlMouseEventArgs)

The mouse moved over the module. Coordinates are relative to the client area.

protected virtual void OnMouseMove(RenderControlMouseEventArgs e)

Parameters

e RenderControlMouseEventArgs

OnMouseUp(RenderControlMouseEventArgs)

A mouse button was released over the module.

protected virtual void OnMouseUp(RenderControlMouseEventArgs e)

Parameters

e RenderControlMouseEventArgs

OnMouseWheel(RenderControlMouseEventArgs)

The mouse wheel was turned over the module (Delta).

protected virtual void OnMouseWheel(RenderControlMouseEventArgs e)

Parameters

e RenderControlMouseEventArgs

OnNewTrades(IPlatformModuleInstrument, IReadOnlyList<MarketDataArg>)

New trades of an additional instrument, oldest first. Do not keep the list: it belongs to this call.

protected virtual void OnNewTrades(IPlatformModuleInstrument instrument, IReadOnlyList<MarketDataArg> trades)

Parameters

instrument IPlatformModuleInstrument
trades IReadOnlyList<MarketDataArg>

OnNewTrades(IReadOnlyList<MarketDataArg>)

New trades of the instrument, oldest first. Do not keep the list: it belongs to this call.

protected virtual void OnNewTrades(IReadOnlyList<MarketDataArg> trades)

Parameters

trades IReadOnlyList<MarketDataArg>

OnRender(RenderContext, Rectangle)

Draws the module. bounds is the whole client area; the platform has filled it with BackgroundColor. Called for every frame — keep it cheap: compute in the data callbacks and the timer, draw here.

protected abstract void OnRender(RenderContext context, Rectangle bounds)

Parameters

context RenderContext
bounds Rectangle

OnSettingsChanged()

Called after the module settings changed (and once after OnInitialize()).

protected virtual void OnSettingsChanged()

OnSizeChanged(Size)

The client area of the module changed its size (also called before the first OnRender(RenderContext, Rectangle)).

protected virtual void OnSizeChanged(Size size)

Parameters

size Size

OnSummaryChanged(InstrumentDailySummary)

The exchange statistics of the instrument (day open/high/low, volume, previous close, …) changed. The latest value is delivered: changes that happen faster than the platform delivers them are merged.

protected virtual void OnSummaryChanged(InstrumentDailySummary summary)

Parameters

summary InstrumentDailySummary

OnSummaryChanged(IPlatformModuleInstrument, InstrumentDailySummary)

The exchange statistics of an additional instrument changed; the latest value is delivered.

protected virtual void OnSummaryChanged(IPlatformModuleInstrument instrument, InstrumentDailySummary summary)

Parameters

instrument IPlatformModuleInstrument
summary InstrumentDailySummary

OnTimer()

Called about ten times per second while the panel is open (also while it is hidden behind another tab).

protected virtual void OnTimer()

Redraw()

Asks the platform to draw a new frame; calls are merged. Does nothing before OnInitialize().

protected void Redraw()