Class: Melaya::Client
- Inherits:
-
Object
- Object
- Melaya::Client
- Defined in:
- lib/melaya.rb
Overview
The Melaya client.
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Authenticated account reads: connected keys, tier limits, usage.
-
#backtest ⇒ Object
readonly
Historical backtests + parameter sweeps on the Rust engine.
-
#market ⇒ Object
readonly
REST market-data + reference endpoints (public plane).
-
#sim ⇒ Object
readonly
Paper trading (sim broker): virtual balance, positions, and orders.
-
#strategies ⇒ Object
readonly
Launch, control, and inspect trading strategies (paper + live).
-
#stream ⇒ Object
readonly
WebSocket streaming endpoints (public market data + private feeds).
-
#trade ⇒ Object
readonly
Live trading — credentialed order placement and account state on a connected exchange.
Instance Method Summary collapse
-
#initialize(api_key:, base_url: HttpClient::DEFAULT_BASE_URL, ws_url: StreamAPI::DEFAULT_WS_URL, verify_ssl: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key:, base_url: HttpClient::DEFAULT_BASE_URL, ws_url: StreamAPI::DEFAULT_WS_URL, verify_ssl: nil) ⇒ Client
Returns a new instance of Client.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/melaya.rb', line 55 def initialize(api_key:, base_url: HttpClient::DEFAULT_BASE_URL, ws_url: StreamAPI::DEFAULT_WS_URL, verify_ssl: nil) raise ArgumentError, "Melaya: api_key is required (create one at melaya.org -> Settings -> API Keys)." \ if api_key.nil? || api_key.empty? raise ArgumentError, "Melaya: API keys must be prefixed 'mk_'." \ unless api_key.start_with?("mk_") ssl = if verify_ssl.nil? ENV["MELAYA_INSECURE_TLS"] != "1" else verify_ssl end http = HttpClient.new(api_key: api_key, base_url: base_url, verify_ssl: ssl) @market = MarketAPI.new(http) @account = AccountAPI.new(http) @sim = SimAPI.new(http) @strategies = StrategiesAPI.new(http) @backtest = BacktestAPI.new(http) @stream = StreamAPI.new(api_key, ws_url, http, verify_ssl: ssl) @trade = TradeAPI.new(http) end |
Instance Attribute Details
#account ⇒ Object (readonly)
Authenticated account reads: connected keys, tier limits, usage.
38 39 40 |
# File 'lib/melaya.rb', line 38 def account @account end |
#backtest ⇒ Object (readonly)
Historical backtests + parameter sweeps on the Rust engine.
44 45 46 |
# File 'lib/melaya.rb', line 44 def backtest @backtest end |
#market ⇒ Object (readonly)
REST market-data + reference endpoints (public plane).
36 37 38 |
# File 'lib/melaya.rb', line 36 def market @market end |
#sim ⇒ Object (readonly)
Paper trading (sim broker): virtual balance, positions, and orders.
40 41 42 |
# File 'lib/melaya.rb', line 40 def sim @sim end |
#strategies ⇒ Object (readonly)
Launch, control, and inspect trading strategies (paper + live).
42 43 44 |
# File 'lib/melaya.rb', line 42 def strategies @strategies end |
#stream ⇒ Object (readonly)
WebSocket streaming endpoints (public market data + private feeds).
46 47 48 |
# File 'lib/melaya.rb', line 46 def stream @stream end |
#trade ⇒ Object (readonly)
Live trading — credentialed order placement and account state on a connected exchange. WARNING: real funds.
48 49 50 |
# File 'lib/melaya.rb', line 48 def trade @trade end |