[암호화폐] 그것이 알고싶다!! steem-engine order book 그리고 LP 준비

in #sct7 years ago (edited)

steem-engine에 나오는 마켓의 order book을 읽는 방법을 알아봅니다. 관련 소스는 @holgern의 github를 참고하였습니다[1].

API를 잘 만들어 놓아서 파이썬을 조금만 알면 누구나 조회가 가능합니다.

우선 order 북의 buy와 sell 내역을 확인해봅시다. 편의상 최근 5개만 출력을 합니다.

    rets = api.find("market", "buyBook", {'symbol':'SCT'})
    print("=== buy ===")
    cnt = 0
    for ret in rets :
        try:
            print(format(float(ret['price']), "2.5f"), format(float(ret['quantity']), "0.4f"))
            cnt += 1
            if (cnt > 5):
                break
        except Exception as ex :
            print (ret)

    rets = api.find("market", "sellBook", {'symbol':'SCT'})
    print("=== sell ===")
    cnt = 0
    for ret in rets :
        try:
            print(format(float(ret['price']), "2.5f"), format(float(ret['quantity']), "0.4f"))
            cnt += 1
            if (cnt > 5):
                break
        except Exception as ex :
            print (ret)

그 결과는 아래와 같습니다.

현재 order 북 내용과 일치함을 알 수 있습니다. 그런데 순서는 조금 차이가 나는군요. 이런 경우에는 price로 소팅을 해서 사용하면 됩니다.

order 북에 등록된 내용은 아래 구조로 전달이 됩니다.

구조에 대한 설명은 필요가 없을 만큼 단순합니다. 다만 해당 거래를 등록한 account까지 나오기 때문에 개인 정보가 너무 노출되는 문제가 있습니다만, 블록체인의 특성상 어쩔 수 없을 것 같습니다.


최근에 거래가 된 내역도 알면 좋겠죠. 거래 빈도와 추이를 보면 자동 매매도 가능할 수 있습니다. 이것도 명령어 한 줄이면 가능합니다. 편의상 최근 5개만 출력해봅니다.

    rets = api.find("market", "tradesHistory", {'symbol':'SCT'})
    print("=== history ===")
    cnt = 0
    for ret in rets :
        try:            
            if (ret['type'] =='sell') :
                print ("sell", format(float(ret['price']), ".4f"), format(float(ret['quantity']), ".2f"))
            else :
                print ("buy ", format(float(ret['price']), ".4f"), format(float(ret['quantity']), ".2f"))
            cnt += 1
            if (cnt > 10):
                break
        except Exception as ex :
            print (ret)

그 결과도 같습니다.


거래 물량이 많지 않기 때문에 자동 매매를 적용하기는 어렵고, LP 공급자로서의 역할은 할 수 있을 것 같습니다. LP 제공자 관련 작업을 한 후 적용을 해 보도록 하겠습니다.

[1] https://github.com/holgern/steemengine

Sort:  

jcar토큰 7월 보팅입니다. 날마다 좋은 날 되세요. ^^

오오 LP라.. 대단하십니다. SCT는 호가갭이 커서 LP가 리스크는 좀 있겠지만 대신 수익률도 좋을 것 같아요.

그런데 매수하시는 분들이 불만이 있으실 것 같아서 조금 걱정이군요. 아무래도 LP가 있으면 매수 호가가 계속 올라갈테니까요.

Thank you for your continued support towards JJM. For each 1000 JJM you are holding, you can get an additional 1% of upvote. 10,000JJM would give you a 11% daily voting from the 700K SP virus707 account.

Hi @tradingideas!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 3.575 which ranks you at #5708 across all Steem accounts.
Your rank has improved 19 places in the last three days (old rank 5727).

In our last Algorithmic Curation Round, consisting of 159 contributions, your post is ranked at #87.

Evaluation of your UA score:
  • You're on the right track, try to gather more followers.
  • The readers like your work!
  • You have already shown user engagement, try to improve it further.

Feel free to join our @steem-ua Discord server

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.081
BTC 61644.63
ETH 1604.36
USDT 1.00
SBD 0.47