prettify, sorry for the big ass commit

This commit is contained in:
Olivier Gagnon
2021-09-04 19:09:30 -04:00
parent 3d7cdb4ef9
commit a18bdd6afc
554 changed files with 91615 additions and 66138 deletions
+48 -43
View File
@@ -6,56 +6,61 @@ import { OrderTypes } from "./data/OrderTypes";
import { PositionTypes } from "./data/PositionTypes";
import {
Generic_fromJSON,
Generic_toJSON,
Reviver,
Generic_fromJSON,
Generic_toJSON,
Reviver,
} from "../../utils/JSONReviver";
export class Order {
readonly pos: PositionTypes;
readonly price: number;
shares: number;
readonly stockSymbol: string;
readonly type: OrderTypes;
readonly pos: PositionTypes;
readonly price: number;
shares: number;
readonly stockSymbol: string;
readonly type: OrderTypes;
constructor(stockSymbol="", shares=0, price=0, typ: OrderTypes=OrderTypes.LimitBuy, pos: PositionTypes=PositionTypes.Long) {
// Validate arguments
let invalidArgs = false;
if (typeof shares !== "number" || typeof price !== "number") {
invalidArgs = true;
}
if (isNaN(shares) || isNaN(price)) {
invalidArgs = true;
}
if (typeof stockSymbol !== "string") {
invalidArgs = true;
}
if (invalidArgs) {
throw new Error(`Invalid constructor paramters for Order`);
}
this.stockSymbol = stockSymbol;
this.shares = shares;
this.price = price;
this.type = typ;
this.pos = pos;
constructor(
stockSymbol = "",
shares = 0,
price = 0,
typ: OrderTypes = OrderTypes.LimitBuy,
pos: PositionTypes = PositionTypes.Long,
) {
// Validate arguments
let invalidArgs = false;
if (typeof shares !== "number" || typeof price !== "number") {
invalidArgs = true;
}
if (isNaN(shares) || isNaN(price)) {
invalidArgs = true;
}
if (typeof stockSymbol !== "string") {
invalidArgs = true;
}
if (invalidArgs) {
throw new Error(`Invalid constructor paramters for Order`);
}
/**
* Serialize the Order to a JSON save state.
*/
toJSON(): any {
return Generic_toJSON("Order", this);
}
this.stockSymbol = stockSymbol;
this.shares = shares;
this.price = price;
this.type = typ;
this.pos = pos;
}
/**
* Initializes a Order from a JSON save state
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static fromJSON(value: any): Order {
return Generic_fromJSON(Order, value.data);
}
/**
* Serialize the Order to a JSON save state.
*/
toJSON(): any {
return Generic_toJSON("Order", this);
}
/**
* Initializes a Order from a JSON save state
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static fromJSON(value: any): Order {
return Generic_fromJSON(Order, value.data);
}
}
Reviver.constructors.Order = Order;