[ENG/ITA] Earning HIVE Thanks to My Scripts: Bridges Arbitrage and Grid Trading


La versione italiana si trova sotto quella inglese

The italian version is under the english one


Earning HIVE Thanks to My Scripts: Bridges Arbitrage and Grid Trading

Programming, for me, is nothing more than a hobby.

I wish it weren't like that. I wish I were better at it and could work in the programming world, but the truth is I didn't follow the right studies, and I don't have the time now to pursue a completely different path from the one I've followed so far. A part of me would love to, but it would almost certainly be madness.

That's why my Python projects will always be amateurish, simple, and – in the eyes of a real programmer – probably ugly and poorly designed... but ultimately, if I'm coding just for fun, why should I care if what I create is little more than a toy?

And the answer is: I don’t. If the scripts I write do what I created them for, they entertain me, and give me small satisfactions, that’s good enough for me.

Also because lately, some of the projects I've worked on over the past months have shown me that you can achieve something even with little: I used to think that without great skills, abilities, and knowledge it was impossible to create something useful... but I was wrong.

And in this post, I’d like to focus on one topic in particular — one that, until not long ago, I thought was completely beyond my abilities — namely, earning money thanks to my scripts.

How can I earn anything if I just said I’ll never be able to get a job as a programmer because I don’t have the necessary skills?

Well, lately I discovered that, in some way, I can!


Bridging arbitrage

What proved to me that I could earn something thanks to my scripts is a project I already mentioned here, specifically the one about arbitraging the bridges that connect HIVE with SWAP.HIVE, taking advantage of the fact that, under certain conditions, it’s possible to generate a positive fee, thus making a profit.

The script I created uses all my liquid HIVE to perform operations of this type through the @liquid.wolf account: over the ~15 days this project has been running, I’ve made a profit of almost 200 HIVE, plus over 5.8 BXT – a token I talked about here.



initially @liquid.wolf had 1695 HIVE and 0 BXT available

This event, in a way, opened my eyes, because it showed me that even with basic knowledge like mine, it’s possible to create scripts that generate a profit.

A little voice in my head even started wondering: what if I managed to create dozens of scripts like this one?


Grid trading

And that brings us to the second project I wanted to talk about today, the one I’m developing based on an idea from @bencwarmer and inspired by what @hoosie used to do — namely, trying to take advantage of price fluctuations in HIVE to do something that, according to ChatGPT, is called grid trading.

def place_orders(account, nodes, session: requests.Session, diff, trades, amount, market, lowest, highest):
    for _ in range(trades):
        hive, hbd = get_balances(account, nodes, session)
        print(f"Balances available: {hive} HIVE and {hbd} HBD")

        if float(hbd) > amount:
            sell_price = round(highest + diff * highest / 100, 4)
            print("Looking to sell HBD...")

            sell = place_sell_order(
                account, sell_price, amount, market
            )  # Buy HIVE, sell HBD
            time.sleep(3)

        if float(hive) > amount * lowest:
            buy_price = round(lowest - diff * lowest / 100, 4)
            print("Looking to sell HIVE...")

            buy = place_buy_order(
                account, buy_price, amount, market
            )  # Sell HIVE, buy HBD
            time.sleep(3)

        diff += 1

a snippet of the code

The idea is to convert HIVE into HBD when the price goes up, and HBD into HIVE when the price drops, using very small increments/decrements and canceling older orders when they become too far from the current price.

This script is also already active, although not fully yet, because I’m still fine-tuning it and currently launch it manually when I want to run tests.

I still need to implement, for example, a system to keep track of completed operations, so I can automatically calculate whether the script is generating a profit or not.

In this project, the goal isn’t so much to find a second way to earn right now, but to improve my skills in trading: if I manage to create a solid, reliable, and functional script, I could then look for simpler opportunities to apply what I’ve learned and see if I can generate another small passive income.

There’s a 99% chance I’ll never work as a programmer — but who knows, maybe one day my own scripts will work for me :)


cover made with Bing AI and edited with GIMP

to support the #OliodiBalena community, @balaenoptera is 3% beneficiary of this post


If you've read this far, thank you! If you want to leave an upvote, a reblog, a follow, a comment... well, any sign of life is really much appreciated!


Versione italiana

Italian version


Guadagnare HIVE Grazie ai miei Scripts: Arbitraggio dei Bridges e Grid Trading

Programmare per me è niente più che un hobby.

Vorrei che non fosse così, vorrei essere più bravo e poter lavorare nel mondo della programmazione, ma la verità è che non ho fatto gli studi giusti e non ho il tempo per provare adesso ad inseguire una strada completamente diversa da quella che ho percorso finora. Una parte di me vorrebbe, ma sarebbe quasi sicuramente una follia.

Per questo i miei lavori in Python saranno sempre amatoriali, semplici e - agli occhi di un vero programmatore - pure brutti e poco funzionali... ma tutto sommato, se devo programmare solo per divertimento, alla fine cosa mi importa se ciò che creo è poco più di un gioco?

E' la risposta infatti è "nulla". Se gli script che scrivo fanno ciò per cui li ho creati, mi fanno divertire e mi danno delle piccole soddisfazioni, a me sta bene.

Anche perchè ultimamente alcuni dei progetti a cui ho lavorato in questi mesi mi hanno dimostrato che anche con poco si può ottenere qualcosa: pensavo che senza aver grandi capacità, abilità e conoscenze fosse impossibile creare qualcosa di utile... ma mi sbagliavo.

E in questo post vorrei focalizzarmi su un argomento in particolare, uno che di base, per quello che pensavo fino a poco tempo, sarebbe dovuto essere completamente al di là delle mie capacità, ossia guadagnare grazie ai miei scripts.

Come posso infatti guadagnare se ho detto sopra che non potrò mai trovare un lavoro come programmatore, dato che non ho le necessarie competenze?

Be', in quest'ultimo periodo ho scoperto che, in qualche modo, posso!


Arbitrare i bridges

Ciò che mi ha dimostrato che posso guadagnare qualcosa grazie ai miei scripts è un progetto di cui vi avevo già parlato qua, ed in particolare quello che riguarda la possibilità di arbitrare i bridges che collegano HIVE con SWAP.HIVE, sfruttando il fatto che, in determinate condizioni, sia possibile generare una commissione positiva, ottenendo così un guadagno.

Lo script che ho creato utilizza tutti i miei HIVE liquidi per compiere operazioni di questo tipo tramite l'account @liquid.wolf: nei circa 15 giorni di attività di questo progetto ho ottenuto un guadagno di quasi 200 HIVE, oltre 5.8 BXT - un token di cui vi ho parlato qua.



inizialmente @lqiuid.wolf aveva disponibili 1695 HIVE e 0 BXT

Si tratta di un evento che, in un certo senso, mi ha aperto gli occhi, perchè mi ha dimostrato che, anche con conoscenze basiche come le mie, è possibile creare degli scripts che possano generare un guadagno.

Una piccola vocina nella testa ha anche cominciato a chiedersi: e se riuscissi a creare decine di script come questo?


Grid trading

E passiamo così al secondo progetto di cui volevo parlarvi oggi, quello che sto sviluppando sulla base di un'idea di @bencwarmer ed ispirandomi a quello che faceva un tempo @hoosie, ossia cercare di sfruttare le oscillazioni nel prezzo di HIVE per fare una cosa che, secondo ChatGPT, si chiama grid trading.

def place_orders(account, nodes, session: requests.Session, diff, trades, amount, market, lowest, highest):
    for _ in range(trades):
        hive, hbd = get_balances(account, nodes, session)
        print(f"Balances available: {hive} HIVE and {hbd} HBD")

        if float(hbd) > amount:
            sell_price = round(highest + diff * highest / 100, 4)
            print("Looking to sell HBD...")

            sell = place_sell_order(
                account, sell_price, amount, market
            )  # Buy HIVE, sell HBD
            time.sleep(3)

        if float(hive) > amount * lowest:
            buy_price = round(lowest - diff * lowest / 100, 4)
            print("Looking to sell HIVE...")

            buy = place_buy_order(
                account, buy_price, amount, market
            )  # Sell HIVE, buy HBD
            time.sleep(3)

        diff += 1

un estratto del codice

L'idea sarebbe quella di convertire HIVE in HBD quando il prezzo sale e HBD in HIVE quando il prezzo scende, prevedendo incrementi/decrementi molto piccoli e cancellando gli ordini più vecchi quando cominciano ad essere troppo lontani dal prezzo attuale.

Anche questo script è già operativo, anche se ancora non completamente, perchè lo sto rifinendo e per ora lo lancio quando voglio fare dei test.

Devo ad esempio ancora implementare un sistema che tenga traccia delle operazioni completate, così da poter calcolare in automatico se lo script sta generando un guadagno o meno.

Nel caso di questo progetto la speranza non è tanto quello di trovare di già un secondo modo per guadagnare, quanto quella di affinare le mie capacità nell'ambito del trading: se riuscirò a creare uno script solido, affidabile e funzionante, potrei infatti poi cercare occasioni più semplici da sfruttare per mettere in pratica quanto imparato e vedere se riesco a generare un'altra piccola rendita passiva.

Al 99% non lavorerò mai come programmatore, ma chissà che un giorno non possano essere i miei stessi scripts a lavorare per me :)


cover realizzata con Bing AI ed editata con GIMP

a supporto della community #OliodiBalena, il 3% delle ricompense di questo post va a @balaenoptera

Se sei arrivato a leggere fin qui, grazie! Se hai voglia di lasciare un upvote, un reblog, un follow, un commento... be', un qualsiasi segnale di vita, in realtà, è molto apprezzato!

Posted Using INLEO

0.14130901 BEE
7 comments

Fidati che non vuoi fare il programmatore 😂 rotture di palle sabato e domenica, reperibilità, interventi serali perché è URGENTE e devi sempre essere pronto a dare supporto, trasferte in giro... Meglio l'amministrativo, poi non so che lavoro fai attualmente tu

Comunque 200 hive in 2 settimane mi sembra ottimo, meglio che fare post 😅

0.00000244 BEE

Probabilmente infatti io mi immagino il lavoro del programmatore in modo sbagliato 🤣 è che l'idea di lavorare in smart working per una società straniera sembra così allettante, soprattutto rispetto al passare le giornate chiuso in un ufficio dalle 9 alle 19... poi più che altro io faccio un lavoro che non mi appassiona, per cui mi piace sognare come sarebbe farne uno che mi piace (anche se non è detto mi piacerebbe, perchè un conto è programmare per divertimento, un conto farlo per lavoro, con scadenze e richieste imposte da altri).

Comunque 200 hive in 2 settimane mi sembra ottimo, meglio che fare post 😅

Credo che la presale e l'inizio della generale sale di Conclave Arcana possano avere inciso sui volumi di scambio di queste ultime settimane: mi aspetto che i guadagni non siano così alti in futuro (anche se sarei felice di sbagliarmi ahaahah).

7E-8 BEE

Haha eh ma poi con le grandi aziende anche straniere hai le scadenze da rispettare, ti tocca fare straordinari e lavorare sempre extra orario... Ti dirò, a me fa schifo il mio lavoro da programmatore ma ormai è così 😂 i soldi devono arrivare da qualche parte alla fine

0E-8 BEE

Ammazza, sei bravo. Noi l'anno scorso abbiamo investito in un robottino che faceva la stessa cosa ma sfruttando le piccole oscillazioni euro dollaro. Ci ha dato una piccola soddisfazione. Poi purtroppo il progetto si è concluso.
@barnabo73 leggi qua, è molto interessante
!LOLZ

0.00000253 BEE

My girlfriend left me because of my obsession with storytelling.
I wonder how the next chapter in my life will go.

Credit: reddit
@arc7icwolf, I sent you an $LOLZ on behalf of sissim72

(2/6)

PLAY & EARN $DOOM

0E-8 BEE

Magari fossi bravo! Diciamo che ci acchiappo qualcosa e almeno riesco a togliermi la soddisfazione di vedere qualcuno dei miei progetti funzionare, ogni tanto 🤣

sfruttando le piccole oscillazioni euro dollaro

Se questo script funzionasse e si dimostrasse affidabile, la coppia euro-dollaro sarebbe sicuramente molto interessante da esplorare, visto che tende ad avere un rapporto stabile per periodi prolungati di tempo. Peccato solo che in ambito crypto ci siano pochissime stablecoins ancorate all'euro, per cui probabilmente avrei qualche difficoltà nel farlo (mentre al di fuori dell'ambito delle crypto non saprei nemmeno da dove iniziare... !LOL).

0.00008650 BEE

Why was an insomniac shot by the police?
He was resisting a rest.

Credit: reddit
@sissim72, I sent you an $LOLZ on behalf of arc7icwolf

(2/10)
Delegate Hive Tokens to Farm $LOLZ and earn 110% Rewards. Learn more.

0E-8 BEE

Temo di averti scatenato Barnabo. Perdonami!!! Sta infoiato con Pyton!
!LOLZ

5E-8 BEE

E lo script che dà i numeri vincenti del SuperEnalotto? 😜

!LOLZ

Sempre all'opera!!! Complimenti!!! 💪🏻

0.00000240 BEE

What did the mayonnaise say to the icebox?
Close the door, I am dressing.

Credit: reddit
@arc7icwolf, I sent you an $LOLZ on behalf of bencwarmer

(1/10)
NEW: Join LOLZ's Daily Earn and Burn Contest and win $LOLZ

0E-8 BEE

Già se questo funzionasse non sarebbe male, mi accontento per ora 🤣

!LOL

0E-8 BEE

Did you hear about the happy Roman?
He was gladiator.

Credit: reddit
@bencwarmer, I sent you an $LOLZ on behalf of arc7icwolf

(1/10)
NEW: Join LOLZ's Daily Earn and Burn Contest and win $LOLZ

0E-8 BEE

200 Hive in 15 giorni! Wow, mica male! Complimenti!

0.00000230 BEE

Probabilmente il rilascio di Conclave Arcana ha inciso parecchio, perchè c'erano grossi spostamenti di denaro da Hive ad Hive-Engine e viceversa: mi aspetto un calo da ora in poi... anche se vorrei tanto sbagliarmi ed aver trovato una piccola miniera d'oro 🤣

0E-8 BEE

You'd be surprised how many people go to uni for this shit, finish, and can not do what you are doing now.

I takes a certain kind of thinking to start from scratch and build a program. Most people could not do it.

Additionally, it takes focus.
People who struggle to focus on single problems, or to sit down to think, can't do it either. I think this is the main ability: sit down to code for a long time.

Thinking you are behind the curve because you don't know some algorithms and theory... In times of AI? You'd catch up within 1 year.

That all being said, programming as a career is ass.

0.00000228 BEE

Solving problems and focusing to find a solution is what makes me love programing! I love thinking on how I can solve, or improve, something: for me the challenge of finding a solution, trying to think outside the box, is the most satisfying part of programing.

Thinking you are behind the curve because you don't know some algorithms and theory

And talking about that, recently I was planning to give a (re)read at some of your posts, to see if I have acquired some of the skills need to better understand them :)

That all being said, programming as a career is ass.

My issue is that I already to a job which I don't like... so I can't help but ask myself how would be to do something different... and at least programing looks as something I may like doing even as a job (even if this might not be true, lol, as I have only a very vague idea on what a programer do!).

0E-8 BEE

And talking about that, recently I was planning to give a (re)read at some of your posts, to see if I have acquired some of the skills need to better understand them :)

Could be my fault.

If you continue the Python path and try building more things for web, the shit I wrote will make sense (I hope).
Have you encountered callback functions, yet?
It's that but... for real Gs.
I guess I jumped a few steps too far ahead...

0.00000236 BEE

Interessante, grazie!
Lo script immagino tu lo faccia girare su un computer locale... Mac o Windows?
hai per caso il codice di get_balances(account, nodes, session)?
E.... come conservi le chiavi di accesso?
Grazie

0.00000228 BEE

get_balances è una funzione delle api di hive, se non erro...

0E-8 BEE

Uso Windows, principalmente perchè ho sempre e solo usato quello, per cui se uno mi mette davanti un computer con Mac o Linux vado in tilt 🤣

Quando, e se, arriverò alla fase in cui lo script dovrà operare autonomamente, allora utilizzerò Github Actions per hostarlo, in modo non dover tenere una (mia) macchina sempre accesa.

come conservi le chiavi di accesso?

Per ora sono hardocoded nel codice (in barba a qualsiasi best practice in materia di sicurezza), ma appena lo renderò operativo ed autonomo utilizzerò la funzione "Secrets" di Github, che funziona in maniera simile (per il poco che ci capisco) all'utilizzo di un file .env.

hai per caso il codice di get_balances(account, nodes, session)?

Eccolo qua, con sotto anche get_response, che è la funzione che si interfaccia con le API di Hive:

def get_balances(account, nodes, session: requests.Session):
    data = (
        f'{{"jsonrpc":"2.0", "method":"condenser_api.get_accounts", '
        f'"params":[["{account}"]], "id":1}}'
    )
    result = get_response(data, nodes, session)
    return result[0]["balance"].split()[0], result[0]["hbd_balance"].split()[0]
def get_response(data, nodes, session: requests.Session):
    for node in nodes:
        response = session.post(node, data=data)

        if response.status_code == 502:
            continue

        result = response.json().get("result", [])

        if result or result == []:
            return result

        print(f"Error: Status Code: {response.status_code}")

get_balances è una funzione delle api di hive, se non erro...

Se c'era mi è sfuggita: nel mio codice io ho utilizzato get_accounts dell'API Condenser, che contiene varie informazioni sull'account selezionato, incluso l'ammontare di HIVE e HBD che possiede.

get_balances nel mio script è quindi solo una funzione personalizzata creata da me per costruire la prima parte della richiesta.

1.4E-7 BEE

grazie mille!

Ancora una domanda, scusa...
Il codice seguente, se ho capito bene, crea un ordine di vendita di Hive al prezzo sell_price.

sell_price = round(highest + diff * highest / 100, 4)
place_sell_order(account, sell_price, amount, market)

Se il prezzo dell'hive è più basso round(highest + diff * highest / 100, 4), viene chiamata lo stesso la funzione 'place_sell_order', ma l'ordine non viene eseguito, mentre se l'hive è maggiore di round(highest + diff * highest / 100, 4), l'ordine viene eseguito e gli hive vengono venduti (cioè convertiti in Hbd).

Ho capito bene la logica?

Grazie!

0E-8 BEE

Congratulations @arc7icwolf! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You got more than 24000 replies.
Your next target is to reach 24500 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0E-8 BEE