{"id":20256383,"url":"https://github.com/daskycodes/lemon.markets_ex","last_synced_at":"2025-05-07T13:33:40.854Z","repository":{"id":45253513,"uuid":"388872058","full_name":"daskycodes/lemon.markets_ex","owner":"daskycodes","description":"Elixir client for the https://lemon.markets API.","archived":false,"fork":false,"pushed_at":"2022-01-10T17:30:33.000Z","size":1291,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-03-10T22:47:27.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://daskycodes.github.io/lemon.markets_ex/readme.html","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daskycodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-23T17:07:52.000Z","updated_at":"2023-03-01T21:08:04.000Z","dependencies_parsed_at":"2022-09-03T19:01:35.473Z","dependency_job_id":null,"html_url":"https://github.com/daskycodes/lemon.markets_ex","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskycodes%2Flemon.markets_ex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskycodes%2Flemon.markets_ex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskycodes%2Flemon.markets_ex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daskycodes%2Flemon.markets_ex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daskycodes","download_url":"https://codeload.github.com/daskycodes/lemon.markets_ex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224609065,"owners_count":17339785,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T10:46:29.304Z","updated_at":"2024-11-14T10:46:29.903Z","avatar_url":"https://github.com/daskycodes.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  🍋 lemon.markets_ex\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003eElixir client for the \u003ca href=\"https://lemon.markets\"\u003elemon.markets\u003c/a\u003e API\u003c/p\u003e\n\n\u003e ## ⚠️ Open Beta Notice\n\u003e\n\u003e Note: [lemon.markets](https://lemon.markets) is in open beta and this library is a work in progress. Expect breaking changes until the release of version 1.0.\n\nTo get a general understading of the API, please refer to the [official documentation](https://docs.lemon.markets) and the [quickstart guide](https://docs.lemon.markets/quickstart).\n\n## 💻 Installation\n\nThe package is currently not available on [hex.pm](https://hex.pm) but can be installed directly from GitHub.\n\n```elixir\ndef deps do\n  [\n    {:lemon_markets_ex, github: \"daskycodes/lemon.markets_ex\"}\n  ]\nend\n```\n\n## 🚀 Getting started\n\nPlease refer to the Modules `LemonMarketsEx.Trading` and `LemonMarketsEx.Market` for more details and examples. You can find the documentation [here](https://daskycodes.github.io/lemon.markets_ex).\n\n### 🔐 Configuration\n\nAll requests to the API have to be authenticated. You can get your `api_key` from the [lemon.markets dashboard](https://dashboard.lemon.markets/).\n\nYou can configure the Elixir API Client by setting them up in the `config.exs`\n\n```elixir\nconfig :lemon_markets_ex,\n  api_key: \"LEMON_MARKETS_API_KEY\",\n  trading_api_url: \"https://paper-trading.lemon.markets/v1\"\n```\n\nThere are 2 options for the `LEMON_MARKETS_TRADING_API_URL`:\n\n- `\"https://paper-trading.lemon.markets/v1\"`\n- `\"https://trading.lemon.markets/v1\"`\n\n### 🏦 Your first request\n\nYou can check your account information, to make sure you are correctly authenticated.\n\n```elixir\niex\u003e LemonMarketsEx.Trading.get_account()\n{:ok,\n %{\n   mode: \"paper\",\n   results: %LemonMarketsEx.Account{...},\n   status: \"ok\",\n   time: \"2021-12-27T19:04:38.710+00:00\"\n }}\n```\n\n### 📈 Creating an order\n\n#### Finding an instrument\n\nLet's find an `Instrument` we would like to buy:\n\n```elixir\niex\u003e  LemonMarketsEx.Market.get_instruments(search: \"AIRBNB\", tradable: true)\n{:ok,\n %{\n   next: nil,\n   page: 1,\n   pages: 1,\n   previous: nil,\n   results: [\n     %LemonMarketsEx.Instrument{isin: \"US0090661010\", ...}\n   ],\n   total: 1\n }}\n```\n\nAs you can see the function returns an `:ok` tuple with the result as map\n\n```elixir\n%{next: nil, previous: nil, page: 1, pages: 1, total: 1, results: [%LemonMarketsEx.Instrument{}]}\n```\n\nPlease refer to [pagination-in-the-market-data-api](https://docs.lemon.markets/market-data/overview#pagination-in-the-market-data-api)\n\n#### Create a new order\n\nSo we've found what we would like to buy. A single stock of `AIRBNB` with the ISIN `\"US0090661010\"`\n\nTo create a new order we need to call the function `LemonMarketsEx.Trading.create_order/1` with the following `params` as second argument:\n\n- `params` - A map of request body params.\n  - `isin` (required) - Internation Security Identification Number of the instrument you wish to buy or sell.\n  - `expires_at` (required) - ISO String date (YYYY-MM-DD). Order expires at the end of the specified day. Maximum expiration date is 30 days in the future.\n  - `side` (required) - With this you can define whether you want to buy (`\"buy\"`) or sell (`\"sell\"`) a specific instrument\n  - `quantity` (required) - The amount of shares you want to buy. Limited to 1000 per request.\n  - `venue` (required) - Market Identifier Code of Stock exchange you want to address. Default value is `\"xmun\"`. Use `venue: \"allday\"` for 24/7 order exeution (only in the Paper Money environment).\n  - `space_id` (required) - Identification Number of the space you want to place the order with.\n  - `stop_price` (optional) - Stop Price for your Order. See: https://docs.lemon.markets/trading/overview#working-with-numbers-in-the-trading-api\n  - `limit_price` (optional) - Limit Price for your Order. See: https://docs.lemon.markets/trading/overview#working-with-numbers-in-the-trading-api\n\n```elixir\niex\u003e params = %{\n  expires_at: \"2021-12-27\",\n  isin: \"US19260Q1076\",\n  quantity: 1,\n  side: \"buy\",\n  space_id: \"sp_1337\"\n}\niex\u003e LemonMarketsEx.Trading.create_order(params)\n{:ok,\n  %{\n  mode: \"paper\",\n  results: %LemonMarketsEx.Order{},\n  status: \"ok\",\n  time: \"2021-12-26T21:35:55.546+00:00\",\n}}\n```\n\n#### Activate the newly created order\n\nNice. We successfully created a new order. But it's status is `\"inactive\"`. That's because we still need to activate the order by calling the `LemonMarketsEx.Trading.activate_order/1` function.\n\nWe can simply pass in the `order_id` to the function and activate it.\n\n```elixir\niex\u003e LemonMarketsEx.activate_order(order_id, %{pin: \"1337\"})\n{:ok, %{mode: \"paper\", status: \"ok\", time: \"2021-12-26T22:12:05.023+00:00\"}}\n```\n\n🥳 Success!\n\nYou might have noticed that we do not need to explicitly specify if we would like to create a `market_order`, `stop_order`, `limit_order` or `stop_limit_order`. [lemon.markets](https://lemon.markets) recognizes the type of order automatically. Please refer to [this great blogpost](https://medium.com/lemon-markets/order-types-at-lemon-markets-explained-a52c39852917) about the different types of orders.\n\n## 🤝 Contributing\n\n1. Fork it [daskycodes/lemon.markets_ex](https://github.com/daskycodes/lemon.markets_ex)\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\nCopyright (c) 2021 Daniel Khaapamyaki\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskycodes%2Flemon.markets_ex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaskycodes%2Flemon.markets_ex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaskycodes%2Flemon.markets_ex/lists"}