Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Deprecate public orders #81

Merged
merged 4 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
"peerDependencies": {
"typescript": "^5.6.2"
},
"version": "0.1.54"
}
"version": "0.1.55"
}
5 changes: 0 additions & 5 deletions src/lib/orders/OrderDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ export function OrderDisplay(props: {
<Box flexDirection="column" gap={1} paddingBottom={1}>
<Text>No orders found.</Text>

<Box paddingLeft={4} flexDirection="column">
<Text dimColor># View all public standing orders</Text>
<Text color="yellow">sf orders list --public</Text>
</Box>

<Box paddingLeft={4} flexDirection="column">
<Text dimColor># Place an order to buy compute</Text>
<Text color="yellow">sf buy</Text>
Expand Down
62 changes: 34 additions & 28 deletions src/lib/orders/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type Command, Option } from "@commander-js/extra-typings";
import dayjs from "dayjs";
import { render } from "ink";
import * as console from "node:console";
import duration from "npm:[email protected]/plugin/duration.js";
import relativeTime from "npm:[email protected]/plugin/relativeTime.js";
import React from "react";
Expand All @@ -12,11 +13,10 @@ import {
logSessionTokenExpiredAndQuit,
} from "../../helpers/errors.ts";
import { fetchAndHandleErrors } from "../../helpers/fetch.ts";
import { getApiUrl } from "../../helpers/urls.ts";
import { parseStartDate } from "../../helpers/units.ts";
import { getApiUrl } from "../../helpers/urls.ts";
import { OrderDisplay } from "./OrderDisplay.tsx";
import type { HydratedOrder, ListResponseBody } from "./types.ts";
import * as console from "node:console";

dayjs.extend(relativeTime);
dayjs.extend(duration);
Expand Down Expand Up @@ -65,7 +65,7 @@ export function registerOrders(program: Command) {
.addOption(
new Option(
"--public",
"Include public orders. Only includes open orders.",
"This option is deprecated. It's no longer possible to view public orders.",
)
.conflicts(["onlyFilled", "onlyCancelled"])
.implies({
Expand All @@ -75,12 +75,12 @@ export function registerOrders(program: Command) {
.option(
"--min-price <price>",
"Filter by minimum price (in cents)",
parseInt,
Number.parseInt,
)
.option(
"--max-price <price>",
"Filter by maximum price (in cents)",
parseInt,
Number.parseInt,
)
.option(
"--min-start <date>",
Expand All @@ -98,23 +98,38 @@ export function registerOrders(program: Command) {
"--max-duration <duration>",
"Filter by maximum duration (in seconds)",
)
.option("--min-quantity <quantity>", "Filter by minimum quantity", parseInt)
.option("--max-quantity <quantity>", "Filter by maximum quantity", parseInt)
.option(
"--min-quantity <quantity>",
"Filter by minimum quantity",
Number.parseInt,
)
.option(
"--max-quantity <quantity>",
"Filter by maximum quantity",
Number.parseInt,
)
.option(
"--contract-id <id>",
"Filter by contract ID (only for sell orders)",
)
.addOption(
new Option("--only-open", "Show only open orders")
.conflicts(["onlyFilled", "onlyCancelled"]),
new Option("--only-open", "Show only open orders").conflicts([
"onlyFilled",
"onlyCancelled",
]),
)
.addOption(
new Option("--exclude-filled", "Exclude filled orders")
.conflicts(["onlyFilled"]),
new Option("--exclude-filled", "Exclude filled orders").conflicts([
"onlyFilled",
]),
)
.addOption(
new Option("--only-filled", "Show only filled orders")
.conflicts(["excludeFilled", "onlyCancelled", "onlyOpen", "public"]),
new Option("--only-filled", "Show only filled orders").conflicts([
"excludeFilled",
"onlyCancelled",
"onlyOpen",
"public",
]),
)
.option(
"--min-filled-at <date>",
Expand All @@ -127,17 +142,14 @@ export function registerOrders(program: Command) {
.option(
"--min-fill-price <price>",
"Filter by minimum fill price (in cents)",
parseInt,
Number.parseInt,
)
.option(
"--max-fill-price <price>",
"Filter by maximum fill price (in cents)",
parseInt,
)
.option(
"--include-cancelled",
"Include cancelled orders",
Number.parseInt,
)
.option("--include-cancelled", "Include cancelled orders")
.addOption(
new Option("--only-cancelled", "Show only cancelled orders")
.conflicts(["onlyFilled", "onlyOpen", "public"])
Expand All @@ -161,11 +173,11 @@ export function registerOrders(program: Command) {
"--max-placed-at <date>",
"Filter by maximum placed date (ISO 8601 datestring)",
)
.option("--limit <number>", "Limit the number of results", parseInt)
.option("--limit <number>", "Limit the number of results", Number.parseInt)
.option(
"--offset <number>",
"Offset the results (for pagination)",
parseInt,
Number.parseInt,
)
.option("--json", "Output in JSON format")
.action(async (options) => {
Expand All @@ -175,8 +187,6 @@ export function registerOrders(program: Command) {
side: options.side,
instance_type: options.type,

include_public: options.public,

min_price: options.minPrice,
max_price: options.maxPrice,
min_start_date: options.minStart,
Expand Down Expand Up @@ -236,8 +246,6 @@ export async function getOrders(props: {
side?: "buy" | "sell";
instance_type?: string;

include_public?: boolean;

min_price?: number;
max_price?: number;
min_start_date?: string;
Expand Down Expand Up @@ -307,9 +315,7 @@ export async function getOrders(props: {
return resp.data;
}

export async function submitOrderCancellationByIdAction(
orderId: string,
) {
export async function submitOrderCancellationByIdAction(orderId: string) {
const loggedIn = await isLoggedIn();
if (!loggedIn) {
logLoginMessageAndQuit();
Expand Down