Module Expr Str Expr Str Import alias ImportFrom alias Import alias identifier ClassDef bases AttributeLoad NameLoad attr body FunctionDef arguments args NameParam defaults vararg kwarg body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Str decorator_list FunctionDef arguments args NameParam defaults kwarg body Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str AttributeLoad NameLoad attr Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Return TupleLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore BinOpDiv BinOpAdd NameLoad NameLoad Num Assign SubscriptStore AttributeLoad AttributeLoad NameLoad attr attr Index TupleLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr keyword Str keyword Str Assign NameStore SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr Index Num Assign NameStore SubscriptLoad Call AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr Index Num Assign AttributeStore NameLoad attr BinOpDiv NameLoad NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareGt NameLoad AttributeLoad NameLoad attr body If BoolOpOr UnaryOpNot AttributeLoad NameLoad attr CompareLt AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareLt NameLoad AttributeLoad NameLoad attr body If BoolOpOr UnaryOpNot AttributeLoad NameLoad attr CompareGt AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad body If NameLoad body AugAssignAdd AttributeStore NameLoad attr AttributeLoad NameLoad attr orelse AugAssignSub AttributeStore NameLoad attr AttributeLoad NameLoad attr If CompareEq AttributeLoad NameLoad attr Num body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body AugAssignAdd AttributeStore NameLoad attr BinOpMult AttributeLoad NameLoad attr IfExp NameLoad BinOpSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr BinOpMult NameLoad IfExp CompareEq NameLoad Str BinOpSub NameLoad NameLoad BinOpSub NameLoad NameLoad orelse Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore IfExp NameLoad Str Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword Str If CompareIsNot NameLoad NameLoad body Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Str Print BinOpMod Str TupleLoad NameLoad NameLoad AttributeLoad NameLoad attr Return NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Print BinOpMod Str TupleLoad Call AttributeLoad Call AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Print NameLoad Expr Call AttributeLoad NameLoad attr decorator_list decorator_list If CompareEq NameLoad Str body Assign NameStore Str Assign NameStore Num Assign NameStore Call NameLoad keyword Str keyword NameLoad Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword Str keyword Num keyword Str keyword Num keyword Num keyword Num keyword Num
N/A N/A 
README
======
This file contains Python codes.
======
 N/A 
Implementing the trend-following algorithm
for trading foreign currencies
 N/A oandapy datetime datetime N/A pandas pd ForexSystem N/A N/A oandapy Streamer N/A __init__ N/A N/A self N/A args kwargs N/A N/A N/A N/A N/A oandapy Streamer __init__ self args kwargs N/A N/A self oanda N/A N/A oandapy API N/A kwargs N/A environment N/A kwargs N/A access_token N/A N/A self instrument None N/A N/A self account_id None N/A N/A self qty 0 N/A N/A self resample_interval 10s N/A N/A self mean_period_short 5 N/A N/A self mean_period_long 20 N/A N/A self buy_threshold 1.0 N/A N/A self sell_threshold 1.0 N/A N/A self prices N/A N/A pd DataFrame N/A N/A self beta 0 N/A N/A self is_position_opened False N/A N/A self opening_price 0 N/A N/A self executed_price 0 N/A N/A self unrealized_pnl 0 N/A N/A self realized_pnl 0 N/A N/A self position 0 N/A N/A self dt_format %Y-%m-%dT%H:%M:%S.%fZ N/A begin N/A N/A self N/A params N/A N/A N/A self instrument N/A params N/A instruments N/A N/A self account_id N/A params N/A accountId N/A N/A self qty N/A params N/A qty N/A N/A self resample_interval N/A params N/A resample_interval N/A N/A self mean_period_short N/A params N/A mean_period_short N/A N/A self mean_period_long N/A params N/A mean_period_long N/A N/A self buy_threshold N/A params N/A buy_threshold N/A N/A self sell_threshold N/A params N/A sell_threshold N/A N/A N/A self start params N/A on_success N/A N/A self data N/A N/A N/A N/A time symbol bid ask N/A N/A self parse_tick_data N/A data N/A tick N/A N/A N/A self tick_event time symbol bid ask N/A parse_tick_data N/A N/A self dict_data N/A N/A N/A time N/A N/A datetime strptime N/A dict_data N/A time N/A self dt_format N/A ask N/A float N/A dict_data N/A ask N/A bid N/A float N/A dict_data N/A bid N/A instrument N/A dict_data N/A instrument N/A N/A time instrument bid ask N/A tick_event N/A N/A self time symbol bid ask N/A N/A N/A midprice N/A N/A ask bid 2.0 N/A N/A N/A N/A self prices loc N/A N/A time symbol midprice N/A resampled_prices N/A N/A N/A self prices resample N/A self resample_interval how last fill_method ffill N/A mean_short N/A N/A N/A N/A N/A resampled_prices tail N/A self mean_period_short mean N/A 0 N/A mean_long N/A N/A N/A N/A N/A resampled_prices tail N/A self mean_period_long mean N/A 0 N/A N/A self beta N/A mean_short mean_long N/A N/A N/A self perform_trade_logic N/A self beta N/A N/A N/A self calculate_unrealized_pnl bid ask N/A N/A N/A self print_status N/A perform_trade_logic N/A N/A self beta N/A N/A N/A N/A beta N/A self buy_threshold N/A N/A N/A N/A N/A self is_position_opened N/A N/A self position 0 N/A N/A N/A N/A self check_and_send_order True N/A N/A N/A beta N/A self sell_threshold N/A N/A N/A N/A N/A self is_position_opened N/A N/A self position 0 N/A N/A N/A N/A self check_and_send_order False N/A check_and_send_order N/A N/A self is_buy N/A N/A N/A N/A N/A self place_market_order N/A self qty is_buy N/A N/A is_buy N/A N/A N/A self position N/A self qty N/A N/A N/A self position N/A self qty N/A N/A N/A self position 0 N/A N/A N/A self is_position_opened False N/A N/A N/A self calculate_realized_pnl is_buy N/A N/A N/A self opening_price N/A self executed_price N/A N/A self is_position_opened True N/A calculate_realized_pnl N/A N/A self is_buy N/A N/A N/A N/A self realized_pnl N/A N/A self qty N/A is_buy N/A N/A self opening_price N/A self executed_price N/A N/A self executed_price N/A self opening_price N/A calculate_unrealized_pnl N/A N/A self bid ask N/A N/A N/A N/A self is_position_opened N/A N/A pos N/A N/A N/A self oanda get_position N/A self account_id N/A self instrument N/A units N/A pos N/A units N/A side N/A pos N/A side N/A avg_price N/A float N/A pos N/A avgPrice N/A N/A self unrealized_pnl N/A units N/A N/A side buy N/A bid avg_price N/A avg_price ask N/A N/A N/A self unrealized_pnl 0 N/A place_market_order N/A N/A self qty is_buy N/A N/A N/A side N/A is_buy buy sell N/A response N/A N/A N/A self oanda create_order account_id instrument N/A self instrument units qty side side type market N/A N/A response None N/A N/A N/A self executed_price N/A float N/A response N/A price N/A N/A Placed order %s %s %s at market. N/A side qty N/A self instrument N/A True N/A False N/A print_status N/A N/A self N/A N/A N/A N/A [%s] %s pos=%s beta=%s RPnL=%s UPnL=%s N/A N/A N/A N/A N/A datetime now time N/A self instrument N/A self position N/A round N/A self beta 5 N/A self realized_pnl N/A self unrealized_pnl N/A on_error N/A N/A self data N/A N/A N/A data N/A N/A N/A self disconnect N/A N/A N/A N/A __name__ __main__ N/A N/A key 4c7718c7e03d472c2369abf1cb7ceddb-142b7d845d68844e853bb95c63f1c8b9 N/A account_id 6858884 N/A system N/A ForexSystem environment practice access_token key N/A N/A N/A system begin accountId account_id instruments EUR_USD qty 1000 resample_interval 10s mean_period_short 5 mean_period_long 20 buy_threshold 1.0 sell_threshold 1.0