Commit Graph

234 Commits

Author SHA1 Message Date
Geoff Taylor 7cfc1b76ba Added more logging to watch-minimum-balances. 2021-07-30 17:41:15 +01:00
Geoff Taylor d3b0c48528 Marketmaker now automatically creates required Spot OpenOrders if it doesn't exist. 2021-07-30 15:41:47 +01:00
Geoff Taylor e721d6c8e8 Improved Group and Account output. Tied OpenOrders and PerpOpenOrders together with a PlacedOrdersContainer protocol. 2021-07-29 16:19:52 +01:00
Geoff Taylor c0f2a57938 Fixed error notification problem in watch-minimum-balances. 2021-07-28 19:07:57 +01:00
Geoff Taylor 0aa28d6eef Updated error message to make source of hedge errors clearer. 2021-07-28 17:50:57 +01:00
Geoff Taylor ab3657958d Added hedger command. Had to introduce a LotSizeConverter - may expand its use now it's available. 2021-07-28 17:43:58 +01:00
Geoff Taylor 373392cf78 Updated place_order() method to take an Order instead of separate parameters. 2021-07-28 15:29:24 +01:00
Geoff Taylor d7f117175f Changed RX subscribe_on to observe_on. 2021-07-28 12:52:29 +01:00
Geoff Taylor 7bbe476b2e Fixed watch-minimum-balance threading problems. 2021-07-28 12:31:35 +01:00
Geoff Taylor ac25b08668 Removed max charge from ConfidenceIntervalDesiredOrdersBuilder, added a confidence weight to allow tuning aggressiveness. 2021-07-28 11:05:52 +01:00
Geoff Taylor d739248ec6 Better handling of unseen events in PerpEventQueue. 2021-07-27 21:49:27 +01:00
Geoff Taylor bf7b7e33ef Added file health check to watch-minimum-balances. 2021-07-27 17:21:18 +01:00
Geoff Taylor 7dc86a4e1a Added watch-minimum-balances command. 2021-07-27 17:07:39 +01:00
Geoff Taylor c874b83221 Can now explicitly pick Pyth oracle on mainnet-beta or devnet. 2021-07-26 18:07:56 +01:00
Geoff Taylor 38b08bdb6d Removed spread-ratio parameter from marketmaker. 2021-07-26 15:57:38 +01:00
Geoff Taylor f3546ee217 Added ConfidenceIntervalDesiredOrdersBuilder. 2021-07-26 15:47:57 +01:00
Geoff Taylor 3b23f7e4e7 Added 'confidence' to oracles so marketmaker could access Pyth confidence intervals. 2021-07-26 13:42:03 +01:00
Geoff Taylor 072252095a Some work on streaming logs and account/program events. 2021-07-26 12:19:13 +01:00
Geoff Taylor eb244a2167 Renamed PerpMarket to PerpMarketDetails, and PerpsMarket to PerpMarket to be consistent with SerumMarket and SpotMarket. Improved market stub handling. 2021-07-23 14:18:26 +01:00
Geoff Taylor 8fe48de527 Moved functionality into *Market objects. 2021-07-23 10:20:44 +01:00
Geoff Taylor 7ddc61a3e3 Fixed linting problems. 2021-07-22 15:58:00 +01:00
Geoff Taylor c953ec07fc Added Perp cranking code, plus program. Expanded watch-address, added complementary show-address command. 2021-07-22 15:18:37 +01:00
Geoff Taylor 2f6c3088ef Added token output on launching marketmaker. 2021-07-21 18:25:44 +01:00
Geoff Taylor 000040f678 Fixed return value. 2021-07-21 16:37:47 +01:00
Geoff Taylor 817b31f8ea Added a streaming watcher for some account types. 2021-07-21 16:35:38 +01:00
Geoff Taylor c11aececd9 Fixed Serum cranking to be more complete. 2021-07-21 14:31:04 +01:00
Geoff Taylor 0166b5e371 MarketMaker now takes an optional OrderType parameter. 2021-07-20 10:24:05 +01:00
Geoff Taylor c5cd5ca095 MarketMaker now exits cleanly on Control-C (SIG_TERM). 2021-07-19 15:14:00 +01:00
Geoff Taylor 94df52003b Changes for devnet group v3.8.
* Some struct/layout changes
* Big changes to OpenOrders handling in MarketMaker
* Serum and Spot settlement should now work as expected
2021-07-19 15:04:53 +01:00
Geoff Taylor 5a4022b236 Wrapping SOL now creates a proper Associated Token Account if no Wrapped SOL accounts are available. 2021-07-16 18:59:19 +01:00
Geoff Taylor 3fd7e27138 Removed some debug output. 2021-07-16 17:31:25 +01:00
Geoff Taylor 30d4b01a37 Moved SimpleMarketMaker to its own directory+package. 2021-07-16 17:29:48 +01:00
Geoff Taylor 3b588b32a9 Implemented a better error message for incorrect market assumptions. 2021-07-16 17:24:55 +01:00
Geoff Taylor 040eadcb90 Made marketmaker a bit more configurable, and it now publishes pulse completion and errors. 2021-07-16 14:26:42 +01:00
Geoff Taylor 3ca1d7b706 Updated to new ids.json. Added deposit instruction+command. 2021-07-16 13:32:30 +01:00
Geoff Taylor 436237a949 Fixed linting problems. 2021-07-16 11:54:13 +01:00
Geoff Taylor 7db8326a7c More realistic market-maker is now available. 2021-07-15 21:03:22 +01:00
Geoff Taylor 9f99ecf650 Updated SimpleMarketMaker so it could run well against pure Serum markets. 2021-07-14 14:03:51 +01:00
Geoff Taylor 19e4d948d3 Updates to allow some market making on Serum. 2021-07-13 20:01:32 +01:00
Geoff Taylor 82405cfec1 Updated Serum and Spot instructions builders to properly crank and settle. 2021-07-12 20:29:41 +01:00
Geoff Taylor 80886c106c All MarketOperations now properly use their equivalent MarketInstructionBuilder for building instructions. 2021-07-12 18:26:35 +01:00
Geoff Taylor 6a15c81fa3 New approach to transactions allowing them to be split up.
* CombinableTransactions now separated out.
* CombinableTransactions are now size-aware when being executed, and will automatically split into batches for execution if they are too big.
* New MarketInstructionBuilder approach - each market type can now have its own way of building instructions for common operations.
2021-07-12 17:18:56 +01:00
Geoff Taylor faf514cde1 Brought up to date for new Group structures. New websocket approach. 2021-07-12 10:57:05 +01:00
Geoff Taylor fa28fe4209 Fixed problem fetching transactions for report. Reversed order of output of transactions so it appears better in notifications. 2021-07-07 19:59:27 +01:00
Geoff Taylor 6977d632b0 Fixed problem fetching transactions for report. Reversed order of output of transactions so it appears better in notifications. 2021-07-07 19:58:28 +01:00
Geoff Taylor 79a13f0e06 Report transactions now insists on a report.state file, and reads from it now instead of taking a separate parameter. 2021-07-07 15:06:24 +01:00
Geoff Taylor fb874dae94 Report transactions now insists on a report.state file, and reads from it now instead of taking a separate parameter. 2021-07-07 15:02:57 +01:00
Geoff Taylor 12c07cab7e Added target address to transaction report output. 2021-07-07 12:28:50 +01:00
Geoff Taylor d794326f14 Added target address to transaction report output. 2021-07-07 12:21:31 +01:00
Geoff Taylor 9d4c644950 Added success/failure indicator to report-transactions summary. 2021-07-02 11:05:37 +01:00
Geoff Taylor 8b849859a7 Added success/failure indicator to report-transactions summary. 2021-07-02 10:42:29 +01:00
Geoff Taylor bf675122ac Updated ids.json for new group. Updated Group with new structure.
* Extended mechanism for combining instructions.
* Fixed Account's calculations of deposits and borrows.
* Added net_assets to Account.
* Groups now maintain loaded RootBanks, not just PublicKeys of them.
* Fixed simple market-maker's calculation of position sizes.
2021-07-01 21:24:08 +01:00
Geoff Taylor b5c8f69ae1 Fixed Withdraw command. 2021-06-30 15:06:10 +01:00
Geoff Taylor d9b40e105a Updated Quickstart to use solana-keygen. Deleted create-wallet. 2021-06-28 11:20:10 +01:00
Geoff Taylor 888994424d Improved reporting of TokenValue and BalanceSheet, in line with V2 changes. 2021-06-26 18:24:07 +01:00
Geoff Taylor bbd8cc487e Added a --fetch-prices option to show-margin-account. 2021-06-26 18:11:16 +01:00
Geoff Taylor 115ccf1db3 Made version command handle no .version file case. 2021-06-25 18:04:55 +01:00
Geoff Taylor 7c992b2b07 Added a 'version' command. 2021-06-25 18:02:33 +01:00
Geoff Taylor e61a3806ba Removed all InstructionBuilders. Instead we'll use simpler functions that return an array of instructions (allowing for compound instructions etc.) 2021-06-25 17:21:53 +01:00
Geoff Taylor 5b71ffbd18 Big Rename - removal of old Group and MarginAccount, deletion of a lot of code that is no longer relevant.
* Added some TODO comments where work needs to be done but pieces are currently missing.
2021-06-25 15:50:37 +01:00
Geoff Taylor cd46c1c98b First cut at a lot of V3 code. 2021-06-25 10:33:40 +01:00
Geoff Taylor b0207dd19a Added --worthwhile-threshold parameter to liquidator. 2021-06-24 16:36:11 +01:00
Geoff Taylor 852abdff00 Made all send_transaction() calls consistent in use of preflight commitment. 2021-06-24 11:59:57 +01:00
Geoff Taylor 206a95e39a Added type annotation for token lookups. 2021-06-23 09:44:55 +01:00
Geoff Taylor 3d3577023c Continue liquidating accounts that are liquidatable even if they're above maint_coll_ratio. 2021-06-22 20:36:31 +01:00
Geoff Taylor f7bd67308e Improved AccountInfo.load_multiple and made better use of it fetching updated prices. 2021-06-22 09:43:31 +01:00
Geoff Taylor d0937d09cc Trying to fix duplicated notifications - think it's a captured variable problem. 2021-06-21 16:25:10 +01:00
Geoff Taylor 5fc7aa7868 Added better health management of LiquidationProcessor. 2021-06-21 11:06:26 +01:00
Geoff Taylor 5a234684b0 Fixed incorrect program names in exception handlers. 2021-06-20 19:34:59 +01:00
Geoff Taylor 858cee248b Now uses ReportingAccountLiquidator even when using NullAccountLiquidator. 2021-06-19 19:55:23 +01:00
Geoff Taylor fab659c244 Improved access to market lookup data.
* Abstracted MarketLookup from SpotMarketLookup, because not all markets need be 'spot'.
* Made MarketLookup accessible from Context.
2021-06-18 13:50:33 +01:00
Geoff Taylor 80ba1e0d4b Moved to a more event-driven, observable-based liquidator. 2021-06-17 16:30:40 +01:00
Geoff Taylor aac32ba716 Wallet can now be loaded from environment.
* Centralised configuration of Wallet from command-line
* Added loading Wallet from environment variables
* Improved command-line handling of many commands
2021-06-17 12:06:39 +01:00
Geoff Taylor 7078ef4722 Removed default context objects - now have static method on Context object: Context.default(). 2021-06-17 11:18:35 +01:00
Geoff Taylor f63592878f Added command notify-below-minimum-sol-balance to send a notification if a monitored account is running out of SOLs. 2021-06-16 16:06:47 +01:00
Geoff Taylor d0595b8673 Updated SimpleMarketMaker based on suggestions from Brian.
* Cleans up existing orders on startup, in case recovering from a previous crash.
* Can now leave existing orders in place (instead of cancelling and creating fresh) if price and size are within tolerance.
2021-06-16 12:06:12 +01:00
Geoff Taylor 81f386f114 Introduced a SimpleMarketMaker. 2021-06-15 23:30:11 +01:00
Geoff Taylor 0fae7679f7 Separated out logic to determine liquidatability of margin account into a more testable setup. 2021-06-15 17:30:25 +01:00
Geoff Taylor 36446c2567 Fixed problem passing empty OpenOrders accounts in instructions. 2021-06-13 22:02:02 +01:00
Geoff Taylor a491d1d851 Added to_streaming_observable() method to OracleProviders. Added polling observable to Pyth and Serum providers, and websocket observable to FTX provider. 2021-06-13 16:01:36 +01:00
Geoff Taylor c3ac807fce Moved oracles to their own packages. 2021-06-11 16:51:41 +01:00
Geoff Taylor b47bd6f6f3 Added Serum oracle. 2021-06-11 12:43:47 +01:00
Geoff Taylor 83d1702691 Added code to fetch prices from the Pyth Network. 2021-06-10 21:28:29 +01:00
Geoff Taylor 4294fbebe7 Fixed problem using Wrapped SOL with Serum.
* Fixes problems with liquidator re-balancing.
* Fixes problems with group-balance-wallet, group-settle, serum-buy and serum-sell commands.
* Greatly increases the speed of buying and selling on Serum - the IOC order is now placed, cranked and settled in one transaction.
* Associated token accounts and OpenOrders accounts are automatically created as-needed.
2021-06-09 00:47:15 +01:00
Geoff Taylor 032c91c66e Fixed bug in group-settle, where market metadata was provided instead of a spot market. 2021-06-08 15:12:43 +01:00
Geoff Taylor 16cb68ad4c Fixed bug in balancing wallet.
* Mixed use of 'symbol' in different contexts.
2021-06-08 14:38:28 +01:00
Geoff Taylor e3e44a14ef Added documentation on Wrapped SOL, how to wrap/unwrap. Cleaned up those commands, centralised some Instructions. 2021-06-08 14:05:00 +01:00
Geoff Taylor 616d929e90 Removed context from Group, added name. Price lookups must now pass the context they want to use. 2021-06-08 08:17:37 +01:00
Geoff Taylor c0d7621e53 Added show-group and show-margin-account commands.
* Improved string output
* Strongly typed Group TokenValues, e.g. total deposits/borrows, indexes.
2021-06-07 19:38:43 +01:00
Geoff Taylor 5e59d8a7e3 Moved library code to .py files instead of notebooks.
* This is a big change that touched most files in the project.
* Library code is now an actual package, in /mango.
* Pure .py files used for shared code - easier to edit/debug, and should ease move to installable package later.
* Removed many notebooks. The remaining notebooks are useful 'display'/'show' notebooks for investigating Mango objects.
* More tests! The test story is now much improved, but more unit tests are still needed.
* There's now a Makefile for project operations.
2021-06-07 15:10:18 +01:00
Geoff Taylor de0144f43a Tidied up command help for new commands. 2021-06-03 09:10:09 +01:00
Geoff Taylor 227e63a851 Fixed confirmation statement in wrap-sol. 2021-06-02 20:17:40 +01:00
Geoff Taylor cd7cdab540 Added commands to wrap and unwrap SOL. 2021-06-02 20:03:46 +01:00
Geoff Taylor e3b0d65705 Extended use of Lookups - serum buys and sells no longer need a Group. 2021-06-01 19:16:59 +01:00
Geoff Taylor f73ee9ca19 Now use solana.tokenlist.json for token lookups. 2021-06-01 18:16:02 +01:00
Geoff Taylor cbd42d24ae Context can now decide to look up the group ID given a group name, instead of using the wrong default. 2021-06-01 14:08:54 +01:00
Geoff Taylor ba25e289af Better retry functionality with backoff pauses. 2021-05-28 17:16:53 +01:00
Geoff Taylor b6a595bb21 Updated to handle Groups with 5 tokens as well as Groups with 3 tokens. 2021-05-27 17:07:02 +01:00
Geoff Taylor 8b21f4c025 Fixed formatting of token balance in group-balances command. 2021-05-25 17:17:41 +01:00
Geoff Taylor 30543975ee Renamed commands to better reflect purpose. Updated Quickstart.
* group-buy-token to serum-buy
* group-sell-token to serum-sell
* group-send-token to send-token
2021-05-24 10:40:33 +01:00
Geoff Taylor 5c6abd0733 Added CsvFileNotificationTarget.
* Updated notifications to allow notifying on succeeded or failed (or both!) PartialLiquidate transactions.
* Added more information to LiquidationEvent to allow that to flow through to notifications.
2021-05-21 20:02:54 +01:00
Geoff Taylor 8b8afe1a0b Refactored PollingLiquidator into ReportingAccountLiquidator and LiquidationProcessor
* ReportingAccountLiquidator wraps an AccountLiquidator but provides before-and-after logging and reporting.
* Sped up fetch_token_prices() by reducing it to one network fetch
* Centralised loading of ripe mangoes by creating MarginAccount.load_all_ripe()
* Clearer, more consistent use of Observables
* Added RxPy Backpressure library
* Improved container building to allow for different tags
2021-05-21 14:28:42 +01:00
Geoff Taylor 106973c027 Removed intermediate lambda to see if it was the source of duplicate Discord notifications. 2021-05-19 11:37:44 +01:00
Geoff Taylor ce2d0d7438 Added a NotificationHandler to bridge log events to notifications. 2021-05-18 18:08:38 +01:00
Geoff Taylor 06e8e67049 More depth in parsing transactions, plus better reporting on them. 2021-05-18 15:17:14 +01:00
Geoff Taylor b80e60be37 EventSource now properly inherits from Subject. 2021-05-17 21:17:01 +01:00
Geoff Taylor f2cad71bc2 Fixed Method Resolution Order problem in Events. 2021-05-17 20:54:39 +01:00
Geoff Taylor 5707992fcb Can now send notifications, for example to Discord or Telegram. 2021-05-17 20:43:16 +01:00
Geoff Taylor 540bb5b79d Cleaned up PrintingObserverSubscriber() calls. 2021-05-17 14:17:18 +01:00
Geoff Taylor 02e272e437 Expanded TransactionScout and added new command - report-transactions. 2021-05-15 14:17:42 +01:00
Geoff Taylor c0070c2b94 Moved AccountInfo into BaseModel, moved 'fetch' methods to appropriate objects. 2021-05-14 15:51:29 +01:00
Geoff Taylor 5295121efe Added a transaction-scout command. 2021-05-14 12:32:39 +01:00
Geoff Taylor f79315201d Added TransactionScout to show Mango transaction details. 2021-05-13 20:32:23 +01:00
Geoff Taylor 0d9635ba45 PollingLiquidator optimisation - now loops and updates ripe 🥭 accounts. 2021-05-12 10:52:26 +01:00
Geoff Taylor a40b962965 Fixed dereference of group basket tokens. 2021-05-11 20:32:20 +01:00
Geoff Taylor 9b97722394 Fixed regression in importing notebook code. 2021-05-11 20:17:49 +01:00
Geoff Taylor 4cfc87d420 Split BasketTokenMetadata up. Improved linting.
* Split BasketTokenMetadata into BasketToken and Token.
* Improved linting and mypy so it worked across files.
2021-05-11 19:24:02 +01:00
Geoff Taylor 78fbb05970 Renamed SimpleLiquidator to PollingLiquidator. 2021-05-10 14:48:19 +01:00
Geoff Taylor b398990898 Added a Quickstart! A nice walkthrough of setting up a liquidator. 2021-05-08 16:01:30 +01:00
Geoff Taylor db91e1d9d8 Added a 'create-wallet' command, made other commands more consistent. 2021-05-07 10:47:01 +01:00
Geoff Taylor 013a8ce715 Added Pyston to docker image and commands.
All commands now use Pyston instead of Python as the Python interpreter. It seems a bit faster.
2021-05-06 19:06:47 +01:00
Geoff Taylor fab0d909c2 Added 'dry run' option to commands that perform transactions. 2021-05-06 15:27:25 +01:00
Geoff Taylor 3db09e922c Added wallet balancing. Big changes throughout to support this. 2021-05-06 14:21:40 +01:00
Geoff Taylor f2d4e7c13f Added Serum trading.
* Added nasty patch around pyserum bug
* OpenOrders can now provide (on-demand) the pyserum representation OpenOrdersAccount
* New context methods -unwrap_transaction_id_or_raise_exception() and random_client_id()
* Added Retrier and retry_context() function
* Added TradeExecutor and SerumImmediateTradeExecutor classes to trade on Serum
2021-05-04 17:18:09 +01:00
Geoff Taylor 9ae606b1c6 Commands now output the AccountScout report to show errors and warnings. 2021-04-29 16:33:04 +01:00
Geoff Taylor 9db61efaf5 mango-fetch can now fetch all margin accounts for a user. 2021-04-29 12:51:13 +01:00
Geoff Taylor feda91156b Fixed problem where OpenOrders could show the wrong program ID in some circumstances. 2021-04-29 12:11:28 +01:00
Geoff Taylor c5734a0624 Moved development commands to 'scripts', so 'bin' is for actual commands.
* Added log level as parameter to commands.
2021-04-29 10:53:01 +01:00
Geoff Taylor f8738770f5 Expanded liquidation process and steps. 2021-04-28 18:36:48 +01:00
Geoff Taylor 4f6890fe1c Added argument parsing to liquidator command. 2021-04-27 10:53:43 +01:00
Geoff Taylor acf2ff5da6 Renamed Classes.ipynb to BaseModel.ipynb. Adjusted all imports of it. 2021-04-27 09:41:22 +01:00
Geoff Taylor 482f759b11 Added start of a runnable 'liquidator' command. 2021-04-26 17:09:35 +01:00
Geoff Taylor 3928331cc3 Reformatted some header text and added TOC on all pages. 2021-04-22 14:28:32 +01:00
Geoff Taylor 2cc5135517 Initial import. 2021-04-14 16:51:39 +01:00