Use pyopenbook, add fills for spot
This commit is contained in:
parent
c8191a0bbe
commit
8980ec2017
|
@ -7,3 +7,5 @@ build
|
|||
dist/*
|
||||
scratch.txt
|
||||
mango_explorer_v4/examples/scratch.py
|
||||
.github
|
||||
.vscode
|
||||
|
|
|
@ -23,10 +23,8 @@ async def main():
|
|||
|
||||
mango_client = await MangoClient.connect()
|
||||
|
||||
response = await mango_client.fills(args.symbol)
|
||||
print(await mango_client.fills(args.symbol))
|
||||
|
||||
for fill in response['fills']:
|
||||
print(fill)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -2,6 +2,7 @@ import asyncio
|
|||
|
||||
from mango_explorer_v4.mango_client import MangoClient
|
||||
|
||||
|
||||
async def main():
|
||||
mango_client = await MangoClient.connect()
|
||||
|
||||
|
|
|
@ -592,7 +592,29 @@ class MangoClient():
|
|||
|
||||
match market_type:
|
||||
case 'spot':
|
||||
raise NotImplementedError("Spot markets fills retrieval isn't implemented yet")
|
||||
serum_market_config = [
|
||||
serum3_market_config for serum3_market_config in self.group_config['serum3Markets']
|
||||
if serum3_market_config['name'] == symbol
|
||||
][0]
|
||||
|
||||
serum_market_index = serum_market_config['marketIndex']
|
||||
|
||||
serum_market: Serum3Market = [
|
||||
serum_market
|
||||
for serum_market in self.serum_markets
|
||||
if serum_market.market_index == serum_market_index
|
||||
][0]
|
||||
|
||||
serum_market_external: AsyncMarket = [
|
||||
serum_market_external
|
||||
for serum_market_external in self.serum_markets_external
|
||||
if serum_market_external.state.public_key() == serum_market.serum_market_external
|
||||
][0]
|
||||
|
||||
return {
|
||||
'symbol': symbol,
|
||||
'fills': [fill._asdict() for fill in await serum_market_external.load_fills(9999)]
|
||||
}
|
||||
case 'perpetual':
|
||||
perp_market_config = [perp_market_config for perp_market_config in self.group_config['perpMarkets'] if perp_market_config['name'] == symbol][0]
|
||||
|
||||
|
@ -1115,10 +1137,7 @@ class MangoClient():
|
|||
if serum_market.market_index == serum_market_index
|
||||
][0]
|
||||
|
||||
try:
|
||||
serum3 = [serum3 for serum3 in mango_account.serum3 if serum3.market_index == serum_market_index][0]
|
||||
except IndexError as error:
|
||||
print(error)
|
||||
serum3 = [serum3 for serum3 in mango_account.serum3 if serum3.market_index == serum_market_index][0]
|
||||
|
||||
serum_market_external = [
|
||||
serum_market_external
|
||||
|
|
|
@ -705,22 +705,6 @@ pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2"
|
|||
format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"]
|
||||
format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"]
|
||||
|
||||
[[package]]
|
||||
name = "mangopyserum"
|
||||
version = "0.6.0a0"
|
||||
description = "Python client library for interacting with the Project Serum DEX."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7, <4"
|
||||
files = [
|
||||
{file = "mangopyserum-0.6.0a0-py3-none-any.whl", hash = "sha256:a3991b423ffafbacc1961324085e0b979f4e2ce906b8403eb9d3a05b5ffde3da"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
construct = ">=2.10.56,<3.0.0"
|
||||
construct-typing = ">=0.5.1,<1.0.0"
|
||||
solana = ">=0.11.3,<1.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "matplotlib-inline"
|
||||
version = "0.1.6"
|
||||
|
@ -1085,6 +1069,23 @@ cffi = ">=1.4.1"
|
|||
docs = ["sphinx (>=1.6.5)", "sphinx-rtd-theme"]
|
||||
tests = ["hypothesis (>=3.27.0)", "pytest (>=3.2.1,!=3.3.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pyopenbook"
|
||||
version = "0.7.3a0"
|
||||
description = "Python client library for interacting with the Project Serum DEX."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7, <4"
|
||||
files = [
|
||||
{file = "pyopenbook-0.7.3a0-py3-none-any.whl", hash = "sha256:414c964fa84ac22cce413557bad11a2371552bd6499f557855a6b571ad94082f"},
|
||||
{file = "pyopenbook-0.7.3a0.tar.gz", hash = "sha256:2c49e21b1139be04fc3f57e48bc90f0f7424a43b7427150e6ecfadda5e58aac1"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
construct = ">=2.10.56,<3.0.0"
|
||||
construct-typing = ">=0.5.1,<1.0.0"
|
||||
solana = ">=0.11.3,<1.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "pyrsistent"
|
||||
version = "0.19.2"
|
||||
|
@ -1607,4 +1608,4 @@ cffi = ["cffi (>=1.11)"]
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "dda619f997625c18b83a3c34983aa10eee1815bb2266da2514c4bbcc41b0b8f9"
|
||||
content-hash = "fdfe1eb21980144895b5d9367fc5f8d9146f92eccb05ba64ffbf140c5ab4e5bd"
|
||||
|
|
|
@ -90,9 +90,9 @@ urllib3 = "1.26.13"
|
|||
wcwidth = "0.2.5"
|
||||
websockets = "10.4"
|
||||
zstandard = "0.17.0"
|
||||
mangopyserum = "^0.6.0a0"
|
||||
sortedcontainers = "^2.4.0"
|
||||
aiostream = "^0.4.5"
|
||||
pyopenbook = "^0.7.3a0"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
|
Loading…
Reference in New Issue