OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
filled_orders.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#if (defined(_MSVC_LANG) ? _MSVC_LANG : __cplusplus) < 201703L
9#error \
10 "OpenPine C++ wrapper headers require C++17 (std::optional, std::string_view)."
11#endif
12
13#include <cstdint>
14#include <memory>
15#include <string_view>
16
17#include "../ffi.hpp"
18#include "../string_ref.hpp"
19
20namespace openpine {
21
29 public:
31 std::string_view orderId() const {
32 return detail::refToView(data_.order_id);
33 }
34
36 double price() const { return data_.price; }
37
39 double quantity() const { return data_.quantity; }
40
41 private:
42 ffi::FilledOrder data_{};
44};
45
52 private:
53 std::unique_ptr<ffi::FilledOrdersIterator,
54 decltype(&ffi::filledOrdersIteratorDelete)>
55 p_;
56
57 public:
62 explicit FilledOrdersIterator(ffi::FilledOrdersIterator* p)
63 : p_(p, ffi::filledOrdersIteratorDelete) {}
64
70 bool next(FilledOrder& out) {
71 return ffi::filledOrdersIteratorNext(p_.get(), &out.data_);
72 }
73};
74
75} // namespace openpine
A single filled order (signal name, price, signed quantity).
std::string_view orderId() const
Signal/order id (e.g. entry or exit name).
double quantity() const
Signed quantity (positive = buy, negative = sell).
double price() const
Fill price.
friend class FilledOrdersIterator
bool next(FilledOrder &out)
Advances to the next filled order and writes it into out.
FilledOrdersIterator(ffi::FilledOrdersIterator *p)
Constructs an iterator from the C ABI handle.
std::string_view refToView(const ffi::PineStringRef &ref)
Shared helpers for converting C ABI string refs to std::string_view.