Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SirSevenG/libmarketmaker
Python3 library to proxy marketmaker2 rp calls.
https://github.com/SirSevenG/libmarketmaker
Last synced: 25 days ago
JSON representation
Python3 library to proxy marketmaker2 rp calls.
- Host: GitHub
- URL: https://github.com/SirSevenG/libmarketmaker
- Owner: SirSevenG
- License: mit
- Created: 2019-10-14T09:55:52.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-30T21:52:07.000Z (over 4 years ago)
- Last Synced: 2024-08-04T05:01:47.955Z (4 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-komodefi - SirSeven's libmarketmaker
README
# libmarketmaker
Python3 library to proxy marketmaker2 rp calls.This lib intended to be used in python-based applications,
if you need python mm2 interface for personal usage, check smk'762s PytomicDEX:
https://github.com/smk762/pytomicDEXAPI reference: https://developers.atomicdex.io/basic-docs/atomicdex/atomicdex-api.html
## Variants:
`mm2_rpclib_req` based on requests library https://requests.kennethreitz.org/en/master/
Deps:
pip install requests ujson
`mm2_rpclib_curl` based on slick-bitcoinrpc https://github.com/barjomet/slick-bitcoinrpc
Deps:
pip install ujson pycurl itertools
or
pip install slick-bitcoinrpc### Usage example:
```python
from mm2rpclib_req import MarketMaker2Proxy
host = {
'userpass': 'yyVdXlv1sdcmEhd9',
'rpchost': '95.217.236.53',
'rpcport': 7783
}
proxy = MMProxy(host)
proxy.version()
```RPC params should be passed as **kwargs:
```shell script
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"KMD\",\"rel\":\"BTC\"}
```Will be:
```python
proxy.orderbook(base='KMD', rel='BTC')
```All RPC methods will return dictionary with server's response,
errors are returned as is, AE:```python
coin = 'KMD' # str
electrum_url = "example.domain.net:0000" # domain:port
r = proxy.electrum(coin=coin, servers=[{'url': electrum_url, 'protocol': 'TCP'}], mm2='1')
print(r)
print(type(r))
r = proxy.electrum(coin=coin, servers=[{'url': electrum_url, 'protocol': 'TCP'}], mm2='1')
print(r)
print(type(r))
``````text
{'address': '0000000000000000000000000000000000', 'balance': '0', 'coin': 'KMD',
'locked_by_swaps': '0', 'required_confirmations': 1, 'result': 'success'}
{'error': 'rpc:339] lp_commands:85] lp_coins:643] Coin KMD already initialized'}
```### Batch requests:
Batch requests should be passed as dictionary via batch() method.
Example to batch 10 identical setprice calls:
```python
req = {
"method": "setprice", "base": base, "rel": rel, "price": price, "volume": volume, "cancel_previous": False
}
rec_d = {}
for i in range(10):
rec_d.update({str(i): req})
res = proxy.batch(**rec_d)
```