# LN Markets Python API
A simple way to connect your Python application to [LN Markets](https://lnmarkets.com/)!
## Install
You can install this package with pip:
```shell
pip3 install ln-markets
```
## Use
You can import the rest class from lnmarkets
```python
from lnmarkets import rest
```
And the websocket class as well
```python
from lnmarkets import websockets
```
## Authentication
> For authentication you need your api **key** **secret** and **passphrase**
Without you will not bet able to authenticate
> :warning: **Never share your API Key, Secret or Passphrase**
## Websocket API
### Configuration
Use the LNMarketsWebsocket and your key / passphrase to instanciate a new api connector:
```python
options = {'key': 'your_api_key',
'secret': 'your_api_secret',
'passphrase': 'your_api_passphrase',
'network': 'testnet'}
lnm = websockets.LNMarketsWebsocket(**options)
lnm.connect()
```
> Check [examples](examples/websocket/README.md) for more details as you'll need to extend this class most of the time.
### Subscription
You can subscribe to LNM Markets public event such as futures last price ('futures:btc_usd:last-price') and index ('futures:btc_usd:index').
## REST API Authentication
### Using API key
Use the LNMarketsRest and your key / passphrase to instanciate a new api connector:
```python
from lnmarkets import rest
options = {'key': 'your_api_key',
'secret': 'your_api_secret',
'passphrase': 'your_api_passphrase',
'network': 'testnet'}
lnm = rest.LNMarketsRest(**options)
lnm.futures_get_ticker()
```
### Using Mnemonic seed
Use the LNMarketsRest with [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonic phrase
to instanciate a new api connector:
```python
from lnmarkets import rest
mnemonic = 'struggle goddess action cheap endorse venue force tomato exercise cactus charge such'
lnm = rest.LNMarketsRest(mnemonic=mnemonic)
lnm.futures_get_ticker()
```
Mnemonic seed auth is a "hack" using the cookie used by LNM WebApp, so for avoid risk of stolen cookie, you should
logout, when your program stop running:
```python
lnm.logout()
```
The cookie have a lifetime (about 1 week), so if your program running for more than that time you might renew the
cookie before expiry date (note that it can also be a safety measure tu renew your cookie often to avoid
stolen cookies risk):
```python
lnm.renew_cookie()
```
## REST API
- [`futures_add_margin`](#futures_add_margin)
- [`futures_cancel_all`](#futures_cancel_all)
- [`futures_close_all`](#futures_close_all)
- [`futures_cancel`](#futures_cancel)
- [`futures_cashin`](#futures_cashin)
- [`futures_close`](#futures_close)
- [`futures_get_trades`](#futures_get_trades)
- [`futures_new_trade`](#futures_new_trade)
- [`futures_update_trade`](#futures_update_trade)
- [`futures_carry_fees`](#futures_carry_fees)
- [`futures_get_price`](#futures_get_price)
- [`futures_fixing`](#futures_fixing)
- [`futures_index`](#futures_index)
- [`futures_get_leaderboard`](#futures_get_leaderboard)
- [`futures_get_ticker`](#futures_get_ticker)
- [`futures_get_market`](#futures_get_market)
- [`options_get_instruments`](#options_get_instruments)
- [`options_get_instrument`](#options_get_instrument)
- [`options_close_all`](#options_close_all)
- [`options_close`](#options_close)
- [`options_get_trades`](#options_get_trades)
- [`options_new_trade`](#options_new_trade)
- [`options_update_trade`](#options_update_trade)
- [`options_get_volatility`](#options_get_volatility)
- [`options_get_market`](#options_get_market)
- [`get_swaps`](#get_swaps)
- [`swap`](#swap)
- get_user
- update_user
- get_new_bitcoin_address
- get_bitcoin_addresses
- get_deposit
- get_deposits
- new_deposit
- get_withdrawal
- get_withdrawals
- new_withdraw
- new_internal_transfer
- get_oracle_index
- get_oracle_last
- fetch_notifications
- mark_notifications_read
- app_configuration
- app_node
[`See the API documentation`](https://docs.lnmarkets.com/api/v2) for more details.
### futures_add_margin
Add more margin to an existing trade.
```yml
amount:
type: Integer
required: true
id:
type: String
required: true
```
Example:
```python
lnm.futures_add_margin({
'amount': 20000,
'id': '249dc818-f8a5-4713-a3a3-8fe85f2e8969'
})
```
[`POST /futures/add-margin`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_cancel_all
Cancel all opened (not running) trades for this user.
```
# No parameters
```
Example:
```python
lnm.futures_cancel_all()
```
[`DELETE /futures/all/cancel`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_close_all
Close all running trades for this user.
```
# No parameters
```
Example:
```python
lnm.futures_close_all()
```
[`DELETE /futures/all/close`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_cancel
Cancel a specific trade for this user.
```yml
id:
type: String
required: true
```
Example:
```python
lnm.futures_cancel_position({
'id': 'b87eef8a-52ab-2fea-1adc-c41fba870b0f'
})
```
[`POST /futures/cancel`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_cashin
Cash in a part of the PL of a running trade.
```yml
amount:
type: Integer
required: true
id:
type: String
required: true
```
Example:
```python
lnm.futures_cashin({
'amount': 1000,
'id': "99c470e1-2e03-4486-a37f-1255e08178b1"
})
```
[`POST /futures/cash-in`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_carry_fees
Get carry-fees history.
```yml
from:
type: Integer
required: true
to:
type: Integer
required: tue
limit:
type: Integer
required: false
default: 100
```
Example:
```python
lnm.futures_carry_fees({
'limit': 20
})
```
[`GET /futures/carry-fees`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_close
Close a specific running trade for this user.
```yml
id:
type: String
required: true
```
Example:
```python
lnm.futures_close({
'id': 'a2ca6172-1078-463d-ae3f-8733f36a9b0e'
})
```
[`DELETE /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_get_trades
Retrieve all or a part of user's trades.
```yml
type:
type: String
required: true
enum: ['open', 'running', 'closed']
default: 'open'
from:
type: Integer
required: false
to:
type: Integer
required: false
limit:
type: Integer
required: false
default: 100
```
Example:
```python
lnm.futures_get_trades({
'type': 'running'
})
```
[`GET /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_new_trade
Open a new trade. If type="l", the property price must be included in the request to know when the trade should be filled. You can choose to use the margin or the quantity as a parameter, the other will be calculated with the one you chose.
```yml
type:
type: String
required: true
enum: ['l', 'm']
side:
type: String
required: true
enum: ['b', 's']
margin:
type: Integer
required: true
leverage:
type: Float
required: true
quantity:
type: Integer
required: false
takeprofit:
type: Integer
required: false
stoploss:
type: Integer
required: false
price:
type: Float
required: false
```
Example:
```python
lnm.futures_new_trade({
'type': 'm',
'side': 's',
'margin': 10000,
'leverage': 25,
})
```
[`POST /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_update_trade
Modify stoploss or takeprofit parameter of an existing trade.
```yml
id:
type: String
required: true
type:
type: String
required: true
enum: ['takeprofit', 'stoploss']
value:
type: Float
required: true
```
Example:
```python
lnm.futures_update_trade({
'id': 'b87eef8a-52ab-2fea-1adc-c41fba870b0f',
'type': 'stoploss',
'value': 13290.5
})
```
[`PUT /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_get_price
Get Futures price data over time.
```yml
from:
type: Integer
required: false
to:
type: Integer
required: false
limit: Integer
required: false
default: 100
```
Example:
```python
lnm.futures_price({
'limit': 20
})
```
[`GET /futures/history/price`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_fixing
Get fixing data history.
```yml
from:
type: Integer
required: false
to:
type: Integer
required: false
limit:
type: Integer
required: false
default: 100
```
Example:
```python
lnm.futures_fixing({
'limit': 20
})
```
[`GET /futures/history/fixing`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_index
Get index history data.
```yml
from:
type: Integer
required: false
to:
type: Integer
required: false
limit:
type: Integer
required: false
default: 100
```
Example:
```python
lnm.futures_index({
'limit': 20
})
```
[`GET /futures/history/index`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_get_ticker
Get the futures ticker.
```
# No parameters
```
Example:
```python
lnm.futures_get_ticker()
```
[`GET /futures/ticker`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_get_leaderboard
Queries the 10 users with the biggest positive PL on a daily, weekly, monthly and all-time basis.
```
# No parameters
```
Example:
```python
lnm.futures_get_leaderboard()
```
[`GET /futures/leaderboard`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### futures_get_market
Get the futures market details.
```
# No parameters
```
Example:
```python
lnm.futures_get_market()
```
[`GET /futures/market`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_get_instruments
Get the options instruments list.
```
# No parameters
```
Example:
```python
lnm.options_get_instruments()
```
[`GET /options/instruments`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_get_instrument
Get a specific option instrument detail.
```yml
instrument_name:
type: String
required: true
```
Example:
```python
lnm.options_get_instrument({
'instrument_name': 'BTC.2024-01-05.43000.C'
})
```
[`GET /options/instrument`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_close_all
Close all of the user option trades, the PL will be calculated against the current bid or offer depending on the type of the options.
```
# No parameters
```
Example:
```python
lnm.options_close_all()
```
[`DELETE /options/close-all`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_close
Close the user option trade, the PL will be calculated against the current bid or offer depending on the type of the option.
```yml
id:
type: String
required: true
```
Example:
```python
lnm.options_close({
'id': 'a61faebc-7cc9-47e4-a22d-9d3e95c98322'
})
```
[`DELETE /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_get_trades
Get user's options trades.
```yaml
status:
type: String
enum: ['running', 'closed']
default: running
required: true
from:
type: Integer
required: false
to:
type: Integer
required: false
limit:
type: Integer
required: false
```
Example:
```python
lnm.options_get_trades({
limit: 25,
status: 'closed'
})
```
[`GET /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_new_trade
Create a new options trade
```yaml
side:
type: String
enum: ['b']
required: true
quantity:
type: Integer
required: true
settlement:
type: String
enum: ['physical', 'cash']
required: true
instrument_name:
type: String
required: true
```
Example:
```python
lnm.options_new_trade({
'side': 'b',
'quantity': 10,
'settlement': 'physical',
'instrument_name': 'BTC.2024-01-05.43000.C'
})
```
[`POST /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### options_update_trade
Allows user to update settlement parameter in running option trade.
```yml
id:
type: String
required: true
settlement:
type: String
required: true
enum: ['physical', 'cash']
```
Example:
```python
lnm.options_update_trade({
'id': 'a2ca6172-1078-463d-ae3f-8733f36a9b0e',
'settlement': 'physical'
})
```
[`PUT /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.
#### options_get_volatility
Return the volatility
```yml
instrument:
type: String
required: false
```
Example:
```python
lnm.options_get_volatility({
'instrument': 'BTC.2016-01-14.20000.C'
})
```
[`GET /options/volatility`](https://docs.lnmarkets.com/api/v2) documentation for more details.
#### options_get_market
Get the options market details.
```
# No parameters
```
Example:
```python
lnm.options_get_market()
```
[`GET /options/market`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### get_swaps
Get swap history
```yml
from:
type: Integer
required: false
to:
type: Integer
required: false
limit:
type: Integer
required: False
```
Example:
```python
lnm.get_swaps({
'from': 1669980001000,
'to': '1669990201000',
'limit': 100
})
```
[`GET /swap`](https://docs.lnmarkets.com/api/v2) documentation for more details.
### swap
Swap betweem sats and synthetic USD
```yml
in_asset:
type: String
required: true
enum: ['USD', 'BTC']
out_asset:
type: String
required: true
enum: ['USD', 'BTC']
in_amount:
type: Integer
required: False
out_amount:
type: Integer
required: false
```
Example:
```python
lnm.swap({
'in_asset': 'BTC',
'out_asset': 'USD',
'out_amount': 100
})
```
[`POST /swap`](https://docs.lnmarkets.com/api/v2) documentation for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/ln-markets/api-python",
"name": "ln-markets",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "lnmarkets trading rest api bitcoin lightning network futures options",
"author": "Romain ROUPHAEL",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/13/81/55cf98e5f2f2c150e3bd58414821146ffab27c470f1312b72c016c2fc0fc/ln_markets-2.0.6.tar.gz",
"platform": null,
"description": "# LN Markets Python API \n\nA simple way to connect your Python application to [LN Markets](https://lnmarkets.com/)!\n\n## Install\n\nYou can install this package with pip:\n```shell\npip3 install ln-markets\n```\n\n## Use\n\nYou can import the rest class from lnmarkets\n```python\nfrom lnmarkets import rest\n```\nAnd the websocket class as well\n```python\nfrom lnmarkets import websockets\n```\n\n## Authentication\n\n> For authentication you need your api **key** **secret** and **passphrase**\n\nWithout you will not bet able to authenticate\n\n> :warning: **Never share your API Key, Secret or Passphrase**\n\n## Websocket API\n\n### Configuration\n\nUse the LNMarketsWebsocket and your key / passphrase to instanciate a new api connector: \n\n```python\noptions = {'key': 'your_api_key', \n 'secret': 'your_api_secret', \n 'passphrase': 'your_api_passphrase',\n 'network': 'testnet'}\n\nlnm = websockets.LNMarketsWebsocket(**options)\nlnm.connect()\n```\n\n> Check [examples](examples/websocket/README.md) for more details as you'll need to extend this class most of the time.\n\n### Subscription\n\nYou can subscribe to LNM Markets public event such as futures last price ('futures:btc_usd:last-price') and index ('futures:btc_usd:index').\n\n## REST API Authentication\n\n### Using API key\n\nUse the LNMarketsRest and your key / passphrase to instanciate a new api connector: \n\n```python\nfrom lnmarkets import rest\n\noptions = {'key': 'your_api_key', \n 'secret': 'your_api_secret', \n 'passphrase': 'your_api_passphrase',\n 'network': 'testnet'}\n\nlnm = rest.LNMarketsRest(**options)\n\nlnm.futures_get_ticker()\n\n```\n\n### Using Mnemonic seed\n\nUse the LNMarketsRest with [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonic phrase\nto instanciate a new api connector: \n\n```python\nfrom lnmarkets import rest\n\nmnemonic = 'struggle goddess action cheap endorse venue force tomato exercise cactus charge such'\n\nlnm = rest.LNMarketsRest(mnemonic=mnemonic)\n\nlnm.futures_get_ticker()\n\n```\n\nMnemonic seed auth is a \"hack\" using the cookie used by LNM WebApp, so for avoid risk of stolen cookie, you should \nlogout, when your program stop running:\n\n```python\nlnm.logout()\n```\nThe cookie have a lifetime (about 1 week), so if your program running for more than that time you might renew the \ncookie before expiry date (note that it can also be a safety measure tu renew your cookie often to avoid \nstolen cookies risk):\n\n```python\nlnm.renew_cookie()\n```\n## REST API\n\n- [`futures_add_margin`](#futures_add_margin)\n- [`futures_cancel_all`](#futures_cancel_all)\n- [`futures_close_all`](#futures_close_all)\n- [`futures_cancel`](#futures_cancel)\n- [`futures_cashin`](#futures_cashin)\n- [`futures_close`](#futures_close)\n- [`futures_get_trades`](#futures_get_trades)\n- [`futures_new_trade`](#futures_new_trade)\n- [`futures_update_trade`](#futures_update_trade)\n- [`futures_carry_fees`](#futures_carry_fees)\n- [`futures_get_price`](#futures_get_price)\n- [`futures_fixing`](#futures_fixing)\n- [`futures_index`](#futures_index)\n- [`futures_get_leaderboard`](#futures_get_leaderboard)\n- [`futures_get_ticker`](#futures_get_ticker)\n- [`futures_get_market`](#futures_get_market)\n- [`options_get_instruments`](#options_get_instruments)\n- [`options_get_instrument`](#options_get_instrument)\n- [`options_close_all`](#options_close_all)\n- [`options_close`](#options_close)\n- [`options_get_trades`](#options_get_trades)\n- [`options_new_trade`](#options_new_trade)\n- [`options_update_trade`](#options_update_trade)\n- [`options_get_volatility`](#options_get_volatility)\n- [`options_get_market`](#options_get_market)\n- [`get_swaps`](#get_swaps)\n- [`swap`](#swap)\n- get_user\n- update_user\n- get_new_bitcoin_address\n- get_bitcoin_addresses\n- get_deposit\n- get_deposits\n- new_deposit\n- get_withdrawal\n- get_withdrawals\n- new_withdraw\n- new_internal_transfer\n- get_oracle_index\n- get_oracle_last\n- fetch_notifications\n- mark_notifications_read\n- app_configuration\n- app_node\n\n\n[`See the API documentation`](https://docs.lnmarkets.com/api/v2) for more details.\n\n\n### futures_add_margin\n\nAdd more margin to an existing trade.\n\n```yml\namount:\n type: Integer\n required: true\nid:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.futures_add_margin({\n 'amount': 20000,\n 'id': '249dc818-f8a5-4713-a3a3-8fe85f2e8969'\n })\n```\n\n[`POST /futures/add-margin`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_cancel_all\n\nCancel all opened (not running) trades for this user.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.futures_cancel_all()\n```\n\n[`DELETE /futures/all/cancel`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_close_all\n\nClose all running trades for this user.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.futures_close_all()\n```\n\n[`DELETE /futures/all/close`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_cancel\n\nCancel a specific trade for this user.\n\n```yml\nid:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.futures_cancel_position({\n 'id': 'b87eef8a-52ab-2fea-1adc-c41fba870b0f'\n })\n```\n\n[`POST /futures/cancel`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_cashin\n\nCash in a part of the PL of a running trade.\n\n```yml\namount:\n type: Integer\n required: true\nid:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.futures_cashin({\n 'amount': 1000,\n 'id': \"99c470e1-2e03-4486-a37f-1255e08178b1\"\n })\n```\n\n[`POST /futures/cash-in`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_carry_fees\n\nGet carry-fees history.\n\n```yml\nfrom:\n type: Integer\n required: true\n\nto:\n type: Integer\n required: tue\n\nlimit:\n type: Integer\n required: false\n default: 100\n```\n\nExample:\n\n```python\nlnm.futures_carry_fees({\n 'limit': 20\n })\n```\n\n[`GET /futures/carry-fees`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_close\n\nClose a specific running trade for this user.\n\n```yml\nid:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.futures_close({\n 'id': 'a2ca6172-1078-463d-ae3f-8733f36a9b0e'\n })\n```\n\n[`DELETE /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_get_trades\n\nRetrieve all or a part of user's trades.\n\n```yml\ntype:\n type: String\n required: true\n enum: ['open', 'running', 'closed']\n default: 'open'\n\nfrom:\n type: Integer\n required: false\n\nto:\n type: Integer\n required: false\n\nlimit:\n type: Integer\n required: false\n default: 100\n```\n\nExample:\n\n```python\nlnm.futures_get_trades({\n 'type': 'running'\n })\n```\n\n[`GET /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_new_trade\n\nOpen a new trade. If type=\"l\", the property price must be included in the request to know when the trade should be filled. You can choose to use the margin or the quantity as a parameter, the other will be calculated with the one you chose.\n\n```yml\ntype:\n type: String\n required: true\n enum: ['l', 'm']\n\nside:\n type: String\n required: true\n enum: ['b', 's']\n\nmargin:\n type: Integer\n required: true\n\nleverage:\n type: Float\n required: true\n\nquantity:\n type: Integer\n required: false\n\ntakeprofit:\n type: Integer\n required: false\n\nstoploss:\n type: Integer\n required: false\n\nprice:\n type: Float\n required: false\n```\n\nExample:\n\n```python\n lnm.futures_new_trade({\n 'type': 'm',\n 'side': 's',\n 'margin': 10000,\n 'leverage': 25,\n })\n```\n\n[`POST /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_update_trade\n\nModify stoploss or takeprofit parameter of an existing trade.\n\n```yml\nid:\n type: String\n required: true\n\ntype:\n type: String\n required: true\n enum: ['takeprofit', 'stoploss']\n\nvalue:\n type: Float\n required: true\n```\n\nExample:\n\n```python\nlnm.futures_update_trade({\n 'id': 'b87eef8a-52ab-2fea-1adc-c41fba870b0f',\n 'type': 'stoploss',\n 'value': 13290.5\n })\n```\n\n[`PUT /futures`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_get_price\n\nGet Futures price data over time.\n\n```yml\nfrom:\n type: Integer\n required: false\n\nto:\n type: Integer\n required: false\n\nlimit: Integer\n required: false\n default: 100\n```\n\nExample:\n\n```python\nlnm.futures_price({\n 'limit': 20\n })\n```\n\n[`GET /futures/history/price`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_fixing\n\nGet fixing data history.\n\n```yml\nfrom:\n type: Integer\n required: false\n\nto:\n type: Integer\n required: false\n\nlimit:\n type: Integer\n required: false\n default: 100\n```\n\nExample:\n\n```python\nlnm.futures_fixing({\n 'limit': 20\n })\n```\n\n[`GET /futures/history/fixing`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_index\n\nGet index history data.\n\n```yml\nfrom:\n type: Integer\n required: false\n\nto:\n type: Integer\n required: false\n\nlimit:\n type: Integer\n required: false\n default: 100\n```\n\nExample:\n\n```python\nlnm.futures_index({\n 'limit': 20\n })\n```\n\n[`GET /futures/history/index`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_get_ticker\n\nGet the futures ticker.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.futures_get_ticker()\n```\n\n[`GET /futures/ticker`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_get_leaderboard\n\nQueries the 10 users with the biggest positive PL on a daily, weekly, monthly and all-time basis.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.futures_get_leaderboard()\n```\n\n[`GET /futures/leaderboard`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### futures_get_market\n\nGet the futures market details.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.futures_get_market()\n```\n\n[`GET /futures/market`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_get_instruments\n\nGet the options instruments list.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.options_get_instruments()\n```\n\n[`GET /options/instruments`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_get_instrument\n\nGet a specific option instrument detail.\n\n```yml\ninstrument_name:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.options_get_instrument({\n 'instrument_name': 'BTC.2024-01-05.43000.C'\n })\n```\n\n\n[`GET /options/instrument`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_close_all\n\nClose all of the user option trades, the PL will be calculated against the current bid or offer depending on the type of the options.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.options_close_all()\n```\n\n[`DELETE /options/close-all`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_close\n\nClose the user option trade, the PL will be calculated against the current bid or offer depending on the type of the option.\n\n```yml\nid:\n type: String\n required: true\n```\n\nExample:\n\n```python\nlnm.options_close({\n 'id': 'a61faebc-7cc9-47e4-a22d-9d3e95c98322'\n })\n```\n\n[`DELETE /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_get_trades\n\nGet user's options trades.\n\n```yaml\nstatus:\n type: String\n enum: ['running', 'closed']\n default: running\n required: true\n\nfrom:\n type: Integer\n required: false\n\nto:\n type: Integer\n required: false\n\nlimit:\n type: Integer\n required: false\n```\n\nExample:\n\n```python\n lnm.options_get_trades({\n limit: 25,\n status: 'closed'\n })\n```\n\n[`GET /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_new_trade\n\nCreate a new options trade\n\n```yaml\nside:\n type: String\n enum: ['b']\n required: true\n\nquantity:\n type: Integer\n required: true\n\nsettlement:\n type: String\n enum: ['physical', 'cash']\n required: true\n\ninstrument_name:\n type: String\n required: true\n\n```\n\nExample:\n\n```python\n lnm.options_new_trade({\n 'side': 'b',\n 'quantity': 10,\n 'settlement': 'physical',\n 'instrument_name': 'BTC.2024-01-05.43000.C'\n })\n```\n\n[`POST /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### options_update_trade\n\nAllows user to update settlement parameter in running option trade.\n\n```yml\nid:\n type: String\n required: true\n\nsettlement:\n type: String\n required: true\n enum: ['physical', 'cash']\n```\n\nExample:\n\n```python\nlnm.options_update_trade({\n 'id': 'a2ca6172-1078-463d-ae3f-8733f36a9b0e',\n 'settlement': 'physical'\n })\n```\n\n[`PUT /options`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n#### options_get_volatility\n\nReturn the volatility\n\n```yml\ninstrument:\n type: String\n required: false\n```\n\nExample:\n\n```python\nlnm.options_get_volatility({\n 'instrument': 'BTC.2016-01-14.20000.C'\n })\n```\n\n[`GET /options/volatility`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n#### options_get_market\n\nGet the options market details.\n\n```\n# No parameters\n```\n\nExample:\n\n```python\nlnm.options_get_market()\n```\n\n[`GET /options/market`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### get_swaps\n\nGet swap history\n\n```yml\nfrom:\n type: Integer\n required: false\n \nto:\n type: Integer\n required: false\n \nlimit:\n type: Integer\n required: False\n\n```\n\nExample:\n\n```python\n lnm.get_swaps({\n 'from': 1669980001000,\n 'to': '1669990201000',\n 'limit': 100\n })\n```\n\n[`GET /swap`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n\n### swap\n\nSwap betweem sats and synthetic USD\n\n```yml\nin_asset:\n type: String\n required: true\n enum: ['USD', 'BTC']\n \nout_asset:\n type: String\n required: true\n enum: ['USD', 'BTC']\n\nin_amount:\n type: Integer\n required: False\n\nout_amount:\n type: Integer\n required: false\n\n```\n\nExample:\n\n```python\n lnm.swap({\n 'in_asset': 'BTC',\n 'out_asset': 'USD',\n 'out_amount': 100\n })\n```\n\n[`POST /swap`](https://docs.lnmarkets.com/api/v2) documentation for more details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "LN Markets API python implementation",
"version": "2.0.6",
"project_urls": {
"Homepage": "https://github.com/ln-markets/api-python"
},
"split_keywords": [
"lnmarkets",
"trading",
"rest",
"api",
"bitcoin",
"lightning",
"network",
"futures",
"options"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d4e557083d6a8d2a307309c273b3b3c0d3945a5ea62beec3f0f73c8a4dffde5e",
"md5": "db6bd17b8d20c197e708f932bb9cba99",
"sha256": "4fa8b1f5afd038ecbf5577b0cc6cca45bd308d400b885d1c042ae432f2ad9e81"
},
"downloads": -1,
"filename": "ln_markets-2.0.6-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "db6bd17b8d20c197e708f932bb9cba99",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 8349,
"upload_time": "2024-05-07T16:30:24",
"upload_time_iso_8601": "2024-05-07T16:30:24.806569Z",
"url": "https://files.pythonhosted.org/packages/d4/e5/57083d6a8d2a307309c273b3b3c0d3945a5ea62beec3f0f73c8a4dffde5e/ln_markets-2.0.6-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "138155cf98e5f2f2c150e3bd58414821146ffab27c470f1312b72c016c2fc0fc",
"md5": "9637c3889e111994465e70d771090a7c",
"sha256": "f1fa018e7f1aa08cfeda98dfba6cf1a6ecad9c57d0cf1dd951484475d2745917"
},
"downloads": -1,
"filename": "ln_markets-2.0.6.tar.gz",
"has_sig": false,
"md5_digest": "9637c3889e111994465e70d771090a7c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8677,
"upload_time": "2024-05-07T16:30:27",
"upload_time_iso_8601": "2024-05-07T16:30:27.879542Z",
"url": "https://files.pythonhosted.org/packages/13/81/55cf98e5f2f2c150e3bd58414821146ffab27c470f1312b72c016c2fc0fc/ln_markets-2.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-07 16:30:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ln-markets",
"github_project": "api-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "ln-markets"
}