semvec/pypi-packages huggingface dataset:
songbirdcore 0.1.7
core low level api for songbird
Requires Python: >=3.11

# songbirdcore 🐦

Low-level package with common code used across songbird's
cli and api.

See: 

- [songbirdcli](https://github.com/cboin1996/songbird.git)
- [songbirdapi](https://github.com/cboin1996/songbirdapi.git)

## Documentation

`songbirdcore`'s documentation may be found [here](https://cboin1996.github.io/songbirdcore)

## Requirements

- Python version >= 3.11

## Installation

To install, run

```bash
pip install songbirdcore
```

To install the latest development version from `test-pypi`
run

```bash
    python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ songbirdcore
```

## Development

Once you have clone the repository, run

```bash
export ENV=dev
make setup
source venv/bin/activate
make requirements
```

This configures a virtual environment locally.
You can then run tests by performing the steps below.

### Updating Requirements

Updating the requirements for this package may be done
through

```bash
make update-requirements
make requirements
```

## Tests

Configure your vscode debugger by creating a `.vscode/settings.json`
file with the following contents:

```json
{
    "python.testing.pytestArgs": [
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true,
}
```
fm-sdk 0.0.2
Python SDK for the Flexemarkets API
Requires Python: >=3.11

# fm-sdk-python

Python SDK for the [Flexemarkets](https://fm-data.herokuapp.com) API.

## Requirements

- Python 3.11+

## Install

```bash
python3.11 -m pip install .
```

Or install dependencies directly:

```bash
python3.11 -m pip install httpx websockets
```

## Configuration

The SDK loads credentials and endpoint from these sources (highest priority first):

1. Arguments passed to `Flexemarkets.connect()`
2. Files `~/.fm/credential` and `~/.fm/endpoint` (Java `.properties` format)
3. Environment variable `FM_API_URL` (defaults to `https://fm-data.herokuapp.com`)

### Credential file

Create `~/.fm/credential`:

```
account=myaccount
email=user@example.com
password=secret
```

Or use a bearer token:

```
token=eyJhbGciOiJIUzI1NiJ9...
```

### Endpoint file

Create `~/.fm/endpoint`:

```
endpoint=https://fm-data.herokuapp.com/api/marketplaces/123
```

## SDK usage

```python
from fm import Flexemarkets, OrderBooks, MarketplaceTrades

# Connect
fm = Flexemarkets.connect(
    credential="~/.fm/credential",
    endpoint="https://fm-data.herokuapp.com/api/marketplaces/123",
    client_description="my-bot",
)

# REST API
marketplace_id = fm.endpoint_marketplace_id
markets = fm.markets(marketplace_id)
session = fm.session(marketplace_id)
holdings = fm.holdings(marketplace_id)

# Submit orders
order = fm.submit_limit(marketplace_id, market_id, "BUY", units=1, price=950)
fm.submit_cancel(marketplace_id, market_id, order.id)

# WebSocket events
import queue

q = queue.Queue(maxsize=1000)
fm.listen(marketplace_id, q)

books = OrderBooks(markets)
trades = MarketplaceTrades(markets)

while True:
    event = q.get()
    match event:
        case list() as orders:
            books.update(orders)
            trades.update(orders)
        case Session() as s:
            print(s.state)
        case Holding() as h:
            print(h.cash)

fm.close()
```

The client also works as a context manager:

```python
with Flexemarkets.connect(credential, endpoint, "my-bot") as fm:
    ...
```

## Applications

### ticker

Live terminal display of order book best bid/ask, spread, and recent trade prices.

```bash
python3.11 ticker.py -C ~/.fm/credential -E https://fm-data.herokuapp.com/api/marketplaces/123
```

Options:

| Flag | Description |
|------|-------------|
| `-C`, `--credential` | Credential file path or bearer token |
| `-E`, `--endpoint` | Marketplace endpoint file path or URL |

Output:

```
fm-ticker                                              OPEN

  Symbol     Bid     Ask  Spread   Last trades
  ------  ------  ------  ------   -----------
    AAPL  $ 9.50  $10.50  $ 1.00   $9.50  $10.00
     IBM  $ 4.00  $ 5.00  $ 1.00   $4.50
```

The display refreshes on each order book update. Press `Ctrl-C` to stop.