public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>,
	Michael William Jonathan <[email protected]>
Cc: Alviro Iskandar Setiawan <[email protected]>,
	Ravel Kevin Ethan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RFC PATCH 7/9] gwarnt: Create the initial example
Date: Tue, 10 Sep 2024 23:44:12 +0200	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Initial example to show the usage.

Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---
 src/gwarnt/entry.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/gwarnt/entry.cpp b/src/gwarnt/entry.cpp
index 4a74df9..044234e 100644
--- a/src/gwarnt/entry.cpp
+++ b/src/gwarnt/entry.cpp
@@ -1,6 +1,48 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include <unistd.h>
+#include <iostream>
+#include <gwarnt/p2p/okx.hpp>
+#include <gwarnt/p2p/binance.hpp>
+#include <gwarnt/arbitrage.hpp>
+
 int main(void)
 {
+	std::vector<gwarnt::p2p_ad> buy_bnc, sell_bnc;
+	std::vector<gwarnt::p2p_ad> buy_okx, sell_okx;
+	std::vector<gwarnt::arb_opp> opportunities;
+	gwarnt::p2p::binance bnc;
+	gwarnt::p2p::okx okx;
+
+	while (1) {
+		printf("Fetching data ...\n");
+		buy_bnc = bnc.get_data("IDR", "USDT", "BUY");
+		sell_bnc = bnc.get_data("IDR", "USDT", "SELL");
+
+		buy_okx = okx.get_data("IDR", "USDT", "BUY");
+		sell_okx = okx.get_data("IDR", "USDT", "SELL");
+		printf("Binance: %lu buy, %lu sell\n", buy_bnc.size(), sell_bnc.size());
+		printf("OKX: %lu buy, %lu sell\n", buy_okx.size(), sell_okx.size());
+
+		opportunities = gwarnt::find_arbitrage_opps(sell_okx, buy_bnc);
+		for (const auto &i : opportunities) {
+			std::cout << i.sell.dump() << std::endl;
+			std::cout << "====================" << std::endl;
+			std::cout << i.buy.dump() << std::endl;
+			std::cout << "----------------------------------------------" << std::endl;
+		}
+
+		opportunities = gwarnt::find_arbitrage_opps(sell_bnc, buy_okx);
+		for (const auto &i : opportunities) {
+			std::cout << i.sell.dump() << std::endl;
+			std::cout << "====================" << std::endl;
+			std::cout << i.buy.dump() << std::endl;
+			std::cout << "----------------------------------------------" << std::endl;
+		}
+
+		printf("Sleeping...\n");
+		sleep(5);
+	}
+
 	return 0;
 }
-- 
Alviro Iskandar Setiawan


  parent reply	other threads:[~2024-09-10 21:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 21:44 [RFC PATCH 0/9] Introducing GNU/Weeb Arbitrage Opportunity Notification Bot Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 2/9] gwarnt: Create initial P2P ad data structure Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 3/9] gwarnt: p2p: Add P2P Binance Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 4/9] gwarnt: p2p: Add P2P OKX Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 5/9] gwarnt: Create function to find arbitrage opportunities Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 6/9] gwarnt: p2p/binance: Fix invalid page Alviro Iskandar Setiawan
2024-09-10 21:44 ` Alviro Iskandar Setiawan [this message]
2024-09-10 21:44 ` [RFC PATCH 8/9] gwarnt: Add README file Alviro Iskandar Setiawan
2024-09-10 21:44 ` [RFC PATCH 9/9] gwarnt: Add Telegram bot Alviro Iskandar Setiawan
2024-09-10 22:21 ` [RFC PATCH 0/9] Introducing GNU/Weeb Arbitrage Opportunity Notification Bot Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240910214414.3401712-8-alviro.iskandar@gnuweeb.org \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox