Athanor Quickstart¶
Define two factors in factors.at:
factor spread :=
Bar.close - Bar.open
factor spread_mean := ~window:20
MEAN spread
Compile the definitions with the Athanor CLI included in the release:
mkdir -p generated
athanor compile --output generated/factors.hpp factors.at
The output is a C++ header under namespace aurum::alpha. Regenerate it
after changing any input definition.
Attach the factors¶
#include "generated/factors.hpp"
#include <aurum/sdk.hpp>
#include <aurum/venue/okx.hpp>
using namespace aurum;
using aurum::alpha::spread;
using aurum::alpha::spread_mean;
class FactorWatch final : public sdk::Application {
public:
FactorWatch() : sdk::Application({.mode = sdk::RuntimeMode::LIVE}) {
bind<Datafeed>(venue::okx::Bar("BTCUSDT", "1m"));
(void)wire<"bar://okx/BTCUSDT@1m", spread, spread_mean>();
on(TOPIC<"bar://okx/BTCUSDT@1m">, [](const auto&) {
auto value =
ref(TOPIC<"factor://spread_mean/btcusdt.okx@bar:1m">);
if (value) log::info("spread mean={}", *value);
});
}
};
AURUM_EXPORT(FactorWatch)
Run the project with aurum run .. The factor resource becomes visible in
the runtime catalog after the source is bound.
Continue with Factors in Strategies for window and lifecycle behavior.