pipiku915 / FinMem-LLM-StockTrading

FinMem: A Performance-Enhanced LLM Trading Agent with Layered Memory and Character Design
MIT License
312 stars 73 forks source link

cummulative return #23

Open ccxxiicc opened 2 months ago

ccxxiicc commented 2 months ago

how to calculate buy and hold ‘s cumulative return?In your method,action is zero.

Carolyn-Jiang commented 2 months ago

In our method the actions are all 1 for buy and hold. We used log return to calculate the cumulative return.

reward += log(price[i+1]/price[i])

You can calculate it with CR = log(last day’s price/first day’s price)


From: ccxxiicc @.> Sent: Wednesday, August 21, 2024 5:20:10 PM To: pipiku915/FinMem-LLM-StockTrading @.> Cc: Subscribed @.***> Subject: [pipiku915/FinMem-LLM-StockTrading] cummulative return (Issue #23)

how to calculate buy and hold ‘s cumulative return?In your method,action is zero.

— Reply to this email directly, view it on GitHubhttps://github.com/pipiku915/FinMem-LLM-StockTrading/issues/23, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANUUDRR7JQB427EM2JACL53ZSRLUVAVCNFSM6AAAAABM3S6PPCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TONJSG4YTSMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

ccxxiicc commented 2 months ago

But in your method,when actions are 1,it refer to buy 1 in that day?By the way,cr's calculations omitted action in the formula you gave above.

Carolyn-Jiang commented 2 months ago

When action_i equals one. You can consider it as hold one share on day_i. The return for day_i = action_i * log(p[i+1]/p[i]) Because action_i = 1, return of day_i = log(p[i+1]/p[i]), CR = sum(return_1+return_2+…+return_i) = log(p[2]/p[1])+ log(p[3]/p[2]) + … + log(p[i+1]/p[i]) = log(p[2])-log(p[1])+log(p[3])-log(p[2])+…+log(p[i+1])-log(p[i]) =log(p[i+1])-log(p[1]) = log(p[i+1]/p[1])


From: ccxxiicc @.> Sent: Wednesday, August 21, 2024 5:45:38 PM To: pipiku915/FinMem-LLM-StockTrading @.> Cc: Yuechen Jiang @.>; Comment @.> Subject: Re: [pipiku915/FinMem-LLM-StockTrading] cummulative return (Issue #23)

But in your method,when actions are 1,it refer to buy 1 in that day?By the way,cr's calculations omitted action in the formula you gave above.

— Reply to this email directly, view it on GitHubhttps://github.com/pipiku915/FinMem-LLM-StockTrading/issues/23#issuecomment-2301623808, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANUUDRURA5I6GVM64DWFL4LZSROUFAVCNFSM6AAAAABM3S6PPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBRGYZDGOBQHA. You are receiving this because you commented.Message ID: @.***>

ccxxiicc commented 2 months ago

Can you tell me the reason that you set actions all 1 in buy and hold? what the difference between it and one strategy that always buy 1 everyday?

Carolyn-Jiang commented 2 months ago

Buy and hold means. Buy at the start day and hold it until the end day to sell it. Every day’s return percentage is the price change percentage. Let’s consider we have cash for $1000, and the price of stock A is $100. We plan to buy stock A for half a year(126 trading days). We should buy 10 shares of A on day 1 and sell it on the day 126. In this case, you always buy 1 every day. What should you do on day 11? You cannot consider you have unlimited money for a trading strategy. Because this is a single stock trading task, no matter how many shares you bought on the first day the return of day i should be log[(p_i+1)share/(p_ishare)]=log(p_i+1/p_i).

Get Outlook for iOShttps://aka.ms/o0ukef


From: ccxxiicc @.> Sent: Wednesday, August 21, 2024 6:18:59 PM To: pipiku915/FinMem-LLM-StockTrading @.> Cc: Yuechen Jiang @.>; Comment @.> Subject: Re: [pipiku915/FinMem-LLM-StockTrading] cummulative return (Issue #23)

Can you tell me the reason that you set actions all 1 in buy and hold? what the difference between it and one strategy that always buy 1 everyday?

— Reply to this email directly, view it on GitHubhttps://github.com/pipiku915/FinMem-LLM-StockTrading/issues/23#issuecomment-2301689858, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANUUDRU4324KGPVSVI3DGFLZSRSRHAVCNFSM6AAAAABM3S6PPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBRGY4DSOBVHA. You are receiving this because you commented.Message ID: @.***>

ccxxiicc commented 2 months ago

How do you initialize the cash and stock counts to get the results? Is there any basis for this?

Carolyn-Jiang commented 2 months ago

Refer to the example provided in the previous email. The cumulative return is expressed as a percentage. The initial cash determines the number of shares of the asset that can be purchased, yet it is irrelevant when calculating the cumulative return. For instance, if the initial price p_0 is $100 and the final price p_i is $110, the cumulative return from t_0 to t_1 remains 10%, irrespective of whether you bought one share or one hundred shares using the Buy and Hold strategy. In single asset trading, the initial cash amount doesn’t influence our calculations since we assign a weight of 1, -1, or 0 to the target asset only. Thus, there’s no need to set an initial cash amount.

Get Outlook for iOShttps://aka.ms/o0ukef


From: ccxxiicc @.> Sent: Thursday, August 22, 2024 11:43:05 AM To: pipiku915/FinMem-LLM-StockTrading @.> Cc: Yuechen Jiang @.>; Comment @.> Subject: Re: [pipiku915/FinMem-LLM-StockTrading] cummulative return (Issue #23)

How do you initialize the cash and stock counts to get the results? Is there any basis for this?

— Reply to this email directly, view it on GitHubhttps://github.com/pipiku915/FinMem-LLM-StockTrading/issues/23#issuecomment-2303614152, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANUUDRRX52CVBOOJH4IE6PDZSVM4TAVCNFSM6AAAAABM3S6PPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTGYYTIMJVGI. You are receiving this because you commented.Message ID: @.***>