@@ -77,14 +77,14 @@ type TradePlanBuildSuccess = {
7777
7878type TradePlanBuildResult = TradePlanBuildFailure | TradePlanBuildSuccess ;
7979
80- export function savePlanFile ( plan : TradePlanBuildSuccess , postOnly : boolean ) : string {
80+ export function savePlanFile ( plan : TradePlanBuildSuccess , postOnly : boolean , orderId : string ) : string {
8181 const configDir = process . env [ "XDG_CONFIG_HOME" ] ?? path . join ( os . homedir ( ) , ".config" ) ;
8282 const plansDir = path . join ( configDir , "helper" , "plans" ) ;
8383 mkdirSync ( plansDir , { recursive : true } ) ;
8484 const timestamp = new Date ( ) . toISOString ( ) . replace ( / [: .] / g, "-" ) ;
8585 const filename = `${ plan . product . toLowerCase ( ) } -${ timestamp } .json` ;
8686 const filePath = path . join ( plansDir , filename ) ;
87- writeFileSync ( filePath , serializeJson ( { ...plan , orderOptions : { ...plan . orderOptions , postOnly } } as Record < string , unknown > ) ) ;
87+ writeFileSync ( filePath , serializeJson ( { ...plan , orderId , orderOptions : { ...plan . orderOptions , postOnly } } as Record < string , unknown > ) ) ;
8888 return filePath ;
8989}
9090
@@ -384,9 +384,9 @@ export async function handlePlanAction(product: string, options: PlanOptions): P
384384 console . log ( ` Stop Price: ${ limitTpSlOptions . stopPrice } ` ) ;
385385 console . log ( ` Post Only: ${ limitTpSlOptions . postOnly } ` ) ;
386386
387- const placed = await placeLimitTpSlOrder ( getProductId ( product ) , limitTpSlOptions ) ;
388- if ( placed ) {
389- const filePath = savePlanFile ( plan , limitTpSlOptions . postOnly ?? true ) ;
387+ const orderId = await placeLimitTpSlOrder ( getProductId ( product ) , limitTpSlOptions ) ;
388+ if ( orderId ) {
389+ const filePath = savePlanFile ( plan , limitTpSlOptions . postOnly ?? true , orderId ) ;
390390 console . log ( `Plan saved: ${ filePath } ` ) ;
391391 }
392392}
0 commit comments