For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Question about "Buy and Buy More" result



  • Trying to build a monthly investment strategy like "Buy and Buy More" Link. However, when I print the daily result on values of cash and share, I find that the cash value is not updated for some months after the monthly investment. From what I know, the cash position at any time should not be greatly higher than the share price since the strategy uses all available cash for the purchase. But this is not what I observe when I include notify_fund function.

    Below are some abnormal results

    2008-10-24, Cash 82.13 Value 77460.69 shares 1276.07 close 87.04
    2008-10-27, Cash 82.13 Value 74713.67 shares 1276.07 close 83.95
    2008-10-28, Cash 82.13 Value 83434.77 shares 1276.07 close 93.76
    2008-10-29, Cash 82.13 Value 82830.25 shares 1276.07 close 93.08
    2008-10-30, Cash 82.13 Value 85692.83 shares 1276.07 close 96.30
    2008-10-31, Cash 82.13 Value 86164.00 shares 1276.07 close 96.83
    2008-11-03, Cash 1082.13 Value 86412.92 shares 1290.83 close 97.11
    2008-11-04, Cash 1082.13 Value 90346.62 shares 1290.83 close 100.41
    2008-11-05, Cash 1082.13 Value 86595.04 shares 1290.83 close 96.19
    2008-11-06, Cash 1082.13 Value 81856.67 shares 1290.83 close 90.86
    2008-11-07, Cash 1082.13 Value 84523.67 shares 1290.83 close 93.86

    The monthly investment is 1000. After the monthly investment on Nov 2008, the cash position does not update but the number of share has updated.

    Wanna get any help on this. Thanks a lot



  • I've ran script from that blog post and printed from the next() like this:

        def next(self):
            self.log('cash %.2f, size %d, close %.2f' %
                   (self.broker.get_cash(), self.position.size, self.data.close[0]))
    

    Everything works as expected. Share your code so we can compare approaches and find an issue.


Log in to reply
 

});